brson / wasm-opt-rs

Rust bindings for Binaryen's wasm-opt
Apache License 2.0
61 stars 10 forks source link

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

Open starua opened 1 year ago

starua commented 1 year ago

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 commented 1 year ago

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:

starua commented 1 year ago

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

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