Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: refactor the TLS implementation #126523

Merged
merged 6 commits into from
Jun 24, 2024

Commits on Jun 15, 2024

  1. 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
    joboet committed Jun 15, 2024
    Configuration menu
    Copy the full SHA
    f3facf1 View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2024

  1. std: simplify #[cfg]s for TLS

    joboet committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    d70f071 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b2f29ed View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    35f050b View commit details
    Browse the repository at this point in the history
  4. std: rename module for clarity

    joboet committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    32f9b8b View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2024

  1. std: fix wasm builds

    joboet committed Jun 24, 2024
    Configuration menu
    Copy the full SHA
    50a02ed View commit details
    Browse the repository at this point in the history