aien-protocols-mv
Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem
Brought by drakestapleton
aien-protocols-mv / specs / aienet / jobpath / build.sh
| 1 | #!/bin/sh |
| 2 | # Build the Spark's matmul_u32 recompute: the pinned OM-2 SHA-256 unit of omega-mv followed by |
| 3 | # matmul_u32_recompute.om, compiled by the pinned seed-born omc. Exit 3 NOT_RUN when a pin differs. |
| 4 | # OMEGA_OMC omc binary (sha256 pinned below) |
| 5 | # OMEGA_MV an omega-mv checkout holding om/sha256/sha256-om2.om (sha256 pinned below) |
| 6 | # $1 output path (default ./matmul_u32_recompute) |
| 7 | set -eu |
| 8 | OMC_PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f |
| 9 | SHA_UNIT_PIN=$(sed -n 's/^SHA_UNIT_PIN=//p' "$(dirname "$0")/pins.txt") |
| 10 | HERE=$(cd "$(dirname "$0")" && pwd) |
| 11 | OUT=${1:-./matmul_u32_recompute} |
| 12 | [ -n "${OMEGA_OMC:-}" ] && [ -n "${OMEGA_MV:-}" ] || { echo "NOT_RUN: set OMEGA_OMC and OMEGA_MV"; exit 3; } |
| 13 | [ "$(sha256sum < "$OMEGA_OMC" | cut -c1-64)" = "$OMC_PIN" ] || { echo "NOT_RUN: omc is not the pinned compiler"; exit 3; } |
| 14 | UNIT="$OMEGA_MV/om/sha256/sha256-om2.om" |
| 15 | [ "$(sha256sum < "$UNIT" | cut -c1-64)" = "$SHA_UNIT_PIN" ] || { echo "NOT_RUN: $UNIT is not the pinned SHA-256 unit"; exit 3; } |
| 16 | T=$(mktemp -d); trap 'rm -rf "$T"' EXIT |
| 17 | # Program mode has no exported entries (omc error 9 on `export fn`), so the unit's four `export fn` |
| 18 | # lines lose the word `export` and nothing else; every other byte of the unit is used as pinned. |
| 19 | sed 's/^export fn /fn /' "$UNIT" > "$T/unit.om" |
| 20 | [ "$(grep -c '^export fn ' "$UNIT")" = 4 ] && ! grep -q '^export fn ' "$T/unit.om" || { echo "FAIL: unexpected SHA-256 unit shape"; exit 1; } |
| 21 | cat "$T/unit.om" "$HERE/matmul_u32_recompute.om" > "$T/src.om" |
| 22 | "$OMEGA_OMC" < "$T/src.om" > "$T/bin" |
| 23 | chmod +x "$T/bin" |
| 24 | mv "$T/bin" "$OUT" |
| 25 | echo "built $OUT sha256=$(sha256sum < "$OUT" | cut -c1-64) src=$(sha256sum < "$T/src.om" | cut -c1-64)" |