Skip to content

std: Implement futex on wasip3 targets, update target spec#159731

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
alexcrichton:wasip3-futex
Jul 24, 2026
Merged

std: Implement futex on wasip3 targets, update target spec#159731
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
alexcrichton:wasip3-futex

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit is in preparation for eventual tier 2 status for the wasm32-wasip3 target. Initially this target will not have support for threads but it's expected to come ~later this year. The first step in supporting this is switching internal #[cfg] in the standard library to "ok this target has threads", and this commit is the update for synchronization primitives. All synchronization primitives on the wasm32-wasip3 now use a futex-based implementation, and the implementation of the futex itself is located in wasi-libc (see WebAssembly/wasi-libc#834). Other WASI targets can eventually all use this implementation as well, but wasi-libc's implementation of these symbols will need to percolate, so those targets aren't changed yet. For wasm32-wasip3, however, any supporting wasi-libc will have these symbols.

This then additionally fixes the target to actually build with a modern LLVM by passing a necessary flag to wasm-ld. This flag isn't supported until LLVM 23, but the wasm32-wasip3 target isn't fully supported until LLVM 23 anyway (hence its Tier 3 status currently).

@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added O-wasi Operating system: Wasi, Webassembly System Interface S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

This commit is in preparation for eventual [tier 2 status] for the
`wasm32-wasip3` target. Initially this target will not have support for
threads but it's expected to come ~later this year. The first step in
supporting this is switching internal `#[cfg]` in the standard library
to "ok this target has threads", and this commit is the update for
synchronization primitives. All synchronization primitives on the
`wasm32-wasip3` now use a `futex`-based implementation, and the
implementation of the futex itself is located in wasi-libc (see
WebAssembly/wasi-libc/834). Other WASI targets can eventually all use
this implementation as well, but `wasi-libc`'s implementation of these
symbols will need to percolate, so those targets aren't changed yet. For
`wasm32-wasip3`, however, any supporting `wasi-libc` will have these
symbols.

This then additionally fixes the target to actually build with a modern
LLVM by passing a necessary flag to `wasm-ld`. This flag isn't supported
until LLVM 23, but the `wasm32-wasip3` target isn't fully supported
until LLVM 23 anyway (hence its Tier 3 status currently).

[tier 2 status]: rust-lang/compiler-team#1001
@clarfonthey

Copy link
Copy Markdown
Contributor

The code looks okay, but just since I'm completely unfamiliar with WASI and you have r+ permissions, I'll let you merge. It otherwise doesn't look like it'll break anything important and does match the API you provided.

That is, r=me, but you press the button.

@alexcrichton

Copy link
Copy Markdown
Member Author

Heh fair enough, thanks for reviewing regardless!

@bors r=clarfonthey

@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5871216 has been approved by clarfonthey

It is now in the queue for this repository.

@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 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 14 pull requests

Successful merges:

 - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #158372 (rustfmt: Discover modules via `cfg_select!`)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - #159731 (std: Implement futex on wasip3 targets, update target spec)
 - #159755 (Improve consistency of attribute error messages)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159271 (str: add ASCII fast path to word_to_titlecase)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
@rust-bors
rust-bors Bot merged commit 5c3196f into rust-lang:main Jul 24, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 24, 2026
rust-timer added a commit that referenced this pull request Jul 24, 2026
Rollup merge of #159731 - alexcrichton:wasip3-futex, r=clarfonthey

std: Implement futex on wasip3 targets, update target spec

This commit is in preparation for eventual [tier 2 status] for the `wasm32-wasip3` target. Initially this target will not have support for threads but it's expected to come ~later this year. The first step in supporting this is switching internal `#[cfg]` in the standard library to "ok this target has threads", and this commit is the update for synchronization primitives. All synchronization primitives on the `wasm32-wasip3` now use a `futex`-based implementation, and the implementation of the futex itself is located in wasi-libc (see WebAssembly/wasi-libc#834). Other WASI targets can eventually all use this implementation as well, but `wasi-libc`'s implementation of these symbols will need to percolate, so those targets aren't changed yet. For `wasm32-wasip3`, however, any supporting `wasi-libc` will have these symbols.

This then additionally fixes the target to actually build with a modern LLVM by passing a necessary flag to `wasm-ld`. This flag isn't supported until LLVM 23, but the `wasm32-wasip3` target isn't fully supported until LLVM 23 anyway (hence its Tier 3 status currently).

[tier 2 status]: rust-lang/compiler-team#1001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-wasi Operating system: Wasi, Webassembly System Interface S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

4 participants