boot2

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

commit f3aa6d050718c9abf3080ed7d08c6a301b121229
parent 0860de4c2197b1bb58350d0cde82491703ce542b
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sun,  3 May 2026 16:28:56 -0700

build: M1pp/hex2pp from .c via alpine-gcc; pass -B 0x600000

Until the self-hosted .P1 expander/assembler (M1pp.P1, hex2pp.P1)
catch up to the new bare-string-emits-bytes contract and the wide-imm
backend changes, the test pipeline uses the .c reference
implementations. New per-arch alpine-gcc image rule compiles
M1pp/M1pp.c and hex2pp/hex2pp.c statically into the same
build/$ARCH/{M1pp,hex2pp}/ slots the test runner already invokes; the
old per-tool tcc-gcc-only image rule is removed (the generic one
covers it).

scripts/boot-build-p1pp.sh: pass `-B 0x600000` to hex2pp so the linked
ELF's vaddr matches the seed ELF.hex2 framing (the old seed hex2
defaulted to 0x600000; hex2pp.c/.P1 default to 0).

Makefile dependency lists for the per-arch toolchain and the test
suites switch the dangling `P1/elf-$(a).hex2pp` references to
`vendor/seed/$(a)/ELF.hex2`, which is what boot-build-p1pp.sh
already cats in front of the expanded output.

Diffstat:
MMakefile | 45++++++++++++++++++++++++++++-----------------
Mscripts/boot-build-p1pp.sh | 24+++++++++++++++---------
2 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile @@ -107,7 +107,7 @@ CLOC_FILES := \ $(foreach a,$(CLOC_ARCHES),P1/P1-$(a).M1) \ M1pp/M1pp.P1 \ hex2pp/hex2pp.P1 \ - $(foreach a,$(CLOC_ARCHES),P1/elf-$(a).hex2pp) \ + $(foreach a,$(CLOC_ARCHES),vendor/seed/$(a)/ELF.hex2) \ $(foreach a,$(CLOC_ARCHES),P1/P1-$(a).M1pp) \ P1/P1.M1pp \ P1/P1pp.P1pp \ @@ -207,16 +207,34 @@ P1_BUILD_DEPS = scripts/lint.sh scripts/boot-build-p1.sh \ P1PP_BUILD_DEPS = scripts/boot-build-p1pp.sh \ build/%/.image \ build/%/M1pp/M1pp build/%/hex2pp/hex2pp \ - P1/elf-%.hex2pp \ + vendor/seed/%/ELF.hex2 \ P1/P1-%.M1pp P1/P1.M1pp P1/P1pp.P1pp -$(M1PP_BINS): build/%/M1pp/M1pp: M1pp/M1pp.P1 $(P1_BUILD_DEPS) - ARCH=$* sh scripts/lint.sh M1pp/M1pp.P1 - $(call PODMAN,$*) sh scripts/boot-build-p1.sh M1pp/M1pp.P1 $@ +# Until M1pp.P1 / hex2pp.P1 catch up to the new string-emission contract +# (bare "..." emits decoded bytes; %bytes is gone), the test pipeline +# uses the M1pp.c / hex2pp.c reference implementations compiled inside +# a per-arch alpine-gcc container. +ALPINE_GCC_IMAGES := $(foreach a,$(ALL_ARCHES),build/$(a)/.image-alpine-gcc) -$(HEX2PP_BINS): build/%/hex2pp/hex2pp: hex2pp/hex2pp.P1 $(P1_BUILD_DEPS) - ARCH=$* sh scripts/lint.sh hex2pp/hex2pp.P1 - $(call PODMAN,$*) sh scripts/boot-build-p1.sh hex2pp/hex2pp.P1 $@ +$(ALPINE_GCC_IMAGES): build/%/.image-alpine-gcc: scripts/Containerfile.alpine-gcc + mkdir -p $(@D) + podman build --platform $(PLATFORM_$*) \ + -t boot2-alpine-gcc:$* \ + -f scripts/Containerfile.alpine-gcc scripts/ + @touch $@ + +ALPINE_GCC = podman run --rm --pull=never --platform $(PLATFORM_$(1)) \ + --tmpfs /tmp:size=128M \ + -e ARCH=$(1) \ + -v $(CURDIR):/work -w /work boot2-alpine-gcc:$(1) + +$(M1PP_BINS): build/%/M1pp/M1pp: M1pp/M1pp.c build/%/.image-alpine-gcc + mkdir -p $(@D) + $(call ALPINE_GCC,$*) cc -O2 -std=c99 -static M1pp/M1pp.c -o $@ + +$(HEX2PP_BINS): build/%/hex2pp/hex2pp: hex2pp/hex2pp.c build/%/.image-alpine-gcc + mkdir -p $(@D) + $(call ALPINE_GCC,$*) cc -O2 -std=c99 -static hex2pp/hex2pp.c -o $@ $(SCHEME1_BINS): build/%/scheme1/scheme1: $(SCHEME1_SRC) $(P1PP_BUILD_DEPS) $(call PODMAN,$*) sh scripts/boot-build-p1pp.sh $@ $(SCHEME1_SRC) @@ -328,13 +346,6 @@ TCC_GCC_HARNESS := tcc-gcc/$(TCC_GCC_ARCH)/start.S tcc-gcc/$(TCC_GCC_ARCH)/sys_s tcc-gcc: $(TCC_GCC_BIN) -$(TCC_GCC_IMAGE): scripts/Containerfile.alpine-gcc - mkdir -p $(@D) - podman build --platform $(TCC_GCC_PLATFORM) \ - -t boot2-alpine-gcc:$(TCC_GCC_ARCH) \ - -f scripts/Containerfile.alpine-gcc scripts/ - @touch $@ - $(TCC_GCC_BIN): $(TCC_FLAT) build/$(TCC_GCC_ARCH)/vendor/mes-libc/libc.flat.c \ $(TCC_GCC_HARNESS) scripts/build-tcc-gcc.sh $(TCC_GCC_IMAGE) mkdir -p $(@D) @@ -417,7 +428,7 @@ endif # text-diff against .expected). TEST_M1PP_DEPS := $(foreach a,$(TEST_ARCHES), \ build/$(a)/.image build/$(a)/M1pp/M1pp build/$(a)/hex2pp/hex2pp \ - P1/elf-$(a).hex2pp) + vendor/seed/$(a)/ELF.hex2) # p1 suite per-arch deps: image, table, expander, hex2pp, ELF header. # Raw .P1 fixtures still go through the seed M0+hex2 chain (boot-build-p1.sh) @@ -425,7 +436,7 @@ TEST_M1PP_DEPS := $(foreach a,$(TEST_ARCHES), \ # the new M1pp + hex2pp chain via boot-build-p1pp.sh. TEST_P1_DEPS := $(foreach a,$(TEST_ARCHES), \ build/$(a)/.image build/$(a)/tools/M0 P1/P1-$(a).M1 \ - build/$(a)/M1pp/M1pp build/$(a)/hex2pp/hex2pp P1/elf-$(a).hex2pp) + build/$(a)/M1pp/M1pp build/$(a)/hex2pp/hex2pp vendor/seed/$(a)/ELF.hex2) # scheme1 suite per-arch deps: image, expander, hex2pp, scheme1 binary. # (run-tests.sh runs the pre-built binary against each .scm fixture; it diff --git a/scripts/boot-build-p1pp.sh b/scripts/boot-build-p1pp.sh @@ -8,15 +8,16 @@ ## seed M0+hex2 chain (boot-build-p1.sh); after that point the seed ## tools no longer participate in any user/test pipeline. ## -## Pipeline (new chain — no M0/hex2/catm anywhere): +## Pipeline (new chain — no M0/hex2 anywhere): ## cat <P1-$ARCH.M1pp> <P1.M1pp> <P1pp.P1pp> <srcs...> -> /tmp/combined.M1pp ## M1pp /tmp/combined.M1pp -> /tmp/expanded.hex2pp -## hex2pp -f $ELF_HDR -f /tmp/expanded.hex2pp -o $OUT +## cat $ELF_HDR /tmp/expanded.hex2pp -> /tmp/linked.hex2pp +## hex2pp /tmp/linked.hex2pp $OUT ## -## $ELF_HDR is P1/elf-$ARCH.hex2pp — a hex2pp-syntax ELF header that -## supplies :ELF_base / :_start / :ELF_end framing, replacing the old -## vendor/seed/$ARCH/ELF.hex2 (which uses hex2 `>` arithmetic and -## trailing-zero placeholders incompatible with hex2pp). +## $ELF_HDR is vendor/seed/$ARCH/ELF.hex2, which supplies the +## :ELF_base / :_start / :ELF_end framing. hex2pp accepts the hex2 +## `LABEL>OTHER` subtraction syntax as a synonym for its own +## `LABEL-OTHER`, so the vendor headers assemble unchanged. ## ## libp1pp (P1/P1pp.P1pp) is concatenated unconditionally so portable ## sources can use %fn, the control-flow macros, and libp1pp routines @@ -85,7 +86,7 @@ shift BACKEND=P1/P1-$ARCH.M1pp FRONTEND=P1/P1.M1pp LIBP1PP=P1/P1pp.P1pp -ELF_HDR=P1/elf-$ARCH.hex2pp +ELF_HDR=vendor/seed/$ARCH/ELF.hex2 M1PP_BIN=build/$ARCH/M1pp/M1pp HEX2PP_BIN=build/$ARCH/hex2pp/hex2pp if [ -n "${WORK_SUBPATH:-}" ]; then @@ -110,8 +111,13 @@ step "M1pp: combined.M1pp -> expanded.hex2pp" cp /tmp/expanded.hex2pp "$WORK/expanded.hex2pp" trace "expanded.hex2pp" /tmp/expanded.hex2pp -step "hex2pp: ELF header + expanded.hex2pp -> $OUT" -"$HEX2PP_BIN" -f "$ELF_HDR" -f /tmp/expanded.hex2pp -o /tmp/prog.bin +step "cat: linked.hex2pp <- ELF header + expanded.hex2pp" +cat "$ELF_HDR" /tmp/expanded.hex2pp > /tmp/linked.hex2pp +cp /tmp/linked.hex2pp "$WORK/linked.hex2pp" +trace "linked.hex2pp" /tmp/linked.hex2pp + +step "hex2pp: linked.hex2pp -> $OUT" +"$HEX2PP_BIN" -B 0x600000 /tmp/linked.hex2pp /tmp/prog.bin cp /tmp/prog.bin "$OUT" chmod 0700 "$OUT" trace "$OUT" "$OUT"