Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/physics-mv/blob/main/m2_build.sh # physics-mv FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `physics-mv / m2_build.sh` 86 lines ยท 3463 bytes Raw Blame History 1 #!/bin/sh 2 # m2_build.sh -- Python-free build system for Milestone 2 (PHYSICS_BOOT) 3 # 4 # Builds canonical artifacts and Seam 2 variants from source. 5 # Everything is built deterministically. 6 set -eu 7 8 REPO_DIR=$(cd "$(dirname "$0")" && pwd -P) 9 cd "$REPO_DIR" 10 11 CC=${CC:-aarch64-linux-gnu-gcc} 12 LD=${LD:-aarch64-linux-gnu-ld} 13 OBJCOPY=${OBJCOPY:-aarch64-linux-gnu-objcopy} 14 HOSTCC=${HOSTCC:-gcc} 15 16 TOOLS_DIR="$REPO_DIR/tools" 17 BUILD_DIR="$REPO_DIR/build" 18 M2TOOL="$TOOLS_DIR/m2tool" 19 20 # 1. Compile host m2tool if not present or newer 21 if [ ! -f "$M2TOOL" ] || [ "$TOOLS_DIR/m2tool.c" -nt "$M2TOOL" ] || [ "$REPO_DIR/sha256_clean.c" -nt "$M2TOOL" ]; then 22 echo "[*] Compiling m2tool host utility..." 23 "$HOSTCC" -O2 -std=c11 -Wall -Wextra -Werror -o "$M2TOOL" "$TOOLS_DIR/m2tool.c" "$REPO_DIR/sha256_clean.c" 24 fi 25 26 # 2. Build canonical artifacts into build/canonical 27 mkdir -p "$BUILD_DIR/canonical" 28 CANON="$BUILD_DIR/canonical" 29 30 # Compile sha256_clean.o for target 31 "$CC" -nostdlib -ffreestanding -mgeneral-regs-only -O2 -c "$REPO_DIR/sha256_clean.c" -o "$CANON/sha256_clean.o" 32 33 # Assemble canonical physics modules 34 for s in physics.s vector_table.s memory_alloc.s capability.s; do 35 o="$CANON/$(basename "$s" .s).o" 36 "$CC" -c -nostdlib -ffreestanding "$REPO_DIR/$s" -o "$o" 37 done 38 39 # Link canonical physics.elf and extract binary 40 "$LD" -T "$REPO_DIR/physics.ld" \ 41 "$CANON/physics.o" "$CANON/vector_table.o" "$CANON/memory_alloc.o" "$CANON/capability.o" \ 42 -o "$CANON/physics.elf" 43 "$OBJCOPY" -O binary "$CANON/physics.elf" "$CANON/physics.bin" 44 45 # Generate pin 46 "$M2TOOL" pin-inc "$CANON/physics.bin" "$CANON/physics_pin.inc" 47 48 # Assemble and link atlas_m2 49 "$CC" -c -nostdlib -ffreestanding -I"$CANON" "$REPO_DIR/atlas_m2.s" -o "$CANON/atlas_m2.o" 50 "$LD" -Ttext=0x00000000 "$CANON/atlas_m2.o" "$CANON/sha256_clean.o" -o "$CANON/atlas_m2.elf" 51 "$OBJCOPY" -O binary "$CANON/atlas_m2.elf" "$CANON/atlas_m2.bin" 52 53 # 3. Helper functions for Seam 2 variants 54 build_variant() { 55 name="$1" 56 v_dir="$BUILD_DIR/seam2/$name" 57 mkdir -p "$v_dir" 58 "$M2TOOL" gen-snippet "$name" "$REPO_DIR/physics.s" "$v_dir/physics_$name.s" 59 "$CC" -c -nostdlib -ffreestanding "$v_dir/physics_$name.s" -o "$v_dir/physics.o" 60 "$CC" -c -nostdlib -ffreestanding "$REPO_DIR/vector_table.s" -o "$v_dir/vector_table.o" 61 "$CC" -c -nostdlib -ffreestanding "$REPO_DIR/memory_alloc.s" -o "$v_dir/memory_alloc.o" 62 "$CC" -c -nostdlib -ffreestanding "$REPO_DIR/capability.s" -o "$v_dir/capability.o" 63 64 "$LD" -T "$REPO_DIR/physics.ld" \ 65 "$v_dir/physics.o" "$v_dir/vector_table.o" "$v_dir/memory_alloc.o" "$v_dir/capability.o" \ 66 -o "$v_dir/physics.elf" 67 "$OBJCOPY" -O binary "$v_dir/physics.elf" "$v_dir/physics.bin" 68 69 "$M2TOOL" pin-inc "$v_dir/physics.bin" "$v_dir/physics_pin.inc" 70 (cd "$v_dir" && "$CC" -c -nostdlib -ffreestanding "$REPO_DIR/atlas_m2.s" -o atlas_m2.o) 71 "$LD" -Ttext=0x00000000 "$v_dir/atlas_m2.o" "$CANON/sha256_clean.o" -o "$v_dir/atlas_m2.elf" 72 "$OBJCOPY" -O binary "$v_dir/atlas_m2.elf" "$v_dir/atlas_m2.bin" 73 } 74 75 build_hostile() { 76 tag="$1" 77 defsym="$2" 78 h_dir="$BUILD_DIR/seam2/hostile_$tag" 79 mkdir -p "$h_dir" 80 cp "$CANON/physics_pin.inc" "$h_dir/" 81 (cd "$h_dir" && "$CC" -c -nostdlib -ffreestanding -Wa,--defsym,"$defsym" "$REPO_DIR/atlas_m2.s" -o atlas_m2.o) 82 "$LD" -Ttext=0x00000000 "$h_dir/atlas_m2.o" "$CANON/sha256_clean.o" -o "$h_dir/atlas_m2.elf" 83 "$OBJCOPY" -O binary "$h_dir/atlas_m2.elf" "$h_dir/atlas_m2.bin" 84 } 85 86 echo "m2_build: built canonical artifacts -> $CANON"