liuyanghejerry / rust-wasm-size-bug

This repository is used for reproducing a size issue when compiling code to WASM.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

rustc 1.28.0-nightly (2a1c4eec4 2018-06-25)

In my macOS with rustc 1.28.0-nightly (2a1c4eec4 2018-06-25), the binary is about 639K.

rustc 1.31.0-nightly (4efdc04a5 2018-10-06)

With LTO enabled, it's 52KB now.

rustc 1.33.0-nightly (ceb251214 2019-01-16)

It's 63KB now. No idea why it is going backwards.

rustc 1.49.0 (e1884a8e3 2020-12-29)

It's 236B now. Wow! Not sure the minimal version get this done.

About

This repository is used for reproducing a size issue when compiling code to WASM.


Languages

Language:Rust 52.8%Language:Shell 47.2%