boot2

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

commit f831ef7fd9e12863ce06e59378f6e668e7c9cc4b
parent 409eaad8e100c7a8bb5ef0adf6f5ca51ca4570f5
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Thu, 30 Apr 2026 08:42:20 -0700

tcc-cc: rely on libc-flat as the gcc-built sanity reference

- Drop scripts/run-gcc-flat-tcc.sh: with system-musl static linkage it
  surfaces 15 tcc/AArch64 codegen edge cases (struct-ret, anon-union,
  compound-literal) that the libc-flat path papers over via mes-libc.
  Treat 152/0 under run-gcc-libc-flat-tcc.sh as the canonical
  reference instead.
- boot-run-tests.sh tcc-cc: pass -I tcc/include so user fixtures can
  pick up the bundled <stdarg.h> when tcc-boot2 is invoked with
  -nostdlib (mirrors run-gcc-libc-flat-tcc.sh).
- TCC-TODO.md: collapse the two-control narrative; remove the
  no-libc breakdown and the 22-fail line.

Diffstat:
Mdocs/TCC-TODO.md | 65++++++++++++++++-------------------------------------------------
Mscripts/boot-run-tests.sh | 3++-
2 files changed, 18 insertions(+), 50 deletions(-)

diff --git a/docs/TCC-TODO.md b/docs/TCC-TODO.md @@ -130,28 +130,20 @@ files as the main source of the failures. A stronger control is to compile the same ARM64 `tcc.flat.c` with Alpine gcc and use that gcc-built tcc to run the same `tests/cc` -fixtures. That control is not perfectly green, but it is far healthier: +fixtures: ```text -gcc-built ARM64 tcc.flat.c (no libc): 130 passed, 22 failed gcc-built ARM64 tcc.flat.c (libc + tcc hdrs): 152 passed, 0 failed -cc.scm-built ARM64 tcc-boot2: 13 passed, 139 failed +cc.scm-built ARM64 tcc-boot2: 13 passed, 139 failed ``` -So there are three layers of signal: - -- The **libc + tcc-headers** control is fully green. It links the - flattened tcc against `libc.flat.c` + libtcc1 + a tiny mes-libc - string runtime, and passes `-I tcc/include` so the bundled - `<stdarg.h>` resolves under `-nostdlib`. Run with - `scripts/run-gcc-libc-flat-tcc.sh`. This proves the fixtures and - the flattened tcc source are coherent end-to-end. -- The **no-libc** control still has 22 failures. Most are stdarg.h - not on the include path (the script doesn't pass `-I tcc/include`) - and a handful are upstream tcc/AArch64 codegen bugs unrelated to - varargs (struct-ret, compound-literal, typedef-fnptr, etc.). -- The remaining ~117 failures fire only with the `cc.scm`-built tcc. - That is the main evidence that our compiler is miscompiling tcc. +The gcc-built control is fully green: it links the flattened tcc +against `libc.flat.c` + libtcc1 + a tiny mes-libc string runtime, and +passes `-I tcc/include` so the bundled `<stdarg.h>` resolves under +`-nostdlib`. Run with `scripts/run-gcc-libc-flat-tcc.sh`. This proves +the fixtures and the flattened tcc source are coherent end-to-end, so +the remaining 139 failures on the `cc.scm`-built path are evidence +that our compiler is miscompiling tcc. ## Host Baseline @@ -174,48 +166,23 @@ HOST_CFLAGS=-std=gnu11 -w The gcc-built flattened-tcc control runs in the Alpine gcc image: ```sh +make tcc-gcc TCC_TARGET=ARM64 podman run --rm --pull=never --platform linux/arm64 \ -v "$PWD":/work -w /work boot2-alpine-gcc:aarch64 \ - sh build/aarch64/.work/tests/tcc-cc/run-gcc-flat-tcc.sh + sh scripts/run-gcc-libc-flat-tcc.sh ``` Current result: ```text tcc version 0.9.26 (AArch64 Linux) -130 passed, 22 failed -``` - -The libc-flat variant adds `-I tcc/include` and a real libc backing, -and is fully green: - -```sh -make tcc-gcc TCC_TARGET=ARM64 -podman run --rm --pull=never --platform linux/arm64 \ - -v "$PWD":/work -w /work boot2-alpine-gcc:aarch64 \ - sh scripts/run-gcc-libc-flat-tcc.sh -# 152 passed, 0 failed +152 passed, 0 failed ``` -The 22 no-libc failures break down as: - -- Compile/link failures from missing `<stdarg.h>` (the script doesn't - pass `-I tcc/include`): `001-kitchen-sink`, `015-variadic`, - `067-vararg-call`, `076-vararg-recv`, `079-vararg-deep`, - `097-vararg-many-named`, `116-struct-ret-vararg`, `131-vararg-mixed`. -- Compile/link segfaults from upstream tcc/AArch64 codegen gaps: - `032-local-struct-desig`, `084-struct-assign`, `096-fwd-struct`, - `099-init-zero-tail`, `108-typedef-fnptr`, `109-typedef-anon`, - `111-struct-ret-1word`, `112-struct-ret-2word`, `113-struct-ret-3word`, - `114-struct-ret-many-args`, `115-struct-ret-3word-many-args`, - `117-compound-literal`, `125-anon-union`, `129-extern-libp1pp`. - -The 5 prior runtime-exit mismatches (`018-sext-narrow`, `068-main-noret`, -`102-cmpd-narrow`, `119-float-parse`, `128-cast-signedness`) are gone: -the fixtures were cleaned up so they assume neither implicit -`signed char` nor a specific `long double` size. `068-main-noret` was -retired entirely because relying on the implicit return value of -`main` is undefined. +This is the canonical sanity reference for tcc-built-from-our-source. +The fixtures were cleaned up to drop assumptions about implicit +`char` signedness and `long double` size; `068-main-noret` was retired +because relying on the implicit return value of `main` is undefined. `scripts/simple-patches/tcc-0.9.26/` carries two AArch64 vararg fixes applied during stage1-flatten so any tcc rebuilt from this tree picks diff --git a/scripts/boot-run-tests.sh b/scripts/boot-run-tests.sh @@ -516,6 +516,7 @@ run_tcc_cc_suite() { tcc=build/$ARCH/tcc-boot2/tcc-boot2 start=build/$ARCH/tcc-cc/start.o + tcc_include=build/tcc/ARM64/tcc-0.9.26-1147-gee75a10c/include if [ ! -x "$tcc" ]; then echo " FAIL [$ARCH] tcc-cc" echo " missing $tcc -- run 'make test SUITE=tcc-cc ARCH=$ARCH'" >&2 @@ -553,7 +554,7 @@ run_tcc_cc_suite() { mkdir -p "$(dirname "$elf")" "$workdir" tcc_log=$workdir/tcc.log - if ! "$tcc" -nostdlib "$start" "$src" -o "$elf" \ + if ! "$tcc" -nostdlib -I "$tcc_include" "$start" "$src" -o "$elf" \ >"$tcc_log" 2>&1; then fail "$label" "tcc compile/link failed:" "$tcc_log" continue