Skip to content

std: Switch implementations of thread_local! for WASI#159733

Open
alexcrichton wants to merge 1 commit into
rust-lang:mainfrom
alexcrichton:wasi-thread-locals
Open

std: Switch implementations of thread_local! for WASI#159733
alexcrichton wants to merge 1 commit into
rust-lang:mainfrom
alexcrichton:wasi-thread-locals

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit is a change for all WASI targets to use a different underlying implementation in the standard library for thread_local!. Previously all wasm targets, without the atomics feature, were funneled into the no_threads implementation and various fallbacks in the thread_local module. The upcoming wasm32-wasip3 target, however, will actually have threads and will need different treatment. Additionally the modules that wasm32-wasip3 needs all already work on all other WASI targets as well -- for example the pthread_* symbols needed to manage destructors are exposed by wasi-libc.

The end result is that the wasm32-wasip3 target will be "ready for threads" as soon as wasi-libc has support. Other targets shouldn't have any functional difference from before, too.

This commit is a change for all WASI targets to use a different
underlying implementation in the standard library for `thread_local!`.
Previously all wasm targets, without the `atomics` feature, were
funneled into the `no_threads` implementation and various fallbacks in
the `thread_local` module. The upcoming `wasm32-wasip3` target, however,
will actually have threads and will need different treatment.
Additionally the modules that `wasm32-wasip3` needs all already work on
all other WASI targets as well -- for example the `pthread_*` symbols
needed to manage destructors are exposed by `wasi-libc`.

The end result is that the `wasm32-wasip3` target will be "ready for
threads" as soon as `wasi-libc` has support. Other targets shouldn't
have any functional difference from before, too.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 22, 2026
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 6 candidates

@clarfonthey

Copy link
Copy Markdown
Contributor

This module's logic is a bit annoying to follow, although everything appears reasonable to me.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit cd551c3 has been approved by clarfonthey

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 26, 2026
…=clarfonthey

std: Switch implementations of `thread_local!` for WASI

This commit is a change for all WASI targets to use a different underlying implementation in the standard library for `thread_local!`. Previously all wasm targets, without the `atomics` feature, were funneled into the `no_threads` implementation and various fallbacks in the `thread_local` module. The upcoming `wasm32-wasip3` target, however, will actually have threads and will need different treatment. Additionally the modules that `wasm32-wasip3` needs all already work on all other WASI targets as well -- for example the `pthread_*` symbols needed to manage destructors are exposed by `wasi-libc`.

The end result is that the `wasm32-wasip3` target will be "ready for threads" as soon as `wasi-libc` has support. Other targets shouldn't have any functional difference from before, too.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 26, 2026
…=clarfonthey

std: Switch implementations of `thread_local!` for WASI

This commit is a change for all WASI targets to use a different underlying implementation in the standard library for `thread_local!`. Previously all wasm targets, without the `atomics` feature, were funneled into the `no_threads` implementation and various fallbacks in the `thread_local` module. The upcoming `wasm32-wasip3` target, however, will actually have threads and will need different treatment. Additionally the modules that `wasm32-wasip3` needs all already work on all other WASI targets as well -- for example the `pthread_*` symbols needed to manage destructors are exposed by `wasi-libc`.

The end result is that the `wasm32-wasip3` target will be "ready for threads" as soon as `wasi-libc` has support. Other targets shouldn't have any functional difference from before, too.
rust-bors Bot pushed a commit that referenced this pull request Jul 26, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #159638 (bootstrap: Split the `Step` trait into multiple traits)
 - #159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations)
 - #159837 (line-tables-only test: check that the line number matches the function name)
 - #159946 (Update Enzyme submodule to imporve llvm-cov)
 - #159617 (Fix up `#[linkage]` target checking)
 - #159733 (std: Switch implementations of `thread_local!` for WASI)
 - #159783 (Check unsafe impls on safe EIIs)
 - #159810 (Add tuple never coercion collection regression test)
 - #159821 (Update expect message using the recommended style in binary_heap module)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
 - #159846 (Implement `str::copy_from_str`)
 - #159849 (rustc_parse: Stop returning `Option` from statement parsing)
 - #159853 (Updated expect messages for `CString` struct and method documentation)
 - #159875 (More cleanup in `rustc_attr_parsing`)
 - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide)
 - #159891 (Split multiline derives into std/rustc macros)
 - #159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups)
 - #159895 (rustc-dev-guide subtree update)
 - #159902 (Clarify that the expected runtime symbols signature is for the current target only)
 - #159914 (Fix error in diagnostic on_unmatched_args)
 - #159917 (spare capacity mut constification)
 - #159918 (rename abort_unwind → abort_on_unwind)
 - #159936 (Minor `rustc_ast::ast` doc cleanups)
 - #159945 (Update expect messages in library/core/src/ptr/non_null.rs)
rust-bors Bot pushed a commit that referenced this pull request Jul 26, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #159638 (bootstrap: Split the `Step` trait into multiple traits)
 - #159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations)
 - #159837 (line-tables-only test: check that the line number matches the function name)
 - #159946 (Update Enzyme submodule to imporve llvm-cov)
 - #159617 (Fix up `#[linkage]` target checking)
 - #159733 (std: Switch implementations of `thread_local!` for WASI)
 - #159783 (Check unsafe impls on safe EIIs)
 - #159810 (Add tuple never coercion collection regression test)
 - #159821 (Update expect message using the recommended style in binary_heap module)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
 - #159846 (Implement `str::copy_from_str`)
 - #159849 (rustc_parse: Stop returning `Option` from statement parsing)
 - #159853 (Updated expect messages for `CString` struct and method documentation)
 - #159875 (More cleanup in `rustc_attr_parsing`)
 - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide)
 - #159891 (Split multiline derives into std/rustc macros)
 - #159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups)
 - #159895 (rustc-dev-guide subtree update)
 - #159902 (Clarify that the expected runtime symbols signature is for the current target only)
 - #159914 (Fix error in diagnostic on_unmatched_args)
 - #159917 (spare capacity mut constification)
 - #159918 (rename abort_unwind → abort_on_unwind)
 - #159936 (Minor `rustc_ast::ast` doc cleanups)
 - #159945 (Update expect messages in library/core/src/ptr/non_null.rs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants