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

multiple rlib candidates for compiler_builtins found #334

Closed
tomaka opened this issue Dec 24, 2019 · 9 comments
Closed

multiple rlib candidates for compiler_builtins found #334

tomaka opened this issue Dec 24, 2019 · 9 comments

Comments

@tomaka
Copy link

tomaka commented Dec 24, 2019

Sorry if this is not the right place to report this issue.

After upgrading to the latest nightly, my no_std project suddenly stopped compiling with this error:

error[E0465]: multiple rlib candidates for `compiler_builtins` found
  |
  = note: candidate #1: /home/pierre/Projets/os/target/arm-freestanding/release/deps/libcompiler_builtins-26c139968e75b8d8.rlib
  = note: candidate #2: /home/pierre/Projets/os/target/arm-freestanding/release/deps/libcompiler_builtins-1ff647597e07803f.rlib

error[E0463]: can't find crate for `compiler_builtins`

I'm following the instructions in README.md which ask you to add compiler_builtins as a dependency and add extern crate compiler_builtins;.

It seems that Rust indeed passes compiler_builtins twice when compiling the crate. Here's a fragment of the invocation of rustc:

--extern 'noprelude:compiler_builtins=/home/pierre/Projets/os/target/arm-freestanding/release/deps/libcompiler_builtins-1ff647597e07803f.rlib' --extern compiler_builtins=/home/pierre/Projets/os/target/arm-freestanding/release/deps/libcompiler_builtins-26c139968e75b8d8.rlib

Interestingly, if I do that in Cargo.toml:

compiler_builtins_under_a_different_name = { package = "compiler_builtins", git = "https://github.com/rust-lang/compiler-builtins" }

And then extern crate compiler_builtins_under_a_different_name;, then everything works fine on some platforms but gives linking errors for memcpy for memcmp on some others.

@bjorn3
Copy link
Member

bjorn3 commented Dec 24, 2019

Are you using -Zbuild-std? In that case, you should not add compiler_builtins as dependency yourself. cargo will build it automatically for you.

@tomaka
Copy link
Author

tomaka commented Dec 24, 2019

Are you using -Zbuild-std? In that case, you should not add compiler_builtins as dependency yourself. cargo will build it automatically for you.

Yes I'm using -Zbuild-std! I'm doing -Zbuild-std=core,compiler_builtins,alloc

Not adding compiler_builtins as a dependency leads to ld.lld: error: undefined symbol: memcmp.
(these linking errors are the reason I've added compiler_builtins as a dependency in the first place)

@bjorn3
Copy link
Member

bjorn3 commented Dec 24, 2019

It seems that the mem feature of compiler-builtins is not enabled by default. By the way compiler_builtins is enabled by default when core is enabled: https://github.com/rust-lang/cargo/blob/86134e7666a088682f20b76278c3ee096a315218/src/cargo/core/compiler/standard_lib.rs#L25-L27

@bjorn3
Copy link
Member

bjorn3 commented Dec 24, 2019

Rust actually pins 0.1.22 in Cargo.lock: https://github.com/rust-lang/rust/blob/f6dca76be55dd6bb8d0d7d3b6bc39ae8373db506/Cargo.lock#L571-L573. I wonder if -Zbuild-std uses Cargo.lock. If so, you may be able to edit it to use compiler-builtins 0.1.22.

@tomaka
Copy link
Author

tomaka commented Dec 24, 2019

(sorry, I deleted a comment in-between, as I realized what you said)

I think my issue is rust-lang/wg-cargo-std-aware#15 and rust-lang/wg-cargo-std-aware#28

I don't really understand why the compiler-builtins-mem feature of the alloc crate is disabled by default.
It is unconditionally enabled by Rust when compiling: https://github.com/rust-lang/rust/blob/a916ac22b9f7f1f0f7aba0a41a789b3ecd765018/src/bootstrap/compile.rs#L204

@alexcrichton
Copy link
Member

I think this is likely a bug with -Zbuild-std rather than this crate itself, so mind reopening this on the std-aware repository?

@tomaka
Copy link
Author

tomaka commented Jan 20, 2020

Reopened as rust-lang/wg-cargo-std-aware#53

@AthiraRamakrishna
Copy link

Hi

is there a solution for this already? I face a similar issue when building for a custom target with -Zbuild-std=core,alloc and providing compiler_builtins as dependency in Cargo.toml file.

Any help much appreciated. Thanks

@tgross35
Copy link
Contributor

@AthiraRamakrishna this has been closed for a long time. Could you open a new issue describing what you are trying and what problem you are experiencing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants