How to Use WASI (WebAssembly System Interface) with Rust

Web
Compile Rust for WASI by adding the wasm32-wasip1 target and building with cargo.

Use the wasm32-wasip1 target triple to compile Rust code for WASI, ensuring getrandom and wasi dependencies are available for runtime system calls.

rustup target add wasm32-wasip1
cargo build --target wasm32-wasip1

For multithreaded support, use wasm32-wasip1-threads as noted in the std::thread::spawn fix for version 1.94.1.

rustup target add wasm32-wasip1-threads
cargo build --target wasm32-wasip1-threads