Skip to content

Instantly share code, notes, and snippets.

@simonwo
Last active November 3, 2022 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonwo/476eaa9564a7ac99fa90c74a33beb3b1 to your computer and use it in GitHub Desktop.
Save simonwo/476eaa9564a7ac99fa90c74a33beb3b1 to your computer and use it in GitHub Desktop.
Compile Rust to WASM with WASI
#!/bin/sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh
sh rustup.sh -y
export PATH=~/.cargo/bin:$PATH
rustup target install wasm32-wasi
apt-get install -y build-essential libc6-dev clang-8 gcc-multilib
cd /code
CC_wasm32_wasi=clang-8 cargo build --target wasm32-wasi --release
cp target/wasm32-wasi/release/*.wasm /outputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment