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

[Bug] Unable compile optimized wasm file at old node.js version #142

Open
starua opened this issue Apr 9, 2023 · 2 comments
Open

[Bug] Unable compile optimized wasm file at old node.js version #142

starua opened this issue Apr 9, 2023 · 2 comments

Comments

@starua
Copy link

starua commented Apr 9, 2023

Version: wasm-opt version 112 (version_112)
Command args: -O4 -g
Node.js Version: v8.9.3

Got this error when calling WebAssembly.Module:

CompileError: WebAssembly.Module(): Compiling wasm function #318:loop failed: Invalid opcode @+122854
    at Object.<anonymous> (<Glue File>:695:20)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at repl:1:9
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)

Note that upgrade node.js or disable optimize can solve this error.

File Pack: pack.zip

Origin wasm file: binary.wasm
Optimized wasm file: binary.wasm-opt.wasm
wasm-opt binary archive: wasm-opt

@brson
Copy link
Owner

brson commented Apr 10, 2023

I am guessing this behavior exists upstream so it might help to test the build from https://github.com/WebAssembly/binaryen and file an issue with them.

The issue could be related to a change in binaryen 111 - by default binaryen now uses the sign-extension and mutable-globals features, which some runtimes might not support.

To test this you can try 2 things:

  • pass the --mvp-features flag to wasm-opt, which should turn off these two features
  • downgrade to wasm-opt 110

@starua
Copy link
Author

starua commented Apr 12, 2023

No, neither --mvp-features flag nor downgrade worked.

This is the optimized wasm file with version 110 & --mvp-features flag: binary.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants