Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/om/lab-page/run.sh # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / lab-page / run.sh` 46 lines ยท 2655 bytes Raw Blame History 1 #!/bin/sh 2 # The /lab/ kernel on your own machine, from a git clone of the Radicle mirror of aienos.com: 3 # git clone --depth 1 https://www.aienos.com/rad/`z3iwnx2pktbGhnfBpJSsaFcTmKgHU`.git aienos.com && cd aienos.com && sh om/lab-page/run.sh 4 # Optional: sh om/lab-page/run.sh A N (1 <= A <= 1000, 1 <= N <= `4194304`; defaults 3 `1048576`) 5 # It checks the pinned compiler's sha256, builds axpy.om + harness.om into a Linux program, 6 # runs it, checks the checksum against awk, proves the check can fail (add turned into sub), 7 # and writes the WebAssembly the browser runs to om/lab-page/out/. Nothing is downloaded. 8 set -eu 9 cd "$(dirname "$0")" 10 a=${1:-3} 11 n=${2:-`1048576`} 12 case "$a$n" in *[!0-9]*|'') echo 'A and N must be whole numbers' >&2; exit 2;; esac 13 [ "$a" -ge 1 ] && [ "$a" -le 1000 ] && [ "$n" -ge 1 ] && [ "$n" -le `4194304` ] || 14 { echo 'need 1 <= A <= 1000 and 1 <= N <= `4194304` (keeps the awk reference exact)' >&2; exit 2; } 15 if [ "$(uname -s) $(uname -m)" != "Linux aarch64" ]; then 16 echo "NOT_RUN: the pinned omc is a Linux aarch64 program and this is $(uname -s) $(uname -m)." 17 echo 'The same kernel runs in your browser at https://www.aienos.com/lab/' 18 exit 0 19 fi 20 omc=../hive-page/omc 21 irwasm=../hive-page/irwasm 22 for f in omc irwasm; do 23 want=$(tr -d ' \n' < "../hive-page/$f.sha256") 24 got=$(sha256sum "../hive-page/$f" | cut -d' ' -f1) 25 [ "$got" = "$want" ] || { echo "$f sha256 $got is not the pin $want" >&2; exit 3; } 26 echo "pin $f sha256 $got" 27 done 28 mkdir -p out 29 cat axpy.om harness.om > out/prog.om 30 s=$(date +%s%N); "$omc" < out/prog.om > out/axpy; e=$(date +%s%N) 31 chmod +x out/axpy 32 echo "build omc: axpy.om + harness.om -> out/axpy in $(( (e - s) / 1000 )) us" 33 s=$(date +%s%N); got=$(echo "$a $n" | ./out/axpy); e=$(date +%s%N) 34 echo "run out/axpy a=$a n=$n -> $got in $(( (e - s) / 1000 )) us (whole process)" 35 ref=$(awk -v a="$a" -v n="$n" 'BEGIN{s=0;for(i=0;i&2; exit 1; } 38 sed 's/^ret add mul a x y$/ret sub mul a x y/' out/prog.om > out/mutant.om 39 "$omc" < out/mutant.om > out/mutant; chmod +x out/mutant 40 bad=$(echo "$a $n" | ./out/mutant || true) 41 [ "$bad" != "$ref" ] || { echo 'FAIL: the mutant (add -> sub) also matched, so the check proves nothing' >&2; exit 1; } 42 echo "control add -> sub gives $bad: mismatch, so the check can fail" 43 { printf 'ir\n'; cat axpy.om; } | "$omc" > out/axpy.ir 44 "$irwasm" < out/axpy.ir > out/axpy.wasm 45 echo "wasm out/axpy.wasm $(wc -c < out/axpy.wasm) bytes, sha256 $(sha256sum out/axpy.wasm | cut -d' ' -f1)" 46 echo 'PASS'