Closed eric-seppanen closed 2 weeks ago
Ran into this issue, and fixed by using an up-to-date wasm-opt
. You can use the one on npmjs
or install the one from the binaryen repo. wasm-opt
on nixpkgs also works
wasm-opt
from crates.io
is not updated as often, so sometimes lacks more recent features
While this is true, it's not practical with Trunk. Newer versions (117+) of wasm-opt require the CLI flag --enable-bulk-memory
to be able to operate on these files, and Trunk currently does not have the ability to set the wasm-opt parameters that are used. (edit: Trunk 0.21.3 added this ability.)
Since this issue (unexpectedly enabling bulk-memory instructions) has already been fixed on master, all that is needed for wasm-bindgen to cut a new release.
Indeed, this has been addressed by #4237 and I plan to make a new release soon.
Describe the Bug
When using rust 1.82.0 and wasm-bindgen 0.2.94 or 0.2.95, builds fail because the wasm-bindgen output includes
table.fill
instructions that are poorly supported by downstream tools (namely, Trunk).Steps to Reproduce
Reproducible two ways: With Trunk 0.21.2 and rust 1.82.0:
trunk build --release
Or, using rust 1.82.0, wasm-bindgen 0.2.95, and wasm-opt v116:
cargo build --target=wasm32-unknown-unknown --release --bin wasm_test_2024
wasm-bindgen --target=web --out-dir=target/wasm-bindgen/release --out-name=wasm_test_2024 target/wasm32-unknown-unknown/release/wasm_test_2024.wasm --no-typescript
wasm-opt -Oz target/wasm-bindgen/release/wasm_test_2024_bg.wasm --output wasm-opt.out
The failure can't be reproduced with rust 1.81.0.
Expected Behavior
No
table.fill
instructions.Trunk's bundled
wasm-opt
can't handle them (and doesn't yet support the CLI changes needed to enable bulk-memory in wasm-opt >= v117).Actual Behavior
wasm-opt
(version 116, as bundled by Trunk) fails with:I am informed that this means that
wasm-bindgen
emittedtable.fill
instructions.Additional Context
I expect this is a duplicate issue, because the
wasm-bindgen
main branch seems to work, presumably because #4237 solved this? (the changlelog entry says Only emittable.fill
instructions if the bulk-memory proposal is enabled.)I wanted to write this up anyway because I didn't see my failure symptom described in any current issues, and wanted to ensure that I was correctly understanding the problem and its solution (can we get the fix in a new release?)
(Related issue in Trunk repo)