Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b40c54b

Browse files
committedJun 15, 2024
std: refactor the TLS implementation
As discovered by Mara in rust-lang#110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with rust-lang#117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. @rustbot label +A-thread-locals
1 parent 369fa55 commit b40c54b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+717
-927
lines changed
 

‎std/src/sys/pal/unix/thread_local_key.rs

-29
This file was deleted.

‎std/src/sys/pal/unsupported/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ pub mod pipe;
1111
pub mod process;
1212
pub mod stdio;
1313
pub mod thread;
14-
#[cfg(target_thread_local)]
15-
pub mod thread_local_dtor;
16-
pub mod thread_local_key;
1714
pub mod time;
1815

1916
mod common;

‎std/src/sys/pal/unsupported/thread_local_dtor.rs

-10
This file was deleted.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.