-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Duplicate definitions for enums in generated bindings #483
Comments
Thanks for the report! This is a bug due to the recent LLVM upgrade. This is specifically a bug internally with LLVM's handling of multiple codegen units. I'm gonna try to get a fix upstream into LLVM (or work around this locally ourselves). In any case, a workaround for now is: # at the bottom of Cargo.toml
[profile.release]
codegen-units = 1 and that should do the trick! |
I've filed https://bugs.llvm.org/show_bug.cgi?id=38184 for the upstream LLVM report. I'll submit a local fix to wasm-bindgen shortly |
This commit adds a hack to the `wasm-bindgen` CLI tool to work around rustwasm#483 which is present on nightly Rust with the recent LLVM upgrade. Hopefully this'll carry us forward until the [upstream bug][1] is fixed. Closes rustwasm#483 [1]: https://bugs.llvm.org/show_bug.cgi?id=38184
When a
wasm_bindgen
annotated enumeration is defined in a module, any item from that module is used somewhere else in a crate, and crate was compiled in release mode, thenwasm-bindgen
generates JS constant for that enumeration once for definition, plus once for every other module where an item from the same module as enum is used. This does not happen when compiled in debug mode.Last tested on 2018-07-16, commit 1d3e8f4.
Reduced test case
Cargo.toml
src/lib.rs
lib/module.rs
When compiled in release mode
wasm-bindgen
outputs the followingNote that
export const Enum
appears twice. When a third module containing a function returningStruct
was added,export const Enum
appeared three times. When compiled in release modeexport const Enum
appears only once, regardless of number of modules.The text was updated successfully, but these errors were encountered: