If I use these settings in Cargo.toml
:
[profile.release]
lto = true
opt-level = "z"
And I compile this code:
fn main() {
}
#[no_mangle]
fn flip(a: u32, b: u32) -> (u32, u32) {
(b, a)
}
Using RUSTFLAGS="-C target-feature=+multivalue" cargo build --release --target=wasm32-unknown-unknown
I end up with a file that is about 65KB. The only thing being used in the code will be flip
, called directly from Javascript in a browser. The vast majority of that 65KB will be unused. (wasm-opt
optimizes away about 2KB.)
How do I minimize the code size further?