Closed notdanilo closed 10 months ago
Thanks for the report! I'd recommend using Cargo's [patch]
feature if you'd like to use a different version of wasm-bindgen crates. You may need to [patch]
more than just one crate, however, since there's a family of crates with wasm-bindgen.
Thanks for the quick response. Would the patching still be necessary to build the crate locally even if I don't have any changes applied to it? I am trying to build a clean repo clone.
Quick update:
cargo clean
seemed to fix it.wasm-pack test --chrome
with the stable toolchain fails because of the use of #![feature]
so I switched to nightly. = note: rust-lld: error: duplicate symbol: __wbindgen_malloc
>>> defined in /home/notdanilo/dev/notdanilo/cross-test/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-52008e5452425f47.rlib(wasm_bindgen-52008e5452425f47.2udpmmivwxjrkfyb.rcgu.o)
>>> defined in /home/notdanilo/dev/notdanilo/cross-test/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-24ecc61ab227544e.rlib(wasm_bindgen-24ecc61ab227544e.wasm_bindgen.bz7yl1pq-cgu.15.rcgu.o)
rust-lld: error: duplicate symbol: __wbindgen_free
>>> defined in /home/notdanilo/dev/notdanilo/cross-test/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-52008e5452425f47.rlib(wasm_bindgen-52008e5452425f47.2udpmmivwxjrkfyb.rcgu.o)
>>> defined in /home/notdanilo/dev/notdanilo/cross-test/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-24ecc61ab227544e.rlib(wasm_bindgen-24ecc61ab227544e.wasm_bindgen.bz7yl1pq-cgu.15.rcgu.o)
It looks like [patch]
may not have patched everything? That looks like there's still two versions of the wasm-bindgen
crate itself being linked in. Perhaps a missing patch
entry for wasm-bindgen itself?
@alexcrichton the deal is I am not patching anything yet. Shouldn't crates/test
be buildable with a clean repo?
Unfortunately using wasm-pack
in this repo itself will not work due to how wasm-pack
works.
@alexcrichton what would be the suggested way to use a modified version of wasm-bindgen-test
?
In case you are curious why I need it so much:
I am creating a cross-test
crate that re-exports platform specific test frameworks because it is really annoying to create target cfgs on every project.
To make wasm-bindgen-test
re-exportable, it seems that I need to rework some type paths. I might create a PR for it if the solution doesn't get too hacky.
If you're editing in-tree you can use cargo test --target wasm32-unknown-unknown
and it should work
@alexcrichton that's not exactly what I am looking for. I want to be able to use a modified version of wasm-bindgen-test
as a dependency just like how an end-user would use it in the project Cargo.toml
and then run the tests with wasm-pack test
.
I can't find anything in the docs explaining how to do that.
It's unfortunately not really well documented, but you'll need to compile a local version of wasm-bindgen-test
(sibling to the wasm-bindgen
binary) and then set that as the test runner for the wasm target through Cargo to execute tests. Basically you need to do what wasm-pack does, except manually to specify your own version of the binary.
I'm also struggling to just include wasm-bindgen
itself on my project, after cloning it locally and adding it via path on my Cargo.toml. I would like to extend RefFromWasmAbi
some traits for more complex types, see this Rust Discord thread for more context and its followup:
(...)
# WASM
getrandom = { version = "0.2", features = ["js"] }
#wasm-bindgen = { version = "0.2", features = ["enable-interning"] }
wasm-bindgen = { path = "../wasm-bindgen" }
(...)
I'm getting:
crypt4gh-rust % cargo build --target wasm32-unknown-unknown
error: failed to select a version for `wasm-bindgen-shared`.
... required by package `wasm-bindgen-macro-support v0.2.62`
... which satisfies dependency `wasm-bindgen-macro-support = "=0.2.62"` of package `wasm-bindgen-macro v0.2.62`
... which satisfies dependency `wasm-bindgen-macro = "=0.2.62"` of package `wasm-bindgen v0.2.62`
... which satisfies dependency `wasm-bindgen = "^0.2.62"` of package `getrandom v0.2.11`
... which satisfies dependency `getrandom = "^0.2"` (locked to 0.2.11) of package `crypt4gh v0.4.1 (/Users/rvalls/dev/umccr/crypt4gh-rust)`
versions that meet the requirements `=0.2.62` are: 0.2.62
the package `wasm-bindgen-shared` links to the native library `wasm_bindgen`, but it conflicts with a previous package which links to `wasm_bindgen` as well:
package `wasm-bindgen-shared v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/shared)`
... which satisfies path dependency `wasm-bindgen-shared` (locked to 0.2.89) of package `wasm-bindgen-macro-support v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/macro-support)`
... which satisfies path dependency `wasm-bindgen-macro-support` (locked to 0.2.89) of package `wasm-bindgen-macro v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/macro)`
... which satisfies path dependency `wasm-bindgen-macro` (locked to 0.2.89) of package `wasm-bindgen v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen)`
... which satisfies path dependency `wasm-bindgen` (locked to 0.2.89) of package `crypt4gh v0.4.1 (/Users/rvalls/dev/umccr/crypt4gh-rust)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='wasm-bindgen-shared' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.
failed to select a version for `wasm-bindgen-shared` which could resolve this conflict
And when I try to trace the crate having a differing getrandom
crate, I'm getting misleading output in cargo tree
from the workspace level since it just outputs a very small subset of dependencies and not the whole tree for all the sub-crates:
% cargo tree
wasm-bindgen v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen)
├── cfg-if v1.0.0
└── wasm-bindgen-macro v0.2.89 (proc-macro) (/Users/rvalls/dev/umccr/wasm-bindgen/crates/macro)
├── quote v1.0.35
│ └── proc-macro2 v1.0.75
│ └── unicode-ident v1.0.12
└── wasm-bindgen-macro-support v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/macro-support)
├── proc-macro2 v1.0.75 (*)
├── quote v1.0.35 (*)
├── syn v2.0.48
│ ├── proc-macro2 v1.0.75 (*)
│ ├── quote v1.0.35 (*)
│ └── unicode-ident v1.0.12
├── wasm-bindgen-backend v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/backend)
│ ├── bumpalo v3.14.0
│ ├── log v0.4.20
│ ├── once_cell v1.19.0
│ ├── proc-macro2 v1.0.75 (*)
│ ├── quote v1.0.35 (*)
│ ├── syn v2.0.48 (*)
│ └── wasm-bindgen-shared v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/shared)
└── wasm-bindgen-shared v0.2.89 (/Users/rvalls/dev/umccr/wasm-bindgen/crates/shared)
I guess that the cargo [patch]
strategy described above doesn't help me here as I want to modify/contribute to wasm-bindgen, so I need a local path?
What am I doing wrong here and how can I fix that (getrandom
?) dependency error? :-S
Summary
I am trying to directly use the
wasm-bindgen-test
crate because I want to make some changes in it.But I am getting this error when I build it: