tests: constant-initialize the TLS value template on MSVC 19.42 #1498
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1505"
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 SimSalabimse on 2026-11-24T13:16:00Z.
Change
On MSVC 19.42,
g_spanincpu_tls_value.dllis constant-initialized from a brace list of plain constant expressions. The list is the same 8 KiBspan_word()pattern the existing check expects, so those bytes are in the TLS template. A function-call initializer, includingconstexpr make_span(), stays dynamic on this compiler and leaves the pattern out of the template. The check intests/cpu/native_tls_value_check.pyis unchanged: a template that does not contain the pattern is still a fixture failure. The CRT-free EXE TLS fixtures are unchanged.Refs #1465
Verification
Commit
04d78f3donx2w-tls-value-msvc1942, base3e23ce2c. Windows 11 build 26200, MSVC 19.42.34435 (toolset 14.42.34433).cpu_tls_valuewas compiled from a new object in a new build directory.cmake --preset devexited 0.cmake --build --preset devof the TLS fixture targets (cpu_tls_value,cpu_tls_original,cpu_tls_sink,pe_map, and thecpu_exe_tls*targets) exited 0.cmake --preset releaseexited 0. The same Release build exited 0.ctest --preset dev --no-tests=error -R '^cpu_native_tls_value$' -VExit code 0.
cpu_native_tls_valuepassed (1.95 s).ctest --preset release --no-tests=error -R '^cpu_native_tls_value$' -VExit code 0.
cpu_native_tls_valuepassed (1.36 s).ctest --preset dev --no-tests=error -R '^cpu_(native|mapped)_tls_value|^cpu_native_exe_tls' -VExit code 0. Five tests passed (3.66 s):
cpu_native_tls_value,cpu_native_exe_tls,cpu_native_exe_tls_slot0_windows,cpu_native_exe_tls_slot0,cpu_native_exe_tls_slot0_enroll. No test namedcpu_mapped_tls_valueis registered.ctest --preset release --no-tests=error -R '^cpu_(native|mapped)_tls_value|^cpu_native_exe_tls' -VExit code 0. The same five tests passed (3.11 s).
The check's own template comparison found the 8 KiB array in both 19.42 DLLs (Debug template RVA
0x6f8d0, 8224 bytes; Release template RVA0x18290, 8224 bytes) and reported that it crosses a page boundary. A separatepefileread of each DLL found the same 8192-byte pattern at offset 32 of the TLS template.MSVC 14.29 was not run. The README sentence about that toolset was left unchanged.
Evidence and follow-up
The brace list is source in
tests/cpu/tls_value.cpp. Astatic_assertchecks it word for word againstspan_word(). The existing test is the negative control: swapping the callback table and zeroing the template from its first page boundary are still rejected.Assumption: MSVC 19.42 puts a thread-local aggregate in the TLS template when the initializer is a brace list of constant expressions, and not when that initializer calls a function. That is the comparison recorded on #1119. This change does not retarget the five CRT-free EXE fixtures from #1094.
No game files, dumps, or distribution links.
Checklist
AI-assisted (Grok Build).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:31:28Z.
Review: COMMENTED
Reviewed
04d78f3d93adf5e61a446766565be7a3861289df:tests/cpu/tls_value.cppreplaces theconstexpr Span make_span()call initializer on__declspec(thread) Span g_spanwith a macro-expanded brace list of constant expressions (SPAN_TEMPLATE), plus astatic_assert(span_template_matches(), ...)verifying word-for-word equivalence withspan_word(). The existing template/callback negative controls intests/cpu/native_tls_value_check.pyremain intact.git diff --check origin/main..HEAD,python3 tests/docs_links_check.py(338 links across 16 files), andpython3 tests/bidi_controls_check.py(1228 files) all passed.--preset dev):cpu_tls_valuebuilt (3.78s);ctest --preset dev -R '^cpu_(native|mapped)_tls_value|^cpu_native_exe_tls' --parallel 4 --no-tests=error --output-on-failure— 5/5 passed (2.60s)./O2(--preset release):cpu_tls_valuebuilt (1.05s); same CTest filter — 5/5 passed (1.58s).Looks good to me.