wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

wasm-opt fails when using WASM_INTERFACE_TYPES=1

Open JesterOrNot opened this issue 5 years ago • 13 comments

🐛 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

JesterOrNot avatar Feb 16 '20 14:02 JesterOrNot

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

Pauan avatar Feb 16 '20 16:02 Pauan

No

JesterOrNot avatar Feb 16 '20 16:02 JesterOrNot

The function I'm using is https://github.com/bytecodealliance/wasmtime-demos/blob/master/markdown/src/lib.rs

JesterOrNot avatar Feb 16 '20 16:02 JesterOrNot

Try running the function with WASM_INTERFACE_TYPES=1 in the example repo

JesterOrNot avatar Feb 16 '20 16:02 JesterOrNot

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

Pauan avatar Feb 16 '20 17:02 Pauan

Just looked through it. But if that was the case it should be fixed right?

JesterOrNot avatar Feb 16 '20 17:02 JesterOrNot

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.

ratnadeep007 avatar Feb 22 '20 09:02 ratnadeep007

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

MattesWhite avatar Jul 27 '20 13:07 MattesWhite

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.

jrheard avatar Aug 27 '20 04:08 jrheard

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.

PiepsC avatar Sep 09 '20 15:09 PiepsC

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)

temasictfic avatar Dec 16 '20 18:12 temasictfic

[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:

  1. upgrading to npm:[email protected], or
  2. downgrading rust (in my case I tried toolchain 1.78.0-aarch64-apple-darwin), or
  3. setting wasm-opt = false

bcheidemann avatar Feb 27 '25 18:02 bcheidemann

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!

SeedyROM avatar May 20 '25 04:05 SeedyROM