Skip to content

Commit 4dc48ac

Browse files
Rollup merge of rust-lang#153174 - Trivo25:fix-wasm64-sync-cfg, r=joboet
std: add wasm64 to sync::Once and thread_parking atomics cfg guards 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](https://github.com/o1-labs/o1js/)) compiled with `-Z build-std=panic_abort,std` and `-C target-feature=+atomics,+bulk-memory,+mutable-globals` Related: rust-lang#83879 rust-lang#77839 Happy to adjust anything based on feedback
2 parents 5f070f9 + 6a950e7 commit 4dc48ac

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

library/std/src/sys/sync/once/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cfg_select! {
1212
all(target_os = "windows", not(target_vendor="win7")),
1313
target_os = "linux",
1414
target_os = "android",
15-
all(target_arch = "wasm32", target_feature = "atomics"),
15+
all(target_family = "wasm", target_feature = "atomics"),
1616
target_os = "freebsd",
1717
target_os = "motor",
1818
target_os = "openbsd",

library/std/src/sys/sync/thread_parking/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cfg_select! {
33
all(target_os = "windows", not(target_vendor = "win7")),
44
target_os = "linux",
55
target_os = "android",
6-
all(target_arch = "wasm32", target_feature = "atomics"),
6+
all(target_family = "wasm", target_feature = "atomics"),
77
target_os = "freebsd",
88
target_os = "openbsd",
99
target_os = "dragonfly",

0 commit comments

Comments
 (0)