interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / build-local-model.sh

35 lines · 1585 bytes Raw Blame History
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
4set -eu
5[ "$#" = 2 ] || { echo 'usage: build-local-model.sh AIEN_TRAIN OUT.EFI' >&2; exit 64; }
6here=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
7train=$1/native/omegallm
8out=$2
9compiler=${OMEGA_COMPILER:?set OMEGA_COMPILER to the pinned x86efi compiler}
10pin=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; }
13mkdir -p "$(dirname "$out")"
14unit=$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"
24dup=$(grep -E '^(fn|global|const|text|struct) ' "$unit" | awk '{print $2}' | sort | uniq -d)
25[ -z "$dup" ] || { echo "duplicate declarations: $dup" >&2; exit 65; }
26rc=0
27"$compiler" < "$unit" > "$out.tmp" 2> "$out.err" || rc=$?
28if [ "$rc" != 0 ]; then
29 cat "$out.err" >&2
30 rm -f "$out.tmp"
31 exit "$rc"
32fi
33[ "$(head -c 2 "$out.tmp")" = MZ ] || { echo 'not an EFI image' >&2; rm -f "$out.tmp"; exit 65; }
34mv "$out.tmp" "$out"
35sha256sum "$compiler" "$unit" "$out"