Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
flavio opened this issue Feb 5, 2024 · 5 comments
Closed
Labels
wasm WebAssembly

Comments

@flavio
Copy link
Contributor

flavio commented Feb 5, 2024

This is a follow up on issue #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 added a commit to flavio/tinygo-wasi-symbol-bug that referenced this issue Feb 5, 2024
Update the code to reproduce a new issue, which is an evolution of the
initial one
@deadprogram deadprogram added the wasm WebAssembly label Feb 21, 2024
@flavio
Copy link
Contributor Author

flavio commented Feb 27, 2024

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

@aykevl
Copy link
Member

aykevl commented Mar 12, 2024

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

aykevl added a commit that referenced this issue Mar 12, 2024
The symbol table was generated incorrectly. The correct way is to use
the custom linking WebAssembly section, which I implemented in go-wasm
for this purpose.

This fixes #4114 and is a
prerequisite for #4176.
@aykevl
Copy link
Member

aykevl commented Mar 12, 2024

Here is the PR that fixes this issue: #4188.
I can't confirm the output binary is correct, but at least it compiles.

@flavio
Copy link
Contributor Author

flavio commented Mar 13, 2024

@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 🥳

@aykevl
Copy link
Member

aykevl commented Mar 13, 2024

@flavio thanks for testing!

aykevl added a commit that referenced this issue Mar 13, 2024
The symbol table was generated incorrectly. The correct way is to use
the custom linking WebAssembly section, which I implemented in go-wasm
for this purpose.

This fixes #4114 and is a
prerequisite for #4176.
deadprogram pushed a commit that referenced this issue Mar 18, 2024
The symbol table was generated incorrectly. The correct way is to use
the custom linking WebAssembly section, which I implemented in go-wasm
for this purpose.

This fixes #4114 and is a
prerequisite for #4176.
@deadprogram deadprogram added the next-release Will be part of next release label Mar 26, 2024
@deadprogram deadprogram removed the next-release Will be part of next release label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasm WebAssembly
Projects
None yet
Development

No branches or pull requests

3 participants