kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit 74c0977fc5d7ae1c26c93b150264c4b617a1f164
parent 4731c9a7ba1ca48dff25c99b8ecd0932e08cc4e3
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Fri, 29 May 2026 14:15:26 -0700

test/driver: assert rt auto-build via linked symbols, not the cache path

cc-auto-builds-and-links-libcfree-rt[-x64] checked for libcfree_rt.a at
<support-dir>/build/rt/<target>/, but commit 607986a moved the rt cache to
DriverEnv's cache_dir, so the archive no longer lands there — the test failed
even though the runtime built and linked correctly (the executable is produced
and its runtime symbols resolve).

Assert the linked image actually defines the needed runtime symbol instead:
__udivti3 for the aarch64 u128-division case, and vsnprintf for the x64 case
(proving printf.c — a libc source, not just compiler-rt — was built and
linked, which is what the old 'ar t | grep printf.c' member check verified).
Location-independent of where the rt archive is cached.

test-driver-cc: 49/49.

Diffstat:
Mtest/driver/run.sh | 19+++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/test/driver/run.sh b/test/driver/run.sh @@ -307,10 +307,15 @@ void _start(void) { for (;;) {} } SRC +# Verify the runtime was auto-built AND linked by checking the linked +# executable actually defines the runtime symbol the source needs +# (__udivti3 for the u128 division). This is location-independent: the rt +# archive is cached under DriverEnv's cache_dir, not the support-dir. if "$CFREE" cc --support-dir "$work/rt-support" -target aarch64-linux \ -e _start "$work/rt-div.c" -o "$work/rt-div" \ > "$work/rt-div.out" 2> "$work/rt-div.err" && - [ -f "$work/rt-support/build/rt/aarch64-linux/libcfree_rt.a" ]; then + "$CFREE" nm "$work/rt-div" 2> "$work/rt-div-nm.err" \ + | grep -qE '[Tt] __udivti3'; then printf 'PASS %s\n' "cc-auto-builds-and-links-libcfree-rt" pass=$((pass + 1)) else @@ -327,21 +332,23 @@ void _start(void) { for (;;) {} } SRC +# freestanding_lib.c uses vsnprintf etc., so a defined `vsnprintf` in the +# linked image proves the runtime's printf.c (a libc source, not just +# compiler-rt) was auto-built and linked — what the old `ar t | grep printf.c` +# member check verified, but location-independent of the rt cache dir. if "$CFREE" cc --support-dir "$work/rt-support" -target x86_64-linux \ -e _start "$repo_root/test/rt/cases/freestanding_lib.c" \ "$work/rt-x64-start.c" \ -o "$work/rt-x64" > "$work/rt-x64.out" 2> "$work/rt-x64.err" && - [ -f "$work/rt-support/build/rt/x86_64-linux/libcfree_rt.a" ] && - "$CFREE" ar t "$work/rt-support/build/rt/x86_64-linux/libcfree_rt.a" \ - > "$work/rt-x64.ar" 2> "$work/rt-x64-ar.err" && - grep -q '^printf\.c$' "$work/rt-x64.ar"; then + "$CFREE" nm "$work/rt-x64" 2> "$work/rt-x64-nm.err" \ + | grep -qE '[Tt] vsnprintf'; then printf 'PASS %s\n' "cc-auto-builds-and-links-libcfree-rt-x64" pass=$((pass + 1)) else printf 'FAIL %s (cfree cc failed)\n' \ "cc-auto-builds-and-links-libcfree-rt-x64" sed 's/^/ | /' "$work/rt-x64.err" - sed 's/^/ | /' "$work/rt-x64-ar.err" 2>/dev/null || true + sed 's/^/ | /' "$work/rt-x64-nm.err" 2>/dev/null || true fail=$((fail + 1)) fi