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-bindgen >= 0.2.94 generates undesired table.fill instructions when used with rust 1.82.0 #4250

Closed
eric-seppanen opened this issue Nov 5, 2024 · 3 comments
Labels

Comments

@eric-seppanen
Copy link
Contributor

Describe the Bug

When using rust 1.82.0 and wasm-bindgen 0.2.94 or 0.2.95, builds fail because the wasm-bindgen output includes table.fill instructions that are poorly supported by downstream tools (namely, Trunk).

Steps to Reproduce

Reproducible two ways:
With Trunk 0.21.2 and rust 1.82.0:

  1. Using the partially-minimized repo https://github.com/eric-seppanen/wasm_test_2024
  2. trunk build --release

Or, using rust 1.82.0, wasm-bindgen 0.2.95, and wasm-opt v116:

  1. Using the partially-minimized repo https://github.com/eric-seppanen/wasm_test_2024
  2. cargo build --target=wasm32-unknown-unknown --release --bin wasm_test_2024
  3. wasm-bindgen --target=web --out-dir=target/wasm-bindgen/release --out-name=wasm_test_2024 target/wasm32-unknown-unknown/release/wasm_test_2024.wasm --no-typescript
  4. wasm-opt -Oz target/wasm-bindgen/release/wasm_test_2024_bg.wasm --output wasm-opt.out

The failure can't be reproduced with rust 1.81.0.

Expected Behavior

No table.fill instructions.

Trunk's bundled wasm-opt can't handle them (and doesn't yet support the CLI changes needed to enable bulk-memory in wasm-opt >= v117).

Actual Behavior

wasm-opt (version 116, as bundled by Trunk) fails with:

[parse exception: invalid code after misc prefix: 17 (at 0:20646)]

I am informed that this means that wasm-bindgen emitted table.fill instructions.

Additional Context

I expect this is a duplicate issue, because the wasm-bindgen main branch seems to work, presumably because #4237 solved this? (the changlelog entry says Only emit table.fill instructions if the bulk-memory proposal is enabled.)

I wanted to write this up anyway because I didn't see my failure symptom described in any current issues, and wanted to ensure that I was correctly understanding the problem and its solution (can we get the fix in a new release?)

(Related issue in Trunk repo)

@insipx
Copy link

insipx commented Nov 7, 2024

Ran into this issue, and fixed by using an up-to-date wasm-opt. You can use the one on npmjs or install the one from the binaryen repo. wasm-opt on nixpkgs also works

wasm-opt from crates.io is not updated as often, so sometimes lacks more recent features

@eric-seppanen
Copy link
Contributor Author

eric-seppanen commented Nov 7, 2024

While this is true, it's not practical with Trunk. Newer versions (117+) of wasm-opt require the CLI flag --enable-bulk-memory to be able to operate on these files, and Trunk currently does not have the ability to set the wasm-opt parameters that are used. (edit: Trunk 0.21.3 added this ability.)

Since this issue (unexpectedly enabling bulk-memory instructions) has already been fixed on master, all that is needed for wasm-bindgen to cut a new release.

@daxpedda
Copy link
Collaborator

daxpedda commented Nov 9, 2024

Indeed, this has been addressed by #4237 and I plan to make a new release soon.

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

No branches or pull requests

3 participants