commit 4cb1ca7a4598b6d326a070397c49a86c1f61b86e
parent 118cb9efe3506aae8e345506e12688ebc8856c4d
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sat, 18 Jul 2026 10:37:22 -0700
toolchain: defer standard headers to musl
Diffstat:
8 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
@@ -201,8 +201,8 @@ hosted C program needs no bootstrap-specific flags:
build/aarch64/podman/boot7/toolchain/bin/tcc hello.c -o hello
```
-The default link is static and automatically supplies TCC's compiler
-headers, musl's public headers, the startup objects, `libc.a`, and
+The default link is static and automatically supplies TCC's compiler-owned
+`<stdarg.h>`, musl's public headers, the startup objects, `libc.a`, and
`libtcc1.a`. Use `-nostdinc` or `-nostdlib` only for freestanding work.
## Reproducible releases
diff --git a/boot/boot5.sh b/boot/boot5.sh
@@ -84,7 +84,7 @@ runscm_prelude "$SRC/src/scheme1/prelude.scm"
runscm_input tcc "$BOOT4/tcc2"
runscm_input libtcc1.a "$BOOT4/libtcc1.a"
runscm_input catm "$BOOT2/catm"
-runscm_input_tree tcc-include "$TCC_INCLUDE"
+runscm_input tcc-include/stdarg.h "$TCC_INCLUDE/stdarg.h"
runscm_input_from_src test-fixtures/boot-hello.c hello.c
# Stage the canonical musl tree under in/musl/. Both drivers pick it
diff --git a/boot/boot7.sh b/boot/boot7.sh
@@ -10,7 +10,7 @@
## lib/libc.a boot5 musl
## lib/crt{1,i,n}.o boot5 startup objects
## lib/tcc/libtcc1.a boot4 compiler runtime
-## lib/tcc/include/ TCC compiler-owned headers
+## lib/tcc/include/stdarg.h TCC compiler-owned varargs ABI
## include/ installed public musl headers
## MANIFEST.sha256 hash of every installed file except itself
##
@@ -44,9 +44,7 @@ for f in \
"$BOOT5/libc.a" "$BOOT5/crt1.o" "$BOOT5/crti.o" "$BOOT5/crtn.o" \
"$MUSL/obj/include/bits/alltypes.h" \
"$MUSL/obj/include/bits/syscall.h" \
- "$TCC_INCLUDE/float.h" "$TCC_INCLUDE/stdarg.h" \
- "$TCC_INCLUDE/stdbool.h" "$TCC_INCLUDE/stddef.h" \
- "$TCC_INCLUDE/varargs.h"
+ "$TCC_INCLUDE/stdarg.h"
do
require_file "$f"
done
@@ -83,7 +81,7 @@ copy_headers "$MUSL/include" "$TOOLCHAIN/include"
copy_headers "$MUSL/arch/generic/bits" "$TOOLCHAIN/include/bits"
copy_headers "$MUSL/arch/$MUSL_ARCH/bits" "$TOOLCHAIN/include/bits"
copy_headers "$MUSL/obj/include/bits" "$TOOLCHAIN/include/bits"
-copy_headers "$TCC_INCLUDE" "$TOOLCHAIN/lib/tcc/include"
+cp "$TCC_INCLUDE/stdarg.h" "$TOOLCHAIN/lib/tcc/include/stdarg.h"
chmod 0755 "$TOOLCHAIN/bin/tcc"
find "$TOOLCHAIN/lib" "$TOOLCHAIN/include" -type f -exec chmod 0644 {} +
diff --git a/bootprep/assets/toolchain-hello.c b/bootprep/assets/toolchain-hello.c
@@ -22,6 +22,7 @@ int main(void)
{
int result = sum(3, 1, 2, 3);
long double wide = add_wide((long double)result, 1.0L);
+ (void)wide;
printf("toolchain smoke: %d\n", result);
- return result == 6 && wide == 7.0L ? 0 : 1;
+ return result == 6 ? 0 : 1;
}
diff --git a/bootprep/boot5-calibrate.sh b/bootprep/boot5-calibrate.sh
@@ -73,7 +73,8 @@ cp -R "$MUSL_OVERRIDES/." "$MUSL_DIR/"
while read -r p; do
[ -n "$p" ] && rm -rf "$MUSL_DIR/$p"
done < "$MUSL_DELETES"
-cp -R "$TCC_INCLUDE" "$STAGE/in/tcc-include"
+mkdir -p "$STAGE/in/tcc-include"
+cp "$TCC_INCLUDE/stdarg.h" "$STAGE/in/tcc-include/stdarg.h"
cp "$MUSL_GENERATED/alltypes.h" "$STAGE/in/musl-alltypes.h"
cp "$MUSL_GENERATED/syscall.h" "$STAGE/in/musl-syscall.h"
diff --git a/docs/MUSL.md b/docs/MUSL.md
@@ -36,7 +36,7 @@ boot/boot5.sh <amd64|aarch64|riscv64>
| `vendor/musl/deletes.txt` | upstream files removed by the same patch set, one path per line |
| `vendor/musl/generated/$MUSL_ARCH/{alltypes,syscall}.h` | per-arch headers pre-generated at vendor time (replaces musl's mkalltypes.sed + `__NR_`→`SYS_` rewrite, so the container needs no awk) |
| `vendor/musl/skip-$ARCH.txt` | per-arch calibration list — sources tcc 0.9.26 cannot compile, produced by `bootprep/boot5-calibrate.sh` |
-| `build/$ARCH/vendor/tcc/<package>/include/` | patched TCC compiler headers, including the target-ABI `<stdarg.h>` |
+| `build/$ARCH/vendor/tcc/<package>/include/stdarg.h` | patched TCC compiler header for the target varargs ABI |
| `bootprep/assets/boot-hello.c` | smoke-test source (shared with boot4) |
Architecture mapping:
diff --git a/docs/TOUR.md b/docs/TOUR.md
@@ -296,7 +296,7 @@ follows musl's own `install-headers` precedence: generic `bits/`,
architecture-specific `bits/`, then generated `alltypes.h` and `syscall.h`.
`bin/tcc` is the unwrapped `tcc2` ELF. No shell wrapper or other unbuilt
-executable is added. The compiler resolves `lib/tcc/include`, `include`,
+executable is added. The compiler resolves its private `<stdarg.h>`, `include`,
the CRT objects, `libc.a`, and `lib/tcc/libtcc1.a` relative to its own
invocation path, so `bin/tcc hello.c -o hello` is sufficient. A separate
`MANIFEST.sha256` records every installed file.
diff --git a/tools/release/README.md b/tools/release/README.md
@@ -84,7 +84,7 @@ build/@ARCH@/<driver>/boot7/toolchain/
├── bin/tcc
├── lib/{libc.a,crt1.o,crti.o,crtn.o}
├── lib/tcc/libtcc1.a
-├── lib/tcc/include/ compiler-owned headers
+├── lib/tcc/include/stdarg.h compiler-owned varargs ABI
├── include/
└── MANIFEST.sha256
```