Skip to content

std: add wasm64 to sync::Once and thread_parking atomics cfg guards#153174

Open
Trivo25 wants to merge 1 commit intorust-lang:mainfrom
Trivo25:fix-wasm64-sync-cfg
Open

std: add wasm64 to sync::Once and thread_parking atomics cfg guards#153174
Trivo25 wants to merge 1 commit intorust-lang:mainfrom
Trivo25:fix-wasm64-sync-cfg

Conversation

@Trivo25
Copy link

@Trivo25 Trivo25 commented Feb 27, 2026

When targeting wasm64-unknown-unknown with atomics enabled, std::sync::Once and thread_parking fall through to the no_threads/unsupported implementations because the cfg guards only check for wasm32. This causes worker threads to panic with unreachable at runtime. The underlying futex implementations already handle both wasm32 and wasm64 correctly, only the cfg guards were missing wasm64.

I tested this manually with a multithreaded wasm64 application (o1js) compiled with -Z build-std=panic_abort,std and -C target-feature=+atomics,+bulk-memory,+mutable-globals

Related: #83879 #77839

Happy to adjust anything based on feedback

@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 Feb 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2026

r? @joboet

rustbot has assigned @joboet.
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 8 candidates
  • Random selection from Mark-Simulacrum, joboet

target_os = "linux",
target_os = "android",
all(target_arch = "wasm32", target_feature = "atomics"),
all(any(target_arch = "wasm32", target_arch = "wasm64"), target_feature = "atomics"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified by using target_family = "wasm" which means any(target_arch = "wasm32", target_arch = "wasm64").

Suggested change
all(any(target_arch = "wasm32", target_arch = "wasm64"), target_feature = "atomics"),
all(target_family = "wasm", target_feature = "atomics"),

target_os = "linux",
target_os = "android",
all(target_arch = "wasm32", target_feature = "atomics"),
all(any(target_arch = "wasm32", target_arch = "wasm64"), target_feature = "atomics"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
all(any(target_arch = "wasm32", target_arch = "wasm64"), target_feature = "atomics"),
all(target_family = "wasm", target_feature = "atomics"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants