Skip to content

Releases: alexcrichton/rust

wasi3

25 Mar 16:31
Compare
Choose a tag to compare

Steps for usage

  1. 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!
  2. Extract it, it'll make a directory called wasi-rustc
  3. Execute rustup toolchain link wasi $PWD/wasi-rustc
  4. Execute rustc +wasi -vV and make sure it works
  5. Create hello.rs which is the standard rust hello world
  6. rustc +wasi hello.rs --target wasm32-unknown-wasi
  7. Clone https://github.com/CraneStation/wasmtime
  8. 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:

  1. Download Clang 8.0 for your platform
  2. Clone https://github.com/CraneStation/wasi-sysroot
  3. Run make WASM_CC=/path/to/clang
  4. Create an executable script called wasm32-wasi-clang which looks like this:
#!/bin/sh
exec /path/to/clang --sysroot /path/to/wasi-sysroot/sysroot "$@"
  1. 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

13 Mar 17:42
Compare
Choose a tag to compare
  1. First, download the appropriate tarball below
  2. Extract it, it'll make a directory called wasi
  3. Execute rustup toolchain link wasi $PWD/wasi
  4. Execute rustc +wasi -vV and make sure it works
  5. Create hello.rs which is the standard rust hello world
  6. rustc +wasi hello.rs --target wasm32-unknown-wasi
  7. Clone https://github.com/cranestation/wasmtime-wasi
  8. 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:

  1. Clone https://github.com/cranestation/wasmception-wasi
  2. Run make inside there
  • This'll take quite awhile as it builds clang
  1. rustc +wasi hello.rs --target wasm32-unknown-wasi -C target-feature=-crt-static -C linker=/path/to/wasmception-wasi/dist/bin/clang

wasi

12 Mar 23:40
Compare
Choose a tag to compare
  1. First, download the appropriate tarball below
  2. Extract it, it'll make a directory called wasi
  3. Execute rustup toolchain link wasi $PWD/wasi
  4. Execute rustc +wasi -vV and make sure it works
  5. Clone https://github.com/cranestation/wasmception-wasi
  6. Run make inside there
  • This'll take quite awhile as it builds clang
  1. Create hello.rs which is the standard rust hello world
  2. rustc +wasi hello.rs --target wasm32-unknown-wasi -C linker=/path/to/wasmception-wasi/dist/bin/clang
  3. Clone https://github.com/cranestation/wasmtime-wasi
  4. cargo run --bin wasmtime /path/to/hello.wasm