omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tools / bootstrap.sh
| 1 | #!/bin/sh |
| 2 | # Source-only replay on Linux AArch64. No C compiler, assembler or linker. |
| 3 | set -eu |
| 4 | cd "$(dirname "$0")/.." |
| 5 | [ "$(uname -m)" = aarch64 ] || { echo 'bootstrap requires Linux AArch64' >&2; exit 1; } |
| 6 | pin=29b12760f4c962606411d6bf25032aedef063301 |
| 7 | mkdir -p build/bootstrap |
| 8 | if [ -n "${OMEGA_SOURCE:-}" ]; then |
| 9 | source_repo=$OMEGA_SOURCE |
| 10 | else |
| 11 | source_repo=build/bootstrap/upstream |
| 12 | if [ ! -d "$source_repo/.git" ]; then git init -q "$source_repo"; fi |
| 13 | git -C "$source_repo" fetch -q --depth=1 https://github.com/aien-spark/omega.git "$pin" |
| 14 | fi |
| 15 | # Archive only audited source rungs. Never import an opaque executable. |
| 16 | git -C "$source_repo" archive "$pin" seed/rung0/seed0.hex seed/rung0/load0.sh seed/rung1/hex1.hex seed/rung2/asm2.hex1 seed/rung2/table.s2 seed/rung3/table3.s2 seed/rung4/table4.s2 seed/rung4/om4.s seed/rung4/mk4.sh seed/omc/omc.om > build/bootstrap/source.tar |
| 17 | mkdir -p build/bootstrap/source |
| 18 | tar -xf build/bootstrap/source.tar -C build/bootstrap/source |
| 19 | cd build/bootstrap/source |
| 20 | verify() { |
| 21 | [ -s "$1" ] |
| 22 | file "$1" | grep -q 'ELF 64-bit.*ARM aarch64' |
| 23 | chmod +x "$1" |
| 24 | } |
| 25 | sh seed/rung0/load0.sh seed/rung0/seed0.hex seed/rung0/seed0.bin |
| 26 | verify seed/rung0/seed0.bin |
| 27 | seed/rung0/seed0.bin < seed/rung0/seed0.hex > seed/rung0/self |
| 28 | cmp seed/rung0/seed0.bin seed/rung0/self |
| 29 | seed/rung0/seed0.bin < seed/rung1/hex1.hex > seed/rung1/hex1.bin |
| 30 | verify seed/rung1/hex1.bin |
| 31 | seed/rung1/hex1.bin < seed/rung2/asm2.hex1 > seed/rung2/asm2.bin |
| 32 | verify seed/rung2/asm2.bin |
| 33 | sh seed/rung4/mk4.sh |
| 34 | verify seed/rung4/om4.bin |
| 35 | seed/rung4/om4.bin < seed/omc/omc.om > ../stage1 |
| 36 | verify ../stage1 |
| 37 | ../stage1 < seed/omc/omc.om > ../stage2 |
| 38 | verify ../stage2 |
| 39 | ../stage2 < seed/omc/omc.om > ../stage3 |
| 40 | verify ../stage3 |
| 41 | cmp ../stage1 ../stage2 |
| 42 | cmp ../stage2 ../stage3 |
| 43 | [ "$(sha256sum ../stage3 | cut -d' ' -f1)" = 191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 ] |
| 44 | cp ../stage3 ../omc |
| 45 | printf 'source=%s\n' "$pin" |
| 46 | sha256sum seed/omc/omc.om ../omc |
| 47 | printf 'bootstrap fixpoint RC=0\n' |