rust/library
Matthias Krüger 546929f276
Rollup merge of #144234 - roblabla:fix-win7-tls-dtors, r=ChrisDenton
Fix broken TLS destructors on 32-bit win7

Fixes rust-lang/rust#141300

On the 32-bit win7 target, we use OS TLS instead of native TLS, due to issues with how the OS handles alignment. Unfortunately, this caused issues due to the TLS destructors not running, causing memory leaks among other problems.

On Windows, to support OS TLS, the TlsAlloc family of function is used by Rust. This function does not support TLS destructors at all. However, rust has some code to emulate those destructors, by leveraging the TLS support functionality found in the MSVC CRT (specifically, in tlssup.c of the CRT).

To use this functionality, the user must do two things:

1. They must put the address to their callback in a section between `.CRT$XLB` and `.CRT$XLY`.
2. They must add a reference to `_tls_used` (or `__tls_used` on x86) to make sure the TLS support code in tlssup.c isn't garbage collected by the linker.

Prior to this commit, this second bit wasn't being done properly by the Rust TLS support code. Instead of adding a reference to _tls_used, it instead had a reference to its own callback to prevent it from getting GC'd by the linker. While this is _also_ necessary, not having a reference on _tls_used made the entire support non-functional.

This commit reworks the code to:

1. Add an unconditional `#[used]` attribute on the CALLBACK, which should be enough to prevent it from getting GC'd by the linker.
2. Add a reference to `_tls_used`, which should pull the TLS support code into the Rust programs and not let it be GC'd by the linker.
2025-07-23 15:59:29 +02:00
..
alloc Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00
alloctests Add test for int_format_into feature 2025-07-03 18:57:16 +02:00
backtrace@b65ab935fb Update the backtrace submodule 2025-06-16 07:00:13 +00:00
compiler-builtins Merge ref '82310651b9' from rust-lang/rust 2025-07-18 19:06:49 +00:00
core Auto merge of #144205 - hkBst:flt2dec, r=workingjubilee 2025-07-22 08:28:29 +00:00
coretests Rollup merge of #143604 - nxsaken:const_float_round_methods, r=RalfJung 2025-07-20 08:56:06 +02:00
panic_abort Use the in-tree compiler-builtins 2025-06-08 02:36:58 +00:00
panic_unwind Win: Use exceptions with empty data for SEH panic exception copies 2025-07-08 22:07:42 +02:00
portable-simd use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
proc_macro Rollup merge of #143631 - hkBst:update-escaper-2, r=compiler-errors 2025-07-17 10:41:45 +02:00
profiler_builtins Fix profiler_builtins build script to handle full path to profiler lib 2025-04-11 16:57:38 +02:00
rtstartup Update cfg(bootstrap) 2025-07-01 10:55:49 -07:00
rustc-std-workspace-alloc Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
rustc-std-workspace-core make compiler_builtins a private dependency 2025-06-30 20:27:10 -04:00
rustc-std-workspace-std Migrated the rustc-std-workspace crates to Rust 2024 2025-03-11 09:46:35 -07:00
std Rollup merge of #144234 - roblabla:fix-win7-tls-dtors, r=ChrisDenton 2025-07-23 15:59:29 +02:00
std_detect Embed auxv files directly into the test binary 2025-07-22 20:22:16 +02:00
stdarch Remove std_detect from stdarch's CI 2025-07-22 20:22:16 +02:00
sysroot Add experimental backtrace-trace-only std feature 2025-07-14 11:52:17 +00:00
test Add new test_main_with_exit_callback public function in libtest to allow a callback to be called before exiting 2025-05-06 18:17:48 +02:00
unwind Upgrade the standard library unwinding version 2025-06-11 20:05:06 +00:00
windows_targets UWP: link ntdll functions using raw-dylib 2025-07-07 15:39:31 +00:00
Cargo.lock Make std_detect a direct dependency of std 2025-07-22 20:17:23 +02:00
Cargo.toml Auto merge of #140999 - hkBst:update-escaper, r=nnethercote 2025-06-25 01:03:30 +00:00