commit 2f5440482e5461d1cd1c316a54274a5d41f964b9
parent c1d79e86efb0844b9fac75978738700a21f1fd50
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Mon, 1 Jun 2026 17:14:39 -0700
test: build each arch's linux rt archive for test-rt-runtime
Hoist the _TEST_RT_<arch> map (was scoped near the parse/asm/macho deps) and
make test-rt-runtime depend on the linux rt variant of every swept arch rather
than the host 'rt' target. A stale per-arch archive otherwise silently breaks
the link -- e.g. a dropped __cfree_assert_fail weak def surfaces only as an
undefined reference.
Diffstat:
| M | test/test.mk | | | 46 | +++++++++++++++++++++++++++++----------------- |
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/test/test.mk b/test/test.mk
@@ -454,7 +454,32 @@ test-rt-headers: bin
$(BIN) cc -target "$$target" -Werror -c test/rt/smoke.c -o "$$out"; \
done
-test-rt-runtime: bin rt $(LINK_EXE_RUNNER)
+# Arch token -> linux rt variant target. The cross-target test harnesses link
+# the matching LINUX runtime archive (compiler-rt-style helpers like
+# __cfree_sext64ti, __cfree_assert_fail) rather than the native `rt` target,
+# which builds only the host's own variant. Shared by the single-arch
+# parse/asm/macho/link tests (via CFREE_TEST_ARCH/TEST_RT_DEP) and by
+# test-rt-runtime, which sweeps several arches at once.
+CFREE_TEST_ARCH ?= aa64
+_TEST_RT_aa64 = rt-aarch64-linux
+_TEST_RT_aarch64 = rt-aarch64-linux
+_TEST_RT_arm64 = rt-aarch64-linux
+_TEST_RT_x64 = rt-x86_64-linux
+_TEST_RT_x86_64 = rt-x86_64-linux
+_TEST_RT_amd64 = rt-x86_64-linux
+_TEST_RT_rv64 = rt-riscv64-linux
+_TEST_RT_riscv64 = rt-riscv64-linux
+TEST_RT_DEP = $(_TEST_RT_$(CFREE_TEST_ARCH))
+
+# test-rt-runtime compiles each case for the configured arches and links it
+# against that arch's LINUX runtime archive, so it must depend on each variant
+# (not the host `rt`). A stale per-arch archive otherwise silently breaks the
+# link — e.g. a dropped __cfree_assert_fail weak def surfaces as an undefined
+# reference. CFREE_RT_RUNTIME_ARCHES mirrors the default in test/rt/run.sh.
+CFREE_RT_RUNTIME_ARCHES ?= aa64 x64 rv64
+RT_RUNTIME_DEPS := $(foreach a,$(CFREE_RT_RUNTIME_ARCHES),$(_TEST_RT_$(a)))
+
+test-rt-runtime: bin $(RT_RUNTIME_DEPS) $(LINK_EXE_RUNNER)
@bash test/rt/run.sh
# Test harness binaries shared by test-elf and test-link.
@@ -572,22 +597,9 @@ test-coff-mingw-import: lib $(COFF_IMPORT_MINGW_BIN)
test-coff-windows-ucrt: bin rt-aarch64-windows
bash test/coff/windows-ucrt-hosted-smoke.sh
-# The parse/asm/macho harnesses select a cross-target via CFREE_TEST_ARCH (default
-# aa64; values aa64/x64/rv64 plus the aliases run.sh accepts). The JIT path (J)
-# links the matching linux rt archive to resolve compiler-rt-style helpers
-# (e.g. __cfree_sext64ti for __int128), so depend on that variant rather than
-# the native `rt` target, which builds only the host's own variant.
-CFREE_TEST_ARCH ?= aa64
-_TEST_RT_aa64 = rt-aarch64-linux
-_TEST_RT_aarch64 = rt-aarch64-linux
-_TEST_RT_arm64 = rt-aarch64-linux
-_TEST_RT_x64 = rt-x86_64-linux
-_TEST_RT_x86_64 = rt-x86_64-linux
-_TEST_RT_amd64 = rt-x86_64-linux
-_TEST_RT_rv64 = rt-riscv64-linux
-_TEST_RT_riscv64 = rt-riscv64-linux
-TEST_RT_DEP = $(_TEST_RT_$(CFREE_TEST_ARCH))
-
+# The parse/asm/macho harnesses select a cross-target via CFREE_TEST_ARCH
+# (default aa64); the link rt dependency is resolved through the shared
+# _TEST_RT_<arch> map defined above (near test-rt-runtime).
test-link: lib $(ROUNDTRIP_BIN) $(ROUNDTRIP_BIN_MACHO) $(LINK_EXE_RUNNER) $(JIT_RUNNER)
bash test/link/run.sh