rust/library/std
Jonathan Brouwer 2c17e0e110
Rollup merge of #151016 - fix_wasi_threading, r=alexcrichton
fix: WASI threading regression by disabling pthread usage

PR rust-lang/rust#147572 changed WASI to use the Unix threading implementation, but WASI does not support threading. When the Unix code tries to call pthread_create, it fails with EAGAIN, causing libraries like rayon to panic when trying to initialize their global thread pool.

The old wasip1/wasip2 implementations:
- wasip1: Threading conditionally available with atomics (experimental)
- wasip2: Threading unconditionally unsupported

This fix restores that behavior by disabling pthread-based threading for all WASI targets:
1. Guard the pthread-based Thread implementation with #[cfg(not(target_os = "wasi"))]
2. Provide an unsupported stub (Thread(!)) for WASI
3. Return Err(io::Error::UNSUPPORTED_PLATFORM) when Thread::new is called

Fixes the regression where rayon-based code (e.g., lopdf in PDF handling) panicked on WASI after nightly-2025-12-10.

Before fix:
  pthread_create returns EAGAIN (error code 6)
  ThreadPoolBuildError { kind: IOError(Os { code: 6,
  kind: WouldBlock, message: "Resource temporarily unavailable" }) }

After fix:
  Thread::new returns Err(io::Error::UNSUPPORTED_PLATFORM)
  Libraries can gracefully handle the lack of threading support

r? @alexcrichton
2026-01-14 22:29:58 +01:00
..
benches benchmark path.components() iteration 2025-10-25 14:46:58 +02:00
src Rollup merge of #151016 - fix_wasi_threading, r=alexcrichton 2026-01-14 22:29:58 +01:00
tests add oneshot tests 2026-01-05 09:47:20 +11:00
build.rs Update to new API, allowing to remove check_doc_cfg.rs file from librustdoc 2025-12-10 12:28:08 +01:00
Cargo.toml Remove std_detect_file_io and std_detect_dlsym_getauxval features 2026-01-08 14:50:12 +00:00