Skip to content

Commit 637a138

Browse files
jieyouxuMark-Simulacrum
authored andcommitted
library: wasm32-wasip1-threads has functional pthreads
Minimal backport-suitable fix to avoid returning `UNSUPPORTED_PLATFORM` for `wasm32-wasip1-threads` which has a working pthreads implementation via `emnapi`. The stable regression was reported in <#153475>.
1 parent 6fd8bb9 commit 637a138

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/sys/thread/unix.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ impl Thread {
4949
// WASI does not support threading via pthreads. While wasi-libc provides
5050
// pthread stubs, pthread_create returns EAGAIN, which causes confusing
5151
// errors. We return UNSUPPORTED_PLATFORM directly instead.
52-
if cfg!(target_os = "wasi") {
52+
53+
// NOTE: exempt `wasm32-wasip1-threads` from this check as `emnapi` has a working pthread
54+
// implementation. See <https://github.com/rust-lang/rust/issues/153475>.
55+
if cfg!(all(target_os = "wasi", not(all(target_env = "p1", target_feature = "atomics")))) {
5356
return Err(io::Error::UNSUPPORTED_PLATFORM);
5457
}
5558

0 commit comments

Comments
 (0)