wasm-pack
wasm-pack copied to clipboard
wasm-opt fails when using WASM_INTERFACE_TYPES=1
🐛 Bug description
The webassembly breaks when I have wasm-opt on
I am able to get around the error when I add
[package.metadata.wasm-pack.profile.dev]
wasm-opt = true
[package.metadata.wasm-pack.profile.release]
wasm-opt = true
But It should work even if I add the optimizations.
🤔 Expected Behavior
It still compiles when I use the optimizations
👟 Steps to reproduce
https://github.com/JesterOrNot/markdown_wasi/tree/bug
Run make and see the error
🌍 Your environment
Open in the browser https://gitpod.io/#https://github.com/JesterOrNot/markdown_wasi/tree/bug Include the relevant details of your environment. Gitpod Cloud IDE based on ubuntu docker wasm-pack version: 0.9.1 rustc version: 1.4.1
To clarify, does it work correctly if you don't use WASM_INTERFACE_TYPES=1?
No
The function I'm using is https://github.com/bytecodealliance/wasmtime-demos/blob/master/markdown/src/lib.rs
Try running the function with WASM_INTERFACE_TYPES=1 in the example repo
If it's still erroring even when not using WASM_INTERFACE_TYPES=1, then this sounds similar to https://github.com/rustwasm/wasm-pack/issues/696
Just looked through it. But if that was the case it should be fixed right?
Same error here also. Trying to follow tutorial and got this error.
[parse exception: Only 1 table definition allowed in MVP (at 0:417)]
Fatal: error in parsing input
Error: failed to execute `wasm-opt`: exited with exit code: 1
full command: "/Users/ratnadeep/Library/Caches/.wasm-pack/wasm-opt-a528729925722b63/wasm-opt" "/Users/ratnadeep/personal/wasm/markdowm/pkg/markdowm.wasm" "-o" "/Users/ratnadeep/personal/wasm/markdowm/pkg/markdowm.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.
Also tried adding:
[package.metadata.wasm-pack.profile.dev]
wasm-opt = true
[package.metadata.wasm-pack.profile.release]
wasm-opt = true
Still it doesn't compile. Also tried adding wasm-opt from npm still failing. When not using WASM_INTERFACE_TYPES=1 its still failing. Only way around is to add:
[package.metadata.wasm-pack.profile.release]
wasm-opt = false
Hope this issue resolves soon.
Has there been any progress on this issue in the meantime? I also face the error:
> WASM_INTERFACE_TYPES=1 wasm-pack build
...
[parse exception: Only 1 table definition allowed in MVP (at 0:448)]
And therefore can't run the wasm using wasmtime.
The suggested editing of [package.metadata.wasm-pack.profile.release] didn't worked for me.
> rustc --version
rustc 1.45.0 (5c1f21c3b 2020-07-13)
> wasm-pack --version
wasm-pack 0.9.1
> wasm-opt --version
wasm-opt version 91
> wasmtime --version
wasmtime 0.19.0
I'm encountering the same issue that @ratnadeep007 describes when working through https://rustwasm.github.io/docs/book/game-of-life/implementing.html . The wasm-opt = false workaround resolves the issue, but it definitely feels like something's broken.
For me this could also be prevented by downgrading from the current 0.9.2 to 0.8.1 as described in #782.
cargo install wasm-pack --version 0.8.1
I ran into the same issue on x64 Arch and Windows.
In the game of life example render function causing this error which returns String. If you use canvas api, no need for this function and fmt::Display implementation. After that wasm-opt worked as expected. (wasm-pack version 0.9.1)
[parse exception: Only 1 table definition allowed in MVP (at 0:417)] Fatal: error in parsing input Error: failed to execute
wasm-opt: exited with exit code: 1 full command: "/Users/ratnadeep/Library/Caches/.wasm-pack/wasm-opt-a528729925722b63/wasm-opt" "/Users/ratnadeep/personal/wasm/markdowm/pkg/markdowm.wasm" "-o" "/Users/ratnadeep/personal/wasm/markdowm/pkg/markdowm.wasm-opt.wasm" "-O"
I was getting this same error with latest stable rust 1.82.0-aarch64-apple-darwin and npm:[email protected].
I was able to resolve this issue by:
- upgrading to
npm:[email protected], or - downgrading rust (in my case I tried toolchain
1.78.0-aarch64-apple-darwin), or - setting
wasm-opt = false
A good idea is to run which wasm-opt and see where it's installed, then check when it was installed. In my case I had an ancient wasm-opt version installed by some unknown tool. So I removed it and it was able to find the correct binary. See here!