aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / allen / build-local-model.sh
| 1 | #!/bin/sh |
| 2 | # Opt-in firmware build. Does not change the default Allen firmware. |
| 3 | # Usage: OMEGA_COMPILER=/pinned/omc sh build-local-model.sh AIEN_TRAIN OUT.EFI |
| 4 | set -eu |
| 5 | [ "$#" = 2 ] || { echo 'usage: build-local-model.sh AIEN_TRAIN OUT.EFI' >&2; exit 64; } |
| 6 | here=$(CDPATH= cd -- "$(dirname "$0")" && pwd) |
| 7 | train=$1/native/omegallm |
| 8 | out=$2 |
| 9 | compiler=${OMEGA_COMPILER:?set OMEGA_COMPILER to the pinned x86efi compiler} |
| 10 | pin=3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 |
| 11 | [ "$(sha256sum "$compiler" | cut -d' ' -f1)" = "$pin" ] || { echo 'compiler pin mismatch' >&2; exit 65; } |
| 12 | [ ! -e "$out" ] || { echo 'fresh output required' >&2; exit 73; } |
| 13 | mkdir -p "$(dirname "$out")" |
| 14 | unit=$out.om |
| 15 | { |
| 16 | printf '%s\n' 'target x86efi' |
| 17 | cat "$here/base.om" "$here/runtime.om" |
| 18 | for f in math data epool model adam ckpt bpe cli; do cat "$train/$f.om"; done |
| 19 | # Only the platform entry point and output hook are replaced. Model math is unmodified. |
| 20 | sed -e 's/^fn main to int$/fn ollm_file_main to int/' \ |
| 21 | -e 's/^fn oflush to void$/fn ollm_file_flush to void/' "$train/eio.om" |
| 22 | cat "$train/nogpu.om" "$here/local-model.om" |
| 23 | } > "$unit" |
| 24 | dup=$(grep -E '^(fn|global|const|text|struct) ' "$unit" | awk '{print $2}' | sort | uniq -d) |
| 25 | [ -z "$dup" ] || { echo "duplicate declarations: $dup" >&2; exit 65; } |
| 26 | rc=0 |
| 27 | "$compiler" < "$unit" > "$out.tmp" 2> "$out.err" || rc=$? |
| 28 | if [ "$rc" != 0 ]; then |
| 29 | cat "$out.err" >&2 |
| 30 | rm -f "$out.tmp" |
| 31 | exit "$rc" |
| 32 | fi |
| 33 | [ "$(head -c 2 "$out.tmp")" = MZ ] || { echo 'not an EFI image' >&2; rm -f "$out.tmp"; exit 65; } |
| 34 | mv "$out.tmp" "$out" |
| 35 | sha256sum "$compiler" "$unit" "$out" |