Skip to content

fix(ci): force rust to use legacy symbol mangling#253

Merged
Akinator31 merged 1 commit intomainfrom
252-disable-v0-mangling-from-wasm-bindgen-to-avoid-duplicated-symbols
Nov 25, 2025
Merged

fix(ci): force rust to use legacy symbol mangling#253
Akinator31 merged 1 commit intomainfrom
252-disable-v0-mangling-from-wasm-bindgen-to-avoid-duplicated-symbols

Conversation

@Akinator31
Copy link
Copy Markdown
Member

Problem

The CI was failing during the frontend WASM build with the following error:

Uncaught SyntaxError: Identifier
'wasm_bindgen_4f453e33dd9327c9___convert__closures________invoke___web_sys_a88f6bde22b957e9___features__gen_Event__Event_____'
has already been declared

This error indicates that a JavaScript identifier is declared twice in the code generated by wasm-bindgen.

Root Cause

The project uses Rust nightly (see rust-toolchain.toml), which enables the new v0 symbol mangling scheme by default.

The problem occurs during the following transformation chain:

  1. Rust compiles the code with v0 mangling → generates unique WASM symbols
  2. wasm-bindgen processes the WASM and uses rustc-demangle to convert symbols into JavaScript names
  3. rustc-demangle doesn't handle v0 mangling correctly → two different symbols (e.g., closures with Fn vs FnMut) are
    demangled to the same JavaScript name
  4. The final JS contains duplicate identifiersSyntaxError

This issue is documented in wasm-bindgen issue #4820: wasm-bindgen/wasm-bindgen#4820

Solution

Force Rust to use legacy symbol mangling (instead of v0) by adding the following RUSTFLAGS during frontend builds:

env:
  RUSTFLAGS: '-Csymbol-mangling-version=legacy -Zunstable-options'

Legacy mangling is properly supported by rustc-demangle, thus avoiding name collisions.

Changes

  • Added RUSTFLAGS in .github/workflows/release-ci.yml to both frontend build steps:
    • build_and_test job (pre-release tests)
    • upload-assets job (release binaries build)

Notes

This solution is a temporary workaround until rustc-demangle and wasm-bindgen properly support v0 mangling. We can remove these flags once issue #4820 is resolved.

References

@Akinator31 Akinator31 linked an issue Nov 25, 2025 that may be closed by this pull request
@Akinator31 Akinator31 self-assigned this Nov 25, 2025
@Akinator31 Akinator31 merged commit 463f326 into main Nov 25, 2025
6 checks passed
@Akinator31 Akinator31 deleted the 252-disable-v0-mangling-from-wasm-bindgen-to-avoid-duplicated-symbols branch November 25, 2025 12:39
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

Successfully merging this pull request may close these issues.

Disable v0 mangling from wasm-bindgen to avoid duplicated symbols

1 participant