-
Notifications
You must be signed in to change notification settings - Fork 112
Compile for WASM
Alexandre Bury edited this page Mar 9, 2022
·
1 revision
As of version 0.10.1, this crate can now compile to WASM!
For example, there is an example in the zstd-sys repository you can compile.
First, make sure you have the wasm32-unknown-unknown
target. If you want to try the WASM binaries locally, you will also need a runtime like wasmtime.
# Make sure you have the correct target
rustup target add wasm32-unknown-unknown
# Build the example
cargo build --target wasm32-unknown-unknown --no-default-features --example it_work
# Run the WASM binary locally using wasmtime
wasmtime target/wasm32-unknown-unknown/debug/examples/it_work.wasm --invoke test_compress
On macOS, you may need some extra steps before you're able to compile:
brew install llvm
export PATH="/usr/local/opt/llvm/bin/:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export AR=/usr/local/opt/llvm/bin/llvm-ar