Skip to content

Commit 7b6731f

Browse files
committed
Move links annotation to wasm-bindgen-shared
This commit moves our `links` annotation in the `wasm-bindgen` crate to the `wasm-bindgen-shared` crate. The `links` annotation is used to ensure that there's only one version of `wasm-bindgen` in a crate graph because if there are multiple versions then a CLI surely cannot actually process the wasm binary (as the multiple versions likely have different formats in their custom sections). Discovered in #1373 it looks like the usage in `wasm-bindgen` isn't quite sufficient to cause this deduplication. It turns out that `wasm-bindgen-shared`, a very core dependency, is actually the most critical to be deduplicated since its the one that defines the format of the custom section. In #1373 a case came up where `wasm-bindgen` was deduplciated but there were two versions of `wasm-bindgen-shared` in the crate graph, meaning that a `[patch]` for only `wasm-bindgen` wasn't sufficient, but rather `web-sys` and/or `js-sys` also needed a `[patch]` annotation to ensure everyone used the right dependencies. This commit won't actually fix #1373 to the point where it "just works", but what it does do is present a better error message than an internal panic of `wasm-bindgen`. The hope is that by moving the `links` annotation we can catch more errors of this crate graph duplication, leading to more `[patch]` annotations locally. Closes #1373
1 parent d49d8c9 commit 7b6731f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name = "wasm-bindgen"
33
version = "0.2.39"
44
authors = ["The wasm-bindgen Developers"]
55
license = "MIT/Apache-2.0"
6-
# Because only a single `wasm_bindgen` version can be used in a dependency
7-
# graph, pretend we link a native library so that `cargo` will provide better
8-
# error messages than the esoteric linker errors we would otherwise trigger.
9-
links = "wasm_bindgen"
106
readme = "README.md"
117
categories = ["wasm"]
128
repository = "https://github.com/rustwasm/wasm-bindgen"

crates/shared/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ description = """
1010
Shared support between wasm-bindgen and wasm-bindgen cli, an internal
1111
dependency.
1212
"""
13+
14+
# Because only a single `wasm_bindgen` version can be used in a dependency
15+
# graph, pretend we link a native library so that `cargo` will provide better
16+
# error messages than the esoteric linker errors we would otherwise trigger.
17+
links = "wasm_bindgen"

0 commit comments

Comments
 (0)