This repository is used for reproducing a size issue when compling code to WASM.
To get things compiled, you'll need nightly toolchain and target "wasm32-unknown-unknown", which can be installed as follow:
rustup toolchain install nightly
rustup target add wasm32-unknown-unknown
Then you can run following command to compile code:
cargo +nightly build --target=wasm32-unknown-unknown --release
Or use shell script:
./run.sh
The WASM file is located at target/wasm32-unknown-unknown/release/wasm_size_bug.wasm
.
In my macOS with rustc 1.28.0-nightly (2a1c4eec4 2018-06-25)
, the binary is about 639K.
With LTO enabled, it's 52KB now.
It's 63KB now. No idea why it is going backwards.
It's 236B now. Wow! Not sure the minimal version get this done.