Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #157483 - RalfJung:windows-gnu-tls-leak, r=ChrisDenton
fix windows-gnu TLS leak
Running the std tests on windows-gnu [has a memory leak](https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/Miri.20test-libstd.20Failure.20.282026-06.29/near/599991435). After lots of false leads, here's what I found:
- The `guard::enable` function needs to be called on each thread; it the ensures that when the thread finishes, cleanup is performed.
- The windows `LazyKey` calls `guard::enable` in its `init` function. That means it only gets called on the first thread that accesses this key!
- We have a `guard::enable` call in the `thread::spawn` path. However, when running tests, there are two copies of std, so there are two guards. `crate::thread::spawn` sets up the guard for the current crate (the one built with `cfg(test)`), but does not set up the guard for `realstd` (the std crate in the sysroot).
This is a regression introduced by https://github.com/rust-lang/rust/pull/148799. Previously, `guard::enable` was pretty much a NOP on Windows so not calling it didn't cause problems.
https://github.com/rust-lang/miri-test-libstd/pull/123 has confirmed that this indeed fixes the leak.
The first commit is a drive-by fix where I found a function name kind of confusing.
r? @ChrisDenton
Cc @joboet