boot.sh (3644B)
1 #!/bin/sh 2 ## boot.sh — drive boot0 → boot6 end-to-end under one driver. 3 ## 4 ## Usage: scripts/boot.sh <arch> 5 ## DRIVER=seed scripts/boot.sh <amd64|aarch64|riscv64> 6 ## DRIVER=podman scripts/boot.sh <amd64|aarch64|riscv64> 7 ## 8 ## DRIVER (default podman) is exported and consumed by each bootN.sh. 9 ## Outputs land at build/$ARCH/$DRIVER/bootN/, so the two driver trees 10 ## coexist on disk. DRIVER=seed runs the build pipeline on top of the 11 ## podman-built boot6 kernel at build/$ARCH/podman/boot6/{Image,kernel.elf}; 12 ## first-time setup therefore requires one prior podman pass: 13 ## ./scripts/boot.sh <arch> # default DRIVER=podman 14 ## DRIVER=seed ./scripts/boot.sh <arch> # re-run on tcc-built kernel 15 ## Subsequent DRIVER=seed runs reuse the Image directly — no stashing. 16 17 set -eu 18 19 case "${1:-}" in 20 -h|--help) 21 cat <<'EOF' 22 boot.sh — drive boot0 → boot6 end-to-end under one driver. 23 24 Usage: 25 scripts/boot.sh <aarch64|amd64|riscv64> 26 27 Environment variables (all optional): 28 DRIVER podman (default) | seed. 29 podman: containerised builds. 30 seed: builds run inside the tcc-built 31 seed kernel under qemu (requires 32 one prior DRIVER=podman pass to 33 mint build/$ARCH/podman/boot6/). 34 BOOT3_TIMEOUT (default 1800) boot3 (scheme1) wall-clock seconds. 35 BOOT4_TIMEOUT (default 5400) boot4 (tcc1/2/3) wall-clock seconds. 36 BOOT5_TIMEOUT (default 7200) boot5 (musl) wall-clock seconds. 37 BOOT6_TIMEOUT (default 1200) boot6 (kernel) wall-clock seconds. 38 QEMU_MEM (default 3072M) guest RAM passed to the seed-driver qemu. 39 TCC_BOOTSTRAP_RELAX_FIXEDPOINT set to 1 in boot4 to accept tcc2 != tcc3. 40 After a codegen-altering tcc patch the 41 two-stage rule needs a third bounce to 42 converge; the next boot4 run, started 43 from this run's tcc3, will reach 44 tcc2 == tcc3 with no extra knob. 45 EOF 46 exit 0 47 ;; 48 esac 49 50 . scripts/lib-arch.sh 51 bootlib_init boot "${1:-}" 52 53 if [ "$DRIVER" = seed ]; then 54 KERNEL=build/$ARCH/podman/boot6/$KERNEL_NAME 55 if [ ! -f "$KERNEL" ]; then 56 echo "[$BOOT_TAG] missing $KERNEL" >&2 57 echo "[$BOOT_TAG] run './scripts/boot.sh $ARCH' first (default DRIVER=podman) to produce it" >&2 58 exit 1 59 fi 60 fi 61 62 # Wipe only this driver's tree so the other driver's outputs survive 63 # (the seed driver consumes build/$ARCH/podman/boot6/$KERNEL_NAME). 64 rm -rf build/$ARCH/$DRIVER 65 66 # Per-stage timing comes from each child's own bootlib EXIT trap 67 # (`[bootN/$DRIVER/$ARCH] done in Xs (cum Ys)`); this orchestrator only 68 # adds its own total at the end (also via the lib trap). 69 70 # A0a: build the canonical generated source tree at build/$ARCH/src/. 71 # Boot stages read source from there exclusively (no flatten/unpack/ 72 # patch inside boot{N}.sh). 73 ./scripts/prep-src.sh $ARCH 74 75 ./scripts/boot0.sh $ARCH 76 ./scripts/boot1.sh $ARCH 77 ./scripts/boot2.sh $ARCH 78 ./scripts/boot3.sh $ARCH 79 ./scripts/boot4.sh $ARCH 80 81 # A0b: apply the per-arch musl skip filter (needs tcc3 from boot4 if 82 # the calibration list is missing; the committed list is the common 83 # case and runs without compiler). 84 ./scripts/prep-musl.sh $ARCH 85 86 ./scripts/boot5.sh $ARCH 87 88 # boot6 builds the seed-kernel ELF/Image with boot4's tcc3 (no `ld -T`, 89 # no objcopy). 90 ./scripts/boot6.sh $ARCH