Description
🐛 Bug description
I am using wasm-pack
and wasm-bingen
to build a javascript package with rust.
Since today when I am running wasm-pack build
I am getting following error:
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Finished release [optimized + debuginfo] target(s) in 13.59s
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[wasm-validator error in module] unexpected true: Exported global cannot be mutable, on
global$0
# --- omitted .wast output ---
Fatal: error in validating input
Error: failed to execute `wasm-opt`: exited with exit code: 1
full command: "~/.cache/.wasm-pack/wasm-opt-4d7a65327e9363b7/wasm-opt" "$REPO/rav1e_js/pkg/rav1e_js_bg.wasm" "-o" "$REPO/rav1e_js/pkg/rav1e_js_bg.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.
It was still working on master yesterday (see CI), but doesn't anymore today with the same commit (see CI). (The important step is "Build").
🤔 Expected Behavior
Build package and optimize it with wasm-opt
as it did before.
(Running wasm-pack build --dev
works, but I'd like to have the optimization).
👟 Steps to reproduce
Trying a few things I figured out that I can make wasm-opt
pass when I am removing all exported (non-static) methods on the exported structs (which is abviously not desireable).
On urhengulas/rav1e@wasm-opt-fix I removed all the methods and it builds and optimizes fine:
➜ rav1e git:(wasm-opt-fix) ✗ cd rav1e_js && wasm-pack build
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Finished release [optimized + debuginfo] target(s) in 0.05s
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: :-) Done in 0.88s
[INFO]: :-) Your wasm pkg is ready to publish at /home/urhengulas/Documents/github.com/xiph/rav1e/rav1e_js/pkg.
But, as soon I am adding a method (e.g. fn Frame.debug(&self) -> Self
in rav1e_js/src/frame.rs
) back, I am getting the error from the bug description.
🌍 Your environment
Include the relevant details of your environment.
➜ rustc --version
rustc 1.45.0 (5c1f21c3b 2020-07-13)
➜ wasm-pack --version
wasm-pack 0.9.1
➜ ~/.cache/.wasm-pack/wasm-opt-4d7a65327e9363b7/wasm-opt --version
wasm-opt version_90
Thx
Thanks to everyone taking the time and having a look at this issue!