Repository navigation
TLS: xcl.exe built with MinGW and lld keeps its TLS directory - #464
Open
pablogonz12 wants to merge 1 commit into
Open
pablogonz12 wants to merge 1 commit into
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.
pablogonz12
force-pushed
the
gnu-tls-directory
branch
from
November 24, 2026 01:01
db04128 to
4a1f727
Compare
towiice
reviewed
Nov 24, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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._tls_usedreference removed: FAILED; with it: ok.XCL_RUN_SECONDSwith exit code 0 (blocks below).Regression run
Made with
scripts/linux/smoke.shfrom #257 under Wine (notsmoke.ps1), GNU builds of both commits. Themainblock was made with a local copy of the script with two lines changed so that a run which does not reach its end still prints its block (set -euinstead ofset -euo pipefail; thedata:fallback as anif): onmainthis build crashes before its first frame.Not tested
tlssup.oalready; there this is a no-op).cargo test --workspace: only thexcllibrary tests were run.AI use