Wasm-pack: wasm-opt fails when using WASM_INTERFACE_TYPES=1

Created on 16 Feb 2020  路  11Comments  路  Source: rustwasm/wasm-pack

馃悰 Bug description

The webassembly breaks when I have wasm-opt on
image
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

Most helpful comment

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.

All 11 comments

To clarify, does it work correctly if you don't use WASM_INTERFACE_TYPES=1?

No

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcoscaceres picture marcoscaceres  路  3Comments

rpjohnst picture rpjohnst  路  5Comments

turboladen picture turboladen  路  4Comments

xtuc picture xtuc  路  5Comments

rbtcollins picture rbtcollins  路  3Comments