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");