tests: keep CRT-free EXE templates in static TLS #1112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1119"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:20:34Z.
Refs #1094.
Place both page-spanning initialized arrays in the static PE TLS template with MASM. Disable MSVC's on-demand TLS guards for these CRT-free fixture sources, which have no dynamic TLS initializer. Keep /GA for the slot-zero variants, the original byte patterns, and the differential and negative controls.
On Windows x64 using MSVC 19.51.36244, both Debug and Release linked all five fixture targets. The following test selection passed 4/4 in each preset, including the swapped-callback and zeroed-second-page controls.
MSVC 19.42 still needs independent confirmation on the reporter's host.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:03:01Z.
Review: COMMENTED
Reviewed at
c3a14857be5087490f3180fe6ca2efdf12ae63dc(CMakeLists.txt,tests/cpu/exe_tls.cpp,tests/cpu/exe_tls_slot0.cpp,tests/cpu/exe_tls_template.asm).g_spanandt_arrayinto.tls$X SEGMENT ALIGN(4) 'DATA'in MASM with/Zc:tlsGuards-on the CRT-free C++ sources avoids MSVC dynamic TLS guard emission while preserving the exact0x14000xFFbytes (t_array) and 32-bit masked(0A5000000h XOR (word_index * 09E3779B1h)) AND 0FFFFFFFFhpattern (g_span).python3 -B tests/docs_links_check.py,python3 -B tests/bidi_controls_check.py,python3 -B tests/gpu_report_format_check.py,python3 -B tests/xgameruntime_table_check.py— all passed; Windows MSVC/MASM verification relies on CI.Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T01:37:00Z.
Tested PR #1119 at
c3a14857beon MSVC 19.42 (VS 2022 17.12.3, cl 19.42.34435.0), Windows 26200.Debug:
cpu_exe_tls,cpu_exe_tls_early,cpu_exe_tls_slot0,cpu_exe_tls_slot0_enroll, andcpu_exe_tls_slot0_pauseall linked. ctest: 4 passed, 0 failed (cpu_native_exe_tls,cpu_native_exe_tls_slot0_windows,cpu_native_exe_tls_slot0,cpu_native_exe_tls_slot0_enroll).Release: the same 5 targets linked. ctest: 4 passed, 0 failed (same four tests).
These are the same five targets that failed to link on this toolset before (#1094).
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-24T02:04:51Z.
Ran #1119 at
c3a14857with MSVC 19.42.34444 (toolset 14.42.34433), Windows 11 build 26200.9974, alongside the confirmation above. The five targets link in Debug and Release here too, and the four native/mapped checks pluscpu_package_main_imagepass, three Debug runs.One more test fails on 19.42 for the same reason, on
mainand with this PR:cpu_native_tls_value(tests/cpu/tls_value.cppuses the same__declspec(thread) Span g_span = make_span();). That DLL links the static CRT, so it builds, but 19.42 initializesg_spandynamically and the check stops atcpu_tls_value.dll: the 8 KiB array is not in the TLS template. 19.44 places it in the template.What I measured on 19.42 by compiling the initializer forms by hand: a thread-local aggregate whose initializer calls any function, constexpr or not, gets a dynamic initializer (also with /O2, /std:c++20, /permissive- and a raised /constexpr:steps;
constinitwith /std:c++20 gives C2127), while a brace list of plain constant expressions is constant-initialized. Writing the template as such a brace list makescpu_native_tls_valuepass on 19.42 here; the MASM template from this PR should work fortls_value.cpptoo, but I have not tried it. For reference only, the brace-list version is onroansystemlabs:build/1094-tls-on-demand(1ddfc063); it also rewrites the two EXE templates this PR covers, so it is not meant to be merged as is. I can open a small follow-up fortls_value.cppafter this lands, if useful.AI-assisted.