Stream: rust-toolchain

Topic: wasm32-wasi platform doc


view this post on Zulip bstrie (Jul 29 2022 at 18:30):

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)

view this post on Zulip bstrie (Jul 29 2022 at 18:32):

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

view this post on Zulip Alex Crichton (Jul 29 2022 at 18:43):

Here's what I might recommend to write for that:


Requirements

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:

This target does not support panic=unwind at this time.

WebAssembly System Interface. Contribute to WebAssembly/WASI development by creating an account on GitHub.
WASI libc implementation for WebAssembly. Contribute to WebAssembly/wasi-libc development by creating an account on GitHub.
Bulk memory operations. Contribute to WebAssembly/bulk-memory-operations development by creating an account on GitHub.
Branch of the spec repo scoped to discussion of SIMD in WebAssembly - GitHub - WebAssembly/simd: Branch of the spec repo scoped to discussion of SIMD in WebAssembly
Sign-extension opcodes. Contribute to WebAssembly/sign-extension-ops development by creating an account on GitHub.
Proposal to add non-trapping float-to-int conversions to WebAssembly - GitHub - WebAssembly/nontrapping-float-to-int-conversions: Proposal to add non-trapping float-to-int conversions to WebAssembly

view this post on Zulip Alex Crichton (Jul 29 2022 at 18:43):

er hit enter too soon editing more in now

view this post on Zulip Alex Crichton (Jul 29 2022 at 18:51):

ok filled out a bit more now, and happy to field questions from upstream if there are any about that

view this post on Zulip bstrie (Jul 29 2022 at 19:33):

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?

view this post on Zulip Alex Crichton (Jul 29 2022 at 19:38):

Sure yeah, I don't mind being listed


Last updated: Nov 22 2024 at 16:03 UTC