aien
aien-dev/aien
Brought by drakestapleton
aien / scripts / goal_microjobs / build.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | # Build the Allen #13 microjob kernel with the pinned seeded Omega compiler. |
| 4 | # Usage: OMEGA_WORKTREE=... build.sh [SOURCE.om] [OUTPUT] |
| 5 | set -euo pipefail |
| 6 | |
| 7 | repo=$(cd "$(dirname "$0")/../.." && pwd) |
| 8 | : "${OMEGA_WORKTREE:?Set OMEGA_WORKTREE to the isolated seeded-Omega compiler worktree}" |
| 9 | |
| 10 | # Same pins as scripts/harness_evolution/gate.sh on feat/harness-evolution-alpha (Allen #12). |
| 11 | omega_pin=c434565c67552c0b01df2d7f76c1a04287c70560 |
| 12 | compiler_pin=191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9 |
| 13 | seed_source_pin=8608fa11f6a2cf1c50db22d871eef16b00d5bc719bc1a222cc3e456984ac5ebf |
| 14 | |
| 15 | compiler="$OMEGA_WORKTREE/build/L574/toolchain/build/bootstrap/omc" |
| 16 | verify_elf="$OMEGA_WORKTREE/build/L574/toolchain/tools/verify-elf.sh" |
| 17 | blocked() { printf 'BLOCKED: %s\n' "$*" >&2; exit 3; } |
| 18 | test "$(git -C "$OMEGA_WORKTREE" rev-parse HEAD)" = "$omega_pin" || |
| 19 | blocked "Omega checkout must be $omega_pin" |
| 20 | # This historical toolchain was an untracked build artifact, not part of the |
| 21 | # Omega commit. A fresh clone alone cannot supply it. Never substitute a newer |
| 22 | # compiler or run an unchecked binary. |
| 23 | test -x "$compiler" && test -f "$verify_elf" && |
| 24 | test -f "$OMEGA_WORKTREE/build/L574/toolchain/seed/omc/omc.om" || |
| 25 | blocked "missing historical build/L574/toolchain artifacts; obtain the archived toolchain listed in docs/GOAL_MICROJOBS.md" |
| 26 | test "$(sha256sum "$compiler" | cut -d' ' -f1)" = "$compiler_pin" || |
| 27 | blocked "historical compiler digest differs from $compiler_pin" |
| 28 | test "$(sha256sum "$OMEGA_WORKTREE/build/L574/toolchain/seed/omc/omc.om" | cut -d' ' -f1)" = "$seed_source_pin" || |
| 29 | blocked "historical compiler source digest differs from $seed_source_pin" |
| 30 | |
| 31 | src=${1:-"$repo/src/goal_microjobs/kernel.om"} |
| 32 | out=${2:-"${GM_BUILD_DIR:-$repo/target/goal_microjobs}/kernel"} |
| 33 | mkdir -p "$(dirname "$out")" |
| 34 | tmp="$out.tmp.$$" |
| 35 | if ! "$compiler" < "$src" > "$tmp" 2> "$tmp.stderr"; then |
| 36 | cat "$tmp.stderr" >&2 |
| 37 | rm -f "$tmp" "$tmp.stderr" |
| 38 | echo 'seeded .om compile failed' >&2 |
| 39 | exit 65 |
| 40 | fi |
| 41 | rm -f "$tmp.stderr" |
| 42 | sh "$verify_elf" "$tmp" |
| 43 | chmod 700 "$tmp" |
| 44 | mv "$tmp" "$out" |
| 45 | printf '%s\n' "$out" |