boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

seed-accept-boot34.sh (3160B)


      1 #!/bin/sh
      2 ## seed-accept-boot34.sh — acceptance: run boot3 (then optionally boot4)
      3 ## under DRIVER=seed and assert byte-identical outputs vs build/aarch64/
      4 ## bootN/'s podman-built artefacts.
      5 ##
      6 ## Prereqs (build first):
      7 ##   - build/aarch64/boot6/Image   (run ./scripts/boot.sh aarch64
      8 ##     under DRIVER=podman to produce the tcc-built seed kernel)
      9 ##   - build/aarch64/boot{0,1,2,3,4}/   (same boot.sh run populates these
     10 ##     references)
     11 ##
     12 ## What it does:
     13 ##   1. Stash existing podman-built build/aarch64/boot{3,4}/ as ref/.
     14 ##   2. DRIVER=seed scripts/boot3.sh aarch64 — one qemu boot, scheme1
     15 ##      drives cc.scm → tcc0 from a generated run.scm.
     16 ##   3. cmp -s tcc0 vs ref tcc0; fail on diff.
     17 ##   4. If $WITH_BOOT4=1, repeat for boot4 (tcc0 → tcc1 → tcc2 → tcc3,
     18 ##      with tcc2 == tcc3 fixed-point asserted).
     19 ##
     20 ## Usage:  scripts/seed-accept-boot34.sh
     21 ##         WITH_BOOT4=1 scripts/seed-accept-boot34.sh
     22 
     23 set -eu
     24 
     25 ARCH=aarch64
     26 ROOT=$(cd "$(dirname "$0")/.." && pwd)
     27 cd "$ROOT"
     28 
     29 KERNEL=build/$ARCH/boot6/Image
     30 [ -f "$KERNEL" ] || { echo "missing $KERNEL — run ./scripts/boot.sh $ARCH (default DRIVER=podman) first" >&2; exit 1; }
     31 [ -x build/$ARCH/boot3/tcc0 ] || { echo "build/$ARCH/boot3/tcc0 missing — run scripts/boot3.sh aarch64" >&2; exit 1; }
     32 
     33 REF=build/$ARCH/.seed-ref
     34 rm -rf "$REF"; mkdir -p "$REF"
     35 cp build/$ARCH/boot3/tcc0 "$REF/tcc0.podman"
     36 
     37 echo "[seed-accept-boot34] boot3: DRIVER=seed scripts/boot3.sh $ARCH"
     38 DRIVER=seed scripts/boot3.sh $ARCH
     39 
     40 if ! cmp -s build/$ARCH/boot3/tcc0 "$REF/tcc0.podman"; then
     41     s_seed=$(wc -c < build/$ARCH/boot3/tcc0)
     42     s_ref=$(wc -c < "$REF/tcc0.podman")
     43     echo "[seed-accept-boot34] boot3 FAIL: tcc0 differs (seed=$s_seed ref=$s_ref)" >&2
     44     exit 3
     45 fi
     46 echo "[seed-accept-boot34] boot3 PASS — tcc0 byte-identical vs podman"
     47 
     48 if [ "${WITH_BOOT4:-0}" != 1 ]; then
     49     exit 0
     50 fi
     51 
     52 [ -x build/$ARCH/boot4/tcc3 ] || { echo "build/$ARCH/boot4/tcc3 missing — run scripts/boot4.sh aarch64 under podman first" >&2; exit 1; }
     53 cp build/$ARCH/boot4/tcc3      "$REF/tcc3.podman"
     54 cp build/$ARCH/boot4/libc.a    "$REF/libc.a.podman"
     55 cp build/$ARCH/boot4/libtcc1.a "$REF/libtcc1.a.podman"
     56 cp build/$ARCH/boot4/crt1.o    "$REF/crt1.o.podman"
     57 cp build/$ARCH/boot4/hello     "$REF/hello.podman"
     58 
     59 echo "[seed-accept-boot34] boot4: DRIVER=seed scripts/boot4.sh $ARCH"
     60 DRIVER=seed scripts/boot4.sh $ARCH
     61 
     62 fail=0
     63 # All boot4 outputs — including the intermediate crt1.o / libc.a /
     64 # libtcc1.a — must match podman byte-for-byte. The strip-file-prefix
     65 # tcc patch (simple-patches/tcc-0.9.26/) drops the /work/in/[tcc-lib/]
     66 # mount prefix from STT_FILE entries, so seed's flat-basename staging
     67 # and podman's /work/in/ mounts produce identical .o relocations.
     68 for f in tcc3 hello crt1.o libc.a libtcc1.a; do
     69     if ! cmp -s build/$ARCH/boot4/$f "$REF/$f.podman"; then
     70         s_seed=$(wc -c < build/$ARCH/boot4/$f)
     71         s_ref=$(wc -c < "$REF/$f.podman")
     72         echo "[seed-accept-boot34] boot4 DIFF $f: seed=$s_seed ref=$s_ref" >&2
     73         fail=1
     74     fi
     75 done
     76 [ $fail -eq 0 ] || exit 4
     77 echo "[seed-accept-boot34] boot4 PASS — tcc3/hello/crt1.o/libc.a/libtcc1.a byte-identical vs podman"