Closed pepyakin closed 5 years ago
I believe this is a case of a missing optimization in LLD itself. If you run this through wasm-opt
it'll remove the bss, but LLD has yet to be taught about that afaik.
Hm actually the presented binary already after wasm-opt
. I should have mentioned this earlier but this is how I build this binary:
rustc +nightly --target wasm32-unknown-unknown -Copt-level=3 -Clto --crate-type=cdylib bss.rs
wasm-opt bss.wasm
wasm2wat -f bss.wasm > bss.wat
Oh I think this may require the -Os
flag perhaps?
It worked when I tried it and rebuilt my wasm-opt
(not sure what helped though)!
Ok I'm going to close this as it was solved locally, and otherwise I think this is a bug for upstream LLD
This Rust code
generates the following wasm
note that on the last line there is a data segment declaration which initializes memory starting from
1048576
to zeroes. This is redundant since memory instance is already initialized to zeroes.