Repository navigation
TLS: xcl.exe built with MinGW and lld keeps its TLS directory - #464
pablogonz12 wants to merge 1 commit into
Conversation
XCL's TLS callback (.CRT$XLY in main.rs) and the title's slot 0 need xcl.exe's TLS directory. MSVC's linker always emits one; with MinGW it is _tls_used in the CRT's tlssup.o, which lld (llvm-mingw) leaves out when nothing refers to it. The x86_64-pc-windows-gnu build then had no TLS directory: the title kept slot 4 while its /GA code reads slot 0 and faulted on its second thread. own_tls_index() now refers to _tls_used on target_env = "gnu", which keeps the directory; a unit test checks the executable has one.
db04128 to
4a1f727
Compare
towiice
left a comment
There was a problem hiding this comment.
Tested PR head 4a1f727 with Rust 1.100.0 (stable-x86_64-pc-windows-gnullvm, llvm-mingw 23.1.6 UCRT + lld) on Windows 11 build 10.0.26300 (26H2), NVIDIA GeForce GTX 1650 SUPER (driver 610.88), DXC v1.9.2609:
cargo build --workspace: succeeded.cargo test -p xcl --lib tls -- --test-threads=4: 7 passed, 0 failed, 1 ignored (includingtls::tests::the_executable_has_a_tls_directoryandpe::tests::parses_own_test_binary_tls).cargo test -p xcl --test e2e: 3 passed, 0 failed (30.79 s).
Builds and passes cleanly under llvm-mingw + lld.
Test report: #464 with GNU ld (mingw-w64-gcc) on NVIDIAThis complements the PR's llvm-mingw / lld run on AMD with the other common MinGW toolchain: mingw-w64-gcc with GNU ld (binutils), on an NVIDIA GPU. With GNU ld the bug doesn't occur, and the PR changes nothing there: same test results apart from its new test, same TLS layout, same game run. Setup
TLS directory (
Tests (debug build, lib test binary under Wine)
Regression run (GTA VI 1.0.2.1, my own dump;
Not tested
AI use: Claude Code (Claude Opus 5.5) built both commits, ran every command above on the machine above and wrote this report. The counts and blocks are pasted from those runs. I reviewed the report before posting. |
|
Linux / MinGW ( Environment
Tested (debug test binary under Wine,
Not tested: full workspace suite, llvm-mingw / lld linker specifically, retail title run, native Windows. AI use: T3 Code / Antigravity (Gemini 4 Neon) merged, built, ran the tests on this machine, and drafted this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
XCL's TLS callback (
.CRT$XLYinmain.rs) and the title's slot 0 needxcl.exe's TLS directory. MSVC's linker always emits one. With MinGW the directory is_tls_usedin the CRT'stlssup.o, which LLVM's lld (llvm-mingw) leaves out when nothing refers to it. Anx86_64-pc-windows-gnubuild linked that way had no TLS directory (llvm-readobj --coff-tls-directoryprinted nothing), the log saidTLS: <title>.exe keeps slot 4 (xcl.exe has no TLS directory) – code built with /GA reads slot 0, and a retail title faulted on its second thread about 0.7 s in. The existing testpe::tests::parses_own_test_binary_tlsfails onmainthe same way.Related: #257 (Linux docs and scripts, which build for
x86_64-pc-windows-gnu).What is in it
crates/xcl/src/tls.rs: ontarget_env = "gnu",own_tls_index()refers to_tls_used, which keeps the directory. MSVC builds are unchanged (the code iscfg'd out).tls::tests::the_executable_has_a_tls_directory.Tested
x86_64-pc-windows-gnu, run under Wine.cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu, test binary run under Wine with--test-threads=4:4a1f727): 633 passed, 4 failed, 21 ignored;main(a6f5f7a): 631 passed, 5 failed, 21 ignored. The fifth ispe::tests::parses_own_test_binary_tls, which this PR fixes; the other four fail the same way on both (gpu_f64_roots,gpu_f64_math_random,gpu_nonfused_mad_and_mac_prevent_fma_contraction,xma2_source_voice_decodes_and_manages_lifetime) and are not touched here.cargo xwin test --workspace --release --locked --target x86_64-pc-windows-msvc --no-run, then each of the 15 test binaries from its package folder under Wine (GE-Proton11-14, Mesa 26.3.1, DXC 1.9.2609.5, Rust 1.100.0, static CRT) with--test-threads=4; no filters, 0SKIPPEDlines on the head, 0 on the base:4a1f727): 670 passed, 7 failed, 41 ignored;main(a6f5f7a): 669 passed, 7 failed, 41 ignored.disk_free_space_ex_reports_pls_quota,gpu::recomp::tests::gpu_f64_math_random,gpu::recomp::tests::gpu_f64_roots,gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction,hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime,set_predication_buffer_state_and_kickoff,test_title_runs_and_game_folder_is_untouched._tls_usedreference removed: FAILED; with it: ok.XCL_RUN_SECONDSwith exit code 0 (GNU build).Regression run
Both blocks are the output of each commit's own unmodified
scripts/smoke.ps1, written to a file by PowerShell and pasted as is. It ran in Windows PowerShell 7.7.0 (pwsh.exe) under Wine (GE-Proton11-14, Linux), not on native Windows, with MinGit 2.56.1 forgit; host workarounds outside the script: a pseudo-terminal,DOTNET_SYSTEM_GLOBALIZATION_USENLS=1, and importing PowerShell's Utility and Management modules first.xcl.exeis an MSVC release build (cargo xwin, static CRT), where this change is compiled out, so this is only a regression check;mainis this PR's base commit.The title is flaky on this host with either commit, so here is every run (alternating, in this order); the pasted pair is run 2, the first where both finished cleanly:
The GNU/lld build, which this PR fixes, was run earlier with the bash script from #257 (not
smoke.ps1):mainfaulted before its first frame and this head presented frames and exited 0.main:This PR's head:
Not tested
tlssup.oalready; there this is a no-op).cargo test --workspaceon the GNU target: the whole-workspace run above is MSVC; on GNU only thexcllibrary tests were run.AI use
smoke.ps1runs and updated those two parts of this description.