Strange linker error
Closed this issue · 3 comments
I get some strange linker errors when compiling with cargo test --all
:
Then I run cargo test --all
again and I get this:
error[E0460]: found possibly newer version of crate `tp_client` which `circle_game` depends on
--> circle_game/src/main.rs:5:19
|
5 | let mut app = circle_game::configure_app();
| ^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
crate `tp_client`: /unencrypted/tp/platform/target/debug/deps/libtp_client.rlib
crate `circle_game`: /unencrypted/tp/platform/target/debug/deps/libcircle_game.rlib
error: could not compile `circle_game` due to previous error
circle_game
is a crate that depends on the tp_client
crate which uses safer-ffi
. circle_game
does not use safer-ffi
at all.
Cargo version: cargo 1.63.0-nightly (38472bc19 2022-05-31)
OS: Ubuntu 20.04.4 on Windows 11 via WSL2
The error is non-deterministic btw, If I cargo clean and then cargo test --all, sometimes it happens and sometimes it doesnt'
Interesting; I think I've managed to run, in the past, into similar things myself, so definitely something I have had on my radar:
-
I strongly suspect this is caused by having n Rust (r)
lib
rary such astp_client
also have thecdylib
and/orstaticlib
crate-type
s. Starting with Rust 1.61.0, there arenightly
/RUSTC_BOOTSTRAP=1
ways to get compilations to use the specificcdylib
/staticlib
types, without having to touch theCargo.toml
in the general case.That is, you could tweak
tp_client
as follows:# Cargo.toml [lib] - crate-type = ["rlib", "cdylib", "staticlib"]
# To compile `tp_client` as a C lib: RUSTC_BOOTSTRAP=1 \ cargo rustc --crate-type=staticlib # --release # or --crate-type=cdylib
- Tracking issue: rust-lang/cargo#10083
Other than that, safer-ffi
can't really help more; this is a Cargo / Rust bug; feel free to report it there: https://github.com/rust-lang/cargo/issues (see also stuff such as rust-lang/rust#82151)