From 064a1881c5634b52a633defcc7a0b2f635d0adc1 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Tue, 10 Mar 2026 10:29:36 +0800 Subject: [PATCH] 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 . --- library/std/src/sys/thread/unix.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/thread/unix.rs b/library/std/src/sys/thread/unix.rs index 6f23c28c04d6a..430e699e098e6 100644 --- a/library/std/src/sys/thread/unix.rs +++ b/library/std/src/sys/thread/unix.rs @@ -49,7 +49,10 @@ impl Thread { // WASI does not support threading via pthreads. While wasi-libc provides // pthread stubs, pthread_create returns EAGAIN, which causes confusing // errors. We return UNSUPPORTED_PLATFORM directly instead. - if cfg!(target_os = "wasi") { + + // NOTE: exempt `wasm32-wasip1-threads` from this check as `emnapi` has a working pthread + // implementation. See . + if cfg!(all(target_os = "wasi", not(all(target_env = "p1", target_feature = "atomics")))) { return Err(io::Error::UNSUPPORTED_PLATFORM); }