Building std for wasm32-wasip3 fails due to missing target_env = "p3" in library/std/src/os/mod.rs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Problem Description
When compiling std for wasm32-wasip3 (e.g. ./x.py build --target wasm32-wasip3 library/std), the build fails with 13 compilation errors starting with cannot find wasi in os:
error[E0433]: cannot find `wasi` in `os`
--> library/std/src/os/fd/raw.rs:24:16
|
24 | use crate::os::wasi::io::OwnedFd;
| ^^^^ could not find `wasi` in `os`
|
note: found an item that was configured out
--> library/std/src/os/mod.rs:58:17
|
57 | #[cfg(any(target_env = "p1", target_env = "p2"))]
| -------------------------------------- the item is gated here
58 | pub mod wasi;
| ^^^^
Cause
In Rust 1.98.0, library/std/src/os/mod.rs was refactored with cfg_select!. In 1.97.x, pub mod wasi; was declared as:
#[cfg(any(target_os = "wasi", any(target_env = "p1", target_env = "p2"), doc))]
pub mod wasi;
In 1.98.0, this was changed to:
target_family = "wasm" => {
#[cfg(any(target_env = "p1", target_env = "p2"))]
pub mod wasi;
#[cfg(target_env = "p2")]
pub mod wasip2;
}
This omitted target_os = "wasi" / target_env = "p3". Since wasm32-wasip3 has target_family = "wasm", target_os = "wasi", and target_env = "p3", pub mod wasi; is configured out, breaking internal modules (sys/fs/unix.rs, sys/env/wasi.rs, os/fd/raw.rs) that depend on crate::os::wasi::*.
Proposed Fix
--- a/library/std/src/os/mod.rs
+++ b/library/std/src/os/mod.rs
@@ -54,7 +54,7 @@
pub mod linux;
}
target_family = "wasm" => {
- #[cfg(any(target_env = "p1", target_env = "p2"))]
+ #[cfg(any(target_os = "wasi", target_env = "p1", target_env = "p2", target_env = "p3"))]
pub mod wasi;
#[cfg(target_env = "p2")]
pub mod wasip2;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in library/std/src/os/mod.rs at the target_family = "wasm" cfg_select! block and compare its wasi module condition with the issue description. Run ./x.py build --target wasm32-wasip3 library/std to reproduce the missing wasi errors. Done means std builds for wasm32-wasip3 without those compilation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100