From 1052aad6c1a1e572a4432adccee8ce174d2a56a7 Mon Sep 17 00:00:00 2001 From: cole Date: Tue, 24 Nov 2026 08:34:03 -0500 Subject: [PATCH] runtime: retain the TLS directory in the /GA test fixture Force the CRT TLS directory into tiny_ga_tls when /GA removes the last _tls_index reference. Reject the unassigned TLS index in the test so missing metadata fails the index check. --- runtime/CMakeLists.txt | 2 ++ runtime/test/loader_tls_test.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 64e346f40a..367f68cc28 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -610,6 +610,8 @@ if(BUILD_TESTING) add_executable(tiny_ga_tls test/fixtures/tiny_ga_tls.cpp) target_compile_definitions(tiny_ga_tls PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) target_compile_options(tiny_ga_tls PRIVATE /W4 /permissive- /utf-8 /GS- /GA) + # /GA can remove the _tls_index reference that pulls in the CRT TLS directory. + target_link_options(tiny_ga_tls PRIVATE /INCLUDE:_tls_used) set_target_properties(tiny_ga_tls PROPERTIES OUTPUT_NAME tiny_ga_tls RUNTIME_OUTPUT_DIRECTORY "${TINY_FIXTURE_DIR}" diff --git a/runtime/test/loader_tls_test.cpp b/runtime/test/loader_tls_test.cpp index 625ff6d861..133b27c819 100644 --- a/runtime/test/loader_tls_test.cpp +++ b/runtime/test/loader_tls_test.cpp @@ -790,7 +790,8 @@ void test_ga_tls_existing_thread(const fs::path& exe) { { rt::Loader loader(exe.parent_path()); rt::Module& m = loader.load(exe); - check(m.tls_index != 0, "the /GA fixture gets a module TLS index other than the process EXE's 0"); + check(m.tls_index != rt::kNoTlsIndex && m.tls_index != 0, + "the /GA fixture gets a valid module TLS index other than the process EXE's 0"); check(m.tls_ga_slot != rt::kNoTlsIndex, "load() rewrites the /GA fixture's index-0 TLS reads"); get = find_export(m, "ga_tls_get"); set = find_export(m, "ga_tls_set");