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

Issue with features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, bulk-memory-opt in wasm2js and wasm-dis #7228

Open
CreatorEdition opened this issue Jan 18, 2025 · 1 comment

Comments

@CreatorEdition
Copy link

CreatorEdition commented Jan 18, 2025

When converting a WebAssembly module using wasm2js, I encountered an error related to the features section of the module. The module includes advanced WebAssembly features such as mutable-globals, bulk-memory, and sign-ext. Despite attempts to optimize or strip these features using wasm-opt, the error persists.

The error message is as follows:

;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, bulk-memory-opt Fatal: error in validating wasm2js output

;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, bulk-memory-opt in after use wasm-dis in file

Steps to Reproduce

  1. Use the following WebAssembly file (or a similar file with advanced features):

  2. Run the following commands:```bash
    wasm-opt input.wasm --strip-debug --strip-producers --disable-mutable-globals --disable-bulk-memory -o optimized.wasm -O2
    wasm2js optimized.wasm -o output.js

3.Observe the error related to the features section.

Actual Behavior

The conversion process fails with a validation error, even after attempting to strip or disable advanced WebAssembly features using wasm-opt.

Environment

Tool version: Binaryen 121
Command line used: wasm2js, wasm-opt
OS: win11

Additional Context

I have attempted the following solutions:

Stripping debug and producer sections using wasm-opt.
Disabling specific features like mutable-globals and bulk-memory during optimization.
Re-generating the WebAssembly file with minimal features.
The issue persists even when using the latest version of Binaryen.

Suggested Improvement

Enhance wasm2js to either skip unsupported features or convert as much as possible while issuing warnings.
Provide better documentation or guidance for handling advanced WebAssembly features in wasm2js.

@kripken
Copy link
Member

kripken commented Jan 18, 2025

I have attempted the following solutions: Re-generating the WebAssembly file with minimal features.

That should work. If it does not then something else is going on rather than features. Make sure that you are emitting a wasm file without those features.

In general, wasm2js is meant to support very old browsers and runtimes, places without wasm. Those places will not benefit from newer wasm features like sign-ext, so wasm2js does not support them.

Note that there are some lowering passes you can run before wasm2js, that can help in some cases: --llvm-memory-copy-fill-lowering, --llvm-nontrapping-fptoint-lowering, --signext-lowering, but they have limitations. It is best to just not emit the features, if you will be running wasm2js.

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