tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

WASM code that uses `__multi3` produces module that cannot be parsed by `wasm-opt`

Open flavio opened this issue 1 year ago • 5 comments

This is a follow up on issue https://github.com/tinygo-org/tinygo/issues/3501. The issue has been fixed with tinygo 0.29.0. However, the code linked as reproducer is still broken. This time the build fails during the optimization phase, when running wasm-opt.

The compilation fails with the following error:

[parse exception: invalid function index (at 0:33795)]

This happens when building with the following Tinygo docker images:

  • tinygo/tinygo:0.29.0
  • tinygo/tinygo:0.30.0

Both images ship with wasm-opt version 114. I've tried to use the latest version of wasm-opt (v116), but I got the same error.

UPDATE: this happens also with the latest version of tinygo (tinygo/tinygo:0.31.0), which contains wasm-opt version 116

Reproducer

I've updated the code inside of the original reproducer, it can be found inside of this GitHub repository.

flavio avatar Feb 05 '24 14:02 flavio

This is happening also with version 0.31.0. I've updated the reproduced to reflect that

flavio avatar Feb 27 '24 08:02 flavio

I found that #3844 was actually incorrect. I have fixed this locally, I'll make a PR soon.

aykevl avatar Mar 12 '24 20:03 aykevl

Here is the PR that fixes this issue: https://github.com/tinygo-org/tinygo/pull/4188. I can't confirm the output binary is correct, but at least it compiles.

aykevl avatar Mar 12 '24 21:03 aykevl

@aykevl good news, I've checked out the PR you linked above, built tinygo from scratch and then I successfully built and tested the real code (not the small reproducer). The fix is working :partying_face:

flavio avatar Mar 13 '24 09:03 flavio

@flavio thanks for testing!

aykevl avatar Mar 13 '24 13:03 aykevl