Skip to content
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

Strange linker error #119

Closed
TheButlah opened this issue Jun 3, 2022 · 3 comments
Closed

Strange linker error #119

TheButlah opened this issue Jun 3, 2022 · 3 comments
Labels
K-bug Kind: existing code isn’t behaving as expected M-wontfix-out-of-scope Marker: genuine issues which, alas, are beyond the scope of safer-ffi

Comments

@TheButlah
Copy link
Contributor

TheButlah commented Jun 3, 2022

I get some strange linker errors when compiling with cargo test --all:

_cargo_test__output.txt

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.

@TheButlah
Copy link
Contributor Author

Cargo version: cargo 1.63.0-nightly (38472bc19 2022-05-31)
OS: Ubuntu 20.04.4 on Windows 11 via WSL2

@TheButlah
Copy link
Contributor Author

The error is non-deterministic btw, If I cargo clean and then cargo test --all, sometimes it happens and sometimes it doesnt'

@danielhenrymantilla danielhenrymantilla added the K-bug Kind: existing code isn’t behaving as expected label Jun 8, 2022
@danielhenrymantilla
Copy link
Collaborator

danielhenrymantilla commented Jun 8, 2022

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)library such as tp_client also have the cdylib and/or staticlib crate-types. Starting with Rust 1.61.0, there are nightly / RUSTC_BOOTSTRAP=1 ways to get compilations to use the specific cdylib / staticlib types, without having to touch the Cargo.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

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)

@danielhenrymantilla danielhenrymantilla added the M-wontfix-out-of-scope Marker: genuine issues which, alas, are beyond the scope of safer-ffi label Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
K-bug Kind: existing code isn’t behaving as expected M-wontfix-out-of-scope Marker: genuine issues which, alas, are beyond the scope of safer-ffi
Projects
None yet
Development

No branches or pull requests

2 participants