Rust -> WASM, large binary?

I am pretty confused with sizes of wasm rust, and I need a help understading why?

# Scenario
$ cargo build --release --target wasm32-unknown-unknown
# Generates a binary wasm file ~874K big.wasm
$ wasm2wat big.wasm -o test1.wat && wat2wasm test1.wat -o small.wasm
# Generates a much smaller wasm binary ~47K small.wasm
$ wasm2wat small.wasm -o test2.wat # generates same source as test1.wat

I can’t give a definite answer to your question of why it is 20 times bigger than it should, but I do know the rust and wasm book has a section on shrinking the size.

Also the wasm workgroup hang out on the rust discord server, and you might get an answer there faster, or you might search issues on the rust github for wasm size…, and potentionally open one if you can’t find answers anywhere else and think this is something that should be fixed.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.