I was thinking it might be nice to have a wasm32-wasi document in the rustc guide section on platform support, similar to how https://doc.rust-lang.org/nightly/rustc/platform-support/wasm64-unknown-unknown.html exists for wasm64-unknown-unknown (which, full disclosure, I have no idea how it relates to wasm32-wasi)
I'd be willing to make the PR adding it, but I don't know enough about the target to answer all the questions in the requirements section: https://doc.rust-lang.org/nightly/rustc/platform-support/TEMPLATE.html#requirements
Here's what I might recommend to write for that:
This target is cross-compiled and represents bindings to WASI host imports available to WebAssembly. This target supports std
, although some functions are stubbed out to unconditionally return errors for platform features not supported by WASI yet. For example std::thread::spawn
will panic because WASI does not support spawning a thread. At this time std::fs
should work and some of std::net
should work. The exact support provided by std
will evolve over time as WASI evolves and gains functionality.
This target is relatively stable but WASI itself is not 100% stable yet. This Rust target will continue to evolve with the upstream evolution of the WASI standard, in particular around the signatures and names of host imported functions.
The WebAssembly binaries produced by this target can run in a number of WebAssembly runtimes which support WASI. For example there are some browser polyfills for WASI, node.js has an experimental wasi
module, and non-JS runtime such as Wasmtime support WASI out-of-the-box. The general intention is that WASI binaries do not need extra "host glue" in the form of JS glue code or otherwise code necessary to run the WebAssembly modules.
This target is currently single-threaded and generally does not support the atomics
feature of WebAssembly.
This target links to wasi-libc for core functionality such as memory allocation and handling of "preopened" paths. This is also done to assist in interoperating Rust code with other languages such as C when they're all compiled to the wasm32-wasi
target.
Notable target features for wasm32-wasi
include:
+bulk-memory
- enables the bulk memory operations proposal, namely the memory.copy
instruction+simd128
- enables the simd proposal which includes a number of operations for 128-bit simd types in the core::arch::wasm32
module+sign-ext
- enables some miscellaneous sign extension instructions for more efficient low-level operations+nontrapping-fptoint
- enables the nontrapping float-to-int proposal which improves codegen and efficiency of f32 as i32
casts in Rust for exampleThis target does not support panic=unwind
at this time.
er hit enter too soon editing more in now
ok filled out a bit more now, and happy to field questions from upstream if there are any about that
Awesome, I'll definitely file a PR with this info, thanks Alex! Would you mind if I specified you and/or Dan as the target maintainers?
Sure yeah, I don't mind being listed
Last updated: Dec 23 2024 at 13:07 UTC