kit

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

commit d1e302e28a2ae299d6e5beeec54d80ee0ec6087b
parent cb2b07f44e58d147ac6486faa6cb68d62c5e6642
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Tue,  9 Jun 2026 11:02:59 -0700

test/toy: run thread-local cases hosted on lane L instead of skipping

Thread-local storage fundamentally needs a hosted TLS runtime: on Mach-O
each _Thread_local access calls a TLV resolver thunk (_tlv_bootstrap,
supplied by libSystem/dyld); on ELF the static-TLS block + thread
pointer are set up by the libc crt. Bare `kit ld` links no libc/crt, so
141/142 were skipped on lane L (.link.skip) — but that path isn't where
TLS is meant to work; the hosted link does, and was verified passing.

Add a per-case <name>.link.hosted directive: when present, lane L links
the case via the hosted path (kit cc -lc) regardless of the platform
default (TOY_L_HOSTED), rather than bare `kit ld`. Replace the 141/142
.link.skip sidecars with .link.hosted. Both now pass on every lane
(R/I/L/C/W, O0+O1); full toy suite 1394 pass / 0 fail / 33 skip.

Diffstat:
Atest/toy/cases/141_threadlocal_mutate.link.hosted | 1+
Dtest/toy/cases/141_threadlocal_mutate.link.skip | 2--
Atest/toy/cases/142_threadlocal_multi.link.hosted | 1+
Dtest/toy/cases/142_threadlocal_multi.link.skip | 2--
Mtest/toy/run.sh | 14+++++++++++++-
5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/test/toy/cases/141_threadlocal_mutate.link.hosted b/test/toy/cases/141_threadlocal_mutate.link.hosted @@ -0,0 +1 @@ +thread-local needs the hosted TLV/TLS runtime (Mach-O _tlv_bootstrap via libSystem; ELF static-TLS via the libc crt); link hosted rather than via bare `kit ld`. R/I/C/W cover the semantics too. diff --git a/test/toy/cases/141_threadlocal_mutate.link.skip b/test/toy/cases/141_threadlocal_mutate.link.skip @@ -1 +0,0 @@ -defining a _Thread_local and linking it into a standalone executable needs PIE/crt TLS setup (see PIE start.c limitation); R/I/C/W cover the semantics -\ No newline at end of file diff --git a/test/toy/cases/142_threadlocal_multi.link.hosted b/test/toy/cases/142_threadlocal_multi.link.hosted @@ -0,0 +1 @@ +thread-local needs the hosted TLV/TLS runtime (Mach-O _tlv_bootstrap via libSystem; ELF static-TLS via the libc crt); link hosted rather than via bare `kit ld`. R/I/C/W cover the semantics too. diff --git a/test/toy/cases/142_threadlocal_multi.link.skip b/test/toy/cases/142_threadlocal_multi.link.skip @@ -1 +0,0 @@ -defining a _Thread_local and linking it into a standalone executable needs PIE/crt TLS setup (see PIE start.c limitation); R/I/C/W cover the semantics -\ No newline at end of file diff --git a/test/toy/run.sh b/test/toy/run.sh @@ -32,6 +32,8 @@ # <name>.cbackend.skip opts the case out of path C (with reason) # <name>.wasm.skip opts the case out of path W (with reason) # <name>.link.skip opts the case out of path L (with reason) +# <name>.link.hosted forces path L to link hosted (kit cc -lc) for this +# case regardless of platform default (with reason) # err/<name>.expected expected diagnostic substring for compile-fail cases # err/<name>.ccargs extra `kit cc -c` flags for that err case (e.g. a # -target triple for a target-specific diagnostic) @@ -157,6 +159,7 @@ kit_lane_L() { dump_exp="${KIT_SRC%.toy}.objdump.elf" fi local link_skip="${KIT_SRC%.toy}.link.skip" + local link_hosted="${KIT_SRC%.toy}.link.hosted" local pattern missing if [ -e "$link_skip" ]; then @@ -164,6 +167,15 @@ kit_lane_L() { return fi + # A <name>.link.hosted sidecar forces this case through the hosted link + # (kit cc -lc) regardless of the platform default. Used for cases that need + # the libc/dyld runtime to link at all (e.g. thread-locals, whose Mach-O TLV + # / ELF static-TLS setup is supplied by the hosted crt, not bare `kit ld`). + local case_hosted="$TOY_L_HOSTED" + if [ -e "$link_hosted" ]; then + case_hosted=1 + fi + if ! "$KIT" cc "-O$KIT_OPT" -c "$KIT_SRC" -o "$obj" \ > "$KIT_WORK/cc.out" 2> "$cc_err"; then kit_fail "$label" "kit cc -O$KIT_OPT -c failed" @@ -201,7 +213,7 @@ kit_lane_L() { fi fi - if [ "$TOY_L_HOSTED" = "1" ]; then + if [ "$case_hosted" = "1" ]; then if ! "$KIT" cc "$obj" -lc -o "$exe" > "$KIT_WORK/ld.out" 2> "$ld_err"; then kit_fail "$label" "kit cc -lc link failed" sed 's/^/ | /' "$ld_err"