Releases: alexcrichton/rust
Releases · alexcrichton/rust
wasi3
Steps for usage
- First, download the appropriate tarball below. Only Linux/macOS tarballs are available right now, but that's just because I don't have a Windows machine handy. When this is landed in upstream rust-lang/rust we'll have standard releases for everyone!
- Extract it, it'll make a directory called
wasi-rustc
- Execute
rustup toolchain link wasi $PWD/wasi-rustc
- Execute
rustc +wasi -vV
and make sure it works - Create
hello.rs
which is the standard rust hello world rustc +wasi hello.rs --target wasm32-unknown-wasi
- Clone https://github.com/CraneStation/wasmtime
cargo run --bin wasmtime /path/to/hello.wasm
And that's it!
If you want to interoperate with C code, then finish step 4 above and follow afterwards with:
- Download Clang 8.0 for your platform
- Clone https://github.com/CraneStation/wasi-sysroot
- Run
make WASM_CC=/path/to/clang
- Create an executable script called
wasm32-wasi-clang
which looks like this:
#!/bin/sh
exec /path/to/clang --sysroot /path/to/wasi-sysroot/sysroot "$@"
- Execute
rustc +wasi hello.rs --target wasm32-unknown-wasi -C target-feature=-crt-static -C linker=/path/to/wasm32-wasi-clang
That final step will link against the sysroot rather than the internal one provided by rustc. You can also produce a staticlib and avoid -C linker
and then link manually. You can also use crates like cc
to build C code as part of your Rust application. Up to you!
wasi2
- First, download the appropriate tarball below
- Extract it, it'll make a directory called
wasi
- Execute
rustup toolchain link wasi $PWD/wasi
- Execute
rustc +wasi -vV
and make sure it works - Create
hello.rs
which is the standard rust hello world rustc +wasi hello.rs --target wasm32-unknown-wasi
- Clone https://github.com/cranestation/wasmtime-wasi
cargo run --bin wasmtime /path/to/hello.wasm
If you want to interoperate with C code, then finish step 4 above and follow afterwards with:
- Clone https://github.com/cranestation/wasmception-wasi
- Run
make
inside there
- This'll take quite awhile as it builds clang
rustc +wasi hello.rs --target wasm32-unknown-wasi -C target-feature=-crt-static -C linker=/path/to/wasmception-wasi/dist/bin/clang
wasi
- First, download the appropriate tarball below
- Extract it, it'll make a directory called
wasi
- Execute
rustup toolchain link wasi $PWD/wasi
- Execute
rustc +wasi -vV
and make sure it works - Clone https://github.com/cranestation/wasmception-wasi
- Run
make
inside there
- This'll take quite awhile as it builds clang
- Create
hello.rs
which is the standard rust hello world rustc +wasi hello.rs --target wasm32-unknown-wasi -C linker=/path/to/wasmception-wasi/dist/bin/clang
- Clone https://github.com/cranestation/wasmtime-wasi
cargo run --bin wasmtime /path/to/hello.wasm