boot2

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

commit ff0fd1204fcb984c90ec5ba308bef63a3d04d76a
parent 5bb6a0ab4ea4e61516278f007bc52516f074d154
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Fri, 24 Apr 2026 10:41:05 -0700

Rename .M1→.P1 and .P1→.P1pp to reflect toolchain level

.P1  — hand-written M1 following P1v2 ABI; consumed by M0 directly
       after the p1_arch.M1 DEFINE table is prepended (no m1pp needed).
.P1pp — P1 source using M1PP macros (%li, %syscall, …); consumed by
        m1pp with P1 backend prepended, then M0.

m1pp/m1pp.M1  → m1pp/m1pp.P1
pokem/pokem.M1 → pokem/pokem.P1
tests/p1/*.P1  → tests/p1/*.P1pp

Update build.sh, build-p1.sh, test.sh (m1pp/ and tests/p1/), and
Makefile comment to use the new extensions.

Diffstat:
MMakefile | 4++--
Mm1pp/build-p1.sh | 12++++++------
Mm1pp/build.sh | 17++++++++---------
Rm1pp/m1pp.M1 -> m1pp/m1pp.P1 | 0
Mm1pp/test.sh | 4++--
Rpokem/pokem.M1 -> pokem/pokem.P1 | 0
Rtests/p1/argc_exit.P1 -> tests/p1/argc_exit.P1pp | 0
Rtests/p1/double.P1 -> tests/p1/double.P1pp | 0
Rtests/p1/hello.P1 -> tests/p1/hello.P1pp | 0
Rtests/p1/p1-aliasing.P1 -> tests/p1/p1-aliasing.P1pp | 0
Rtests/p1/p1-call.P1 -> tests/p1/p1-call.P1pp | 0
Mtests/p1/test.sh | 8++++----
12 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile @@ -312,8 +312,8 @@ test-lisp-all: test-m1pp: build/p1v2/aarch64/p1_aarch64.M1 $(TOOLS_DIR)/M0 | $(IMAGE_STAMP) sh m1pp/test.sh -# P1-language fixtures under tests/p1/ run through the M1pp-driven -# pipeline (p1/P1-<arch>.M1pp + p1/P1.M1pp) for every backend arch. +# P1pp fixtures under tests/p1/ run through the M1pp-driven pipeline +# (p1/P1-<arch>.M1pp + p1/P1.M1pp + <name>.P1pp) for every backend arch. # Cross-arch consistency falls out because every arch must match the # same <name>.expected output. test-p1: diff --git a/m1pp/build-p1.sh b/m1pp/build-p1.sh @@ -1,15 +1,15 @@ #!/bin/sh -## build-p1.sh -- build a P1v2 .M1pp source for the M1pp-based P1 pipeline. +## build-p1.sh -- build a P1v2 .P1pp source for the M1pp-based P1 pipeline. ## ## Pipeline: -## 1. catm p1/P1-<arch>.M1pp + p1/P1.M1pp + <source.M1pp> -> combined.M1pp +## 1. catm p1/P1-<arch>.M1pp + p1/P1.M1pp + <source.P1pp> -> combined.M1pp ## 2. m1pp combined.M1pp -> expanded.M1 (macros -> raw hex + labels) ## 3. M1 expanded.M1 -> prog.hex2 (stringify literals, pass hex through) ## 4. catm ELF-<arch>.hex2 + prog.hex2 -> linked.hex2 ## 5. hex2 linked.hex2 -> raw ELF ## 6. chmod + trim to p_filesz, deposit at <output> ## -## Usage: m1pp/build-p1.sh <arch> <source.M1pp> <output> +## Usage: m1pp/build-p1.sh <arch> <source.P1pp> <output> ## arch: aarch64 | riscv64 | amd64 ## ## The m1pp expander itself is architecture-neutral; we run the aarch64 @@ -19,7 +19,7 @@ set -eu if [ "$#" -ne 3 ]; then - echo "usage: $0 <arch> <source.M1pp> <output>" >&2 + echo "usage: $0 <arch> <source.P1pp> <output>" >&2 exit 2 fi @@ -48,7 +48,7 @@ for f in "$BACKEND" "$FRONTEND" "$ELF_HDR" "$SRC"; do done ## Host-compiled m1pp has 64K-token / 512K-text buffers, versus the ~4K / -## 32K cap in the aarch64 self-hosted m1pp.M1. The combined backend + +## 32K cap in the aarch64 self-hosted m1pp.P1. The combined backend + ## frontend + source easily blows past the 4K-token cap, so use native. NATIVE_M1PP=build/native-tools/m1pp NATIVE_M1=build/native-tools/M1 @@ -62,7 +62,7 @@ if [ ! -x "$NATIVE_M1" ] || [ ! -x "$NATIVE_HEX2" ]; then sh m1pp/build-native-tools.sh fi -NAME=$(basename "$SRC" .M1pp) +NAME=$(basename "$SRC" .P1pp) WORK=build/p1v2-m1pp/$ARCH/$NAME.work mkdir -p "$WORK" "$(dirname "$OUT")" diff --git a/m1pp/build.sh b/m1pp/build.sh @@ -1,16 +1,15 @@ #!/bin/sh -## build.sh — build a P1v2 .M1 source into a runnable aarch64 ELF binary. +## build.sh — build a P1v2 .P1 source into a runnable aarch64 ELF binary. ## ## Mirrors the Makefile's PROG=m1m pipeline but targets the P1v2 DEFINE -## table at build/p1v2/aarch64/p1_aarch64.M1. Used during the m1pp -## C-to-M1 port; once m1pp.M1 lands, this same script builds it too. +## table at build/p1v2/aarch64/p1_aarch64.M1. ## -## Usage: m1pp/build.sh <source.M1> <output_binary> +## Usage: m1pp/build.sh <source.P1> <output_binary> ## ## Pipeline (mirrors Makefile PROG=m1m): -## 1. lint — assert every P1v2 op token in source.M1 is defined +## 1. lint — assert every P1v2 op token in source.P1 is defined ## 2. prune — strip DEFINEs the source doesn't reference -## 3. catm — pruned defs ++ source.M1 -> combined.M1 +## 3. catm — pruned defs ++ source.P1 -> combined.M1 ## 4. M1 — combined.M1 -> .hex2 ## 5. catm — ELF header ++ .hex2 -> linked.hex2 ## 6. hex2 — linked.hex2 -> raw ELF @@ -32,7 +31,7 @@ set -eu if [ "$#" -ne 2 ]; then - echo "usage: $0 <source.M1> <output_binary>" >&2 + echo "usage: $0 <source.P1> <output_binary>" >&2 exit 2 fi @@ -63,7 +62,7 @@ for f in "$P1_DEFS" "$ELF_HDR" lint.sh "$SRC"; do fi done -NAME=$(basename "$SRC" .M1) +NAME=$(basename "$SRC" .P1) WORK=build/m1pp/$NAME.work mkdir -p "$WORK" "$(dirname "$OUT")" @@ -80,7 +79,7 @@ awk 'NR==FNR{for(i=1;i<=NF;i++)u[$i]=1;next} /^DEFINE /{if($2 in u)print;next} { ## Steps 3-7: mode selection. if [ "${M1PP_BOOTSTRAP_TOOLS:-0}" = 1 ]; then ## Bootstrap mode: run stage0 M0/hex2-0 inside the container. Slow - ## (~110s on 1 MB m1pp.M1) but exercises the same code path the + ## (~110s on 1 MB m1pp.P1) but exercises the same code path the ## seed/tcc-boot chain does. Stage through /tmp to dodge virtiofs. for f in "$TOOLS/M0" "$TOOLS/hex2-0" "$TOOLS/catm"; do if [ ! -e "$f" ]; then diff --git a/m1pp/m1pp.M1 b/m1pp/m1pp.P1 diff --git a/m1pp/test.sh b/m1pp/test.sh @@ -8,7 +8,7 @@ ## <name>.expected. ## ## <name>.M1pp — input for the m1pp expander (parity test). -## Runner builds m1pp/m1pp.M1 once, runs the resulting +## Runner builds m1pp/m1pp.P1 once, runs the resulting ## binary as `m1pp <name>.M1pp <tmp>/out`, and diffs ## that output file against <name>.expected. ## @@ -30,7 +30,7 @@ IMAGE=localhost/distroless-busybox:latest cd "$REPO" EXPANDER_BIN=build/m1pp/m1pp -EXPANDER_SRC=m1pp/m1pp.M1 +EXPANDER_SRC=m1pp/m1pp.P1 EXPANDER_DEFS=build/p1v2/aarch64/p1_aarch64.M1 EXPANDER_BUILT=0 diff --git a/pokem/pokem.M1 b/pokem/pokem.P1 diff --git a/tests/p1/argc_exit.P1 b/tests/p1/argc_exit.P1pp diff --git a/tests/p1/double.P1 b/tests/p1/double.P1pp diff --git a/tests/p1/hello.P1 b/tests/p1/hello.P1pp diff --git a/tests/p1/p1-aliasing.P1 b/tests/p1/p1-aliasing.P1pp diff --git a/tests/p1/p1-call.P1 b/tests/p1/p1-call.P1pp diff --git a/tests/p1/test.sh b/tests/p1/test.sh @@ -1,7 +1,7 @@ #!/bin/sh ## tests/p1/test.sh -- run the P1-language test suite. ## -## A P1 fixture is `<name>.P1`. For each fixture with a `<name>.expected` +## A P1 fixture is `<name>.P1pp`. For each fixture with a `<name>.expected` ## sibling, the runner builds the program for every backend arch via ## m1pp/build-p1.sh (which handles m1pp expansion, M1 stringification, and ## hex2 linking against the per-arch ELF header), runs it under the @@ -49,7 +49,7 @@ done if [ -z "$NAMES" ]; then NAMES=$(ls tests/p1/ 2>/dev/null \ - | sed -n 's/^\([^_][^.]*\)\.P1$/\1/p' \ + | sed -n 's/^\([^_][^.]*\)\.P1pp$/\1/p' \ | sort -u) fi @@ -61,11 +61,11 @@ fi pass=0 fail=0 for name in $NAMES; do - fixture=tests/p1/$name.P1 + fixture=tests/p1/$name.P1pp expected=tests/p1/$name.expected if [ ! -e "$fixture" ]; then - echo " SKIP $name (no .P1)" + echo " SKIP $name (no .P1pp)" continue fi if [ ! -e "$expected" ]; then