boot2

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

prep-musl.sh (2563B)


      1 #!/bin/sh
      2 ## prep-musl.sh — A0b: apply the per-arch musl skip filter on top of
      3 ## build/<arch>/src/src/musl/.
      4 ##
      5 ## prep-src.sh (A0a) leaves the musl tree at build/<arch>/src/src/musl/
      6 ## with overrides merged, deletes applied, and pre-generated alltypes.h
      7 ## / syscall.h dropped in. boot5-calibrate.sh's per-arch skip list (the
      8 ## set of musl translation units tcc 0.9.26 cannot compile) needs a
      9 ## working tcc3, so it can't be folded into A0a.
     10 ##
     11 ## A0b is a single transform: read the skip list (committed or freshly
     12 ## calibrated), copy it into the canonical tree as skip.txt, and remove
     13 ## every listed path from src/musl/. After A0b the tree is the exact
     14 ## set of files boot5 will compile — no skip enumeration at boot time.
     15 ##
     16 ## Skip-list source policy:
     17 ##   - if vendor/upstream/musl-1.2.5-skip-<arch>.txt exists, use it
     18 ##     verbatim (the common case — calibrations are committed).
     19 ##   - else run scripts/boot5-calibrate.sh <arch>, which itself depends
     20 ##     on boot4/tcc3. The script writes the committed file for us.
     21 ##
     22 ## Usage: scripts/prep-musl.sh <arch>
     23 ##   <arch> ∈ {aarch64, amd64, riscv64}
     24 
     25 set -eu
     26 
     27 . scripts/lib-arch.sh
     28 bootlib_init prep-musl "${1:-}"
     29 
     30 DST=$ROOT/build/$ARCH/src
     31 DST_MUSL=$DST/src/musl
     32 SKIP_COMMITTED=vendor/upstream/musl-1.2.5-skip-$ARCH.txt
     33 
     34 TAG="[$BOOT_TAG]"
     35 
     36 [ -d "$DST_MUSL" ] || {
     37     echo "$TAG missing $DST_MUSL — run scripts/prep-src.sh $ARCH first" >&2
     38     exit 1
     39 }
     40 
     41 # ── (1) materialize the skip list ─────────────────────────────────────
     42 if [ ! -e "$SKIP_COMMITTED" ]; then
     43     echo "$TAG no committed skip list at $SKIP_COMMITTED — calibrating"
     44     scripts/boot5-calibrate.sh "$ARCH"
     45     [ -e "$SKIP_COMMITTED" ] || {
     46         echo "$TAG calibration did not produce $SKIP_COMMITTED" >&2
     47         exit 1
     48     }
     49 fi
     50 cp "$SKIP_COMMITTED" "$DST_MUSL/skip.txt"
     51 
     52 # ── (2) apply filter — drop every listed path from src/musl/ ──────────
     53 n_skip=0
     54 n_missing=0
     55 while read -r rel; do
     56     [ -n "$rel" ] || continue
     57     case "$rel" in
     58         \#*) continue ;;
     59     esac
     60     if [ -e "$DST_MUSL/$rel" ]; then
     61         rm -rf "$DST_MUSL/$rel"
     62         n_skip=$((n_skip + 1))
     63     else
     64         n_missing=$((n_missing + 1))
     65     fi
     66 done < "$DST_MUSL/skip.txt"
     67 
     68 if [ "$n_missing" -gt 0 ]; then
     69     echo "$TAG WARN: $n_missing skip-list entries were not present in $DST_MUSL" >&2
     70 fi
     71 
     72 n_remaining=$(find "$DST_MUSL" -type f | wc -l | tr -d ' ')
     73 echo "$TAG OK  filtered=$n_skip  remaining=$n_remaining files in $DST_MUSL"