It's just too complex to make Rust+WASM work on macOS, but all the other guides online target macOS. This guide targets only Arch Linux. If your favorate distro is great, you should be able to do the same thing.
Install rustup and emscripten with the distro's native package manager. Then install stable Rust and wasm target with Rustup.
# pacman -S rustup emscripten
$ rustup update stable
$ rustup target add wasm32-unknown-emscripten
Now, logout and re-login to make /etc/profile.d/emscripten.sh
in effect.
$ cargo init --bin hello
$ cd hello
$ rustc --target=wasm32-unknown-emscripten src/main.rs -o main.html
$ emrun main.html # Spin up a server and open your default browser
The rustc
step may fail, if you are using Emscripten Port version 37.
This will be fixed in future releases of Emscripten Port,
which means, you may need to follow the error messages and
patch the code yourself according to WebAssembly/binaryen#1196.
This was written years ago and things have changed. You can use many tools out there (like wasm-pack or cargo-wasi) now.
Sadly, Gist does not support archiving like a real GitHub repo does, so this doc will stay here as is.