Repository navigation
Closed
Labels
-Zfixed-x18Unstable option: -Zfixed-x18Unstable option: -Zfixed-x18A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)Area: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
git clone https://github.com/OISF/suricata.git
cd suricata
export RUSTFLAGS="-Zinstrument-coverage"
sh autogen.sh
./configure --disable-shared --enable-fuzztargets --disable-gccmarch-native --enable-debug-validation
make
This ends up running cargo build --release -Z build-std
I expected to see this happen:
Compilation succeeds
Instead, this happened:
Compilation failed with
Updating crates.io index
Compiling core v0.0.0 (/Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error[E0152]: found duplicate lang item `f32`
--> /Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/f32.rs:319:1
|
319 | / impl f32 {
320 | | /// The radix or base of the internal representation of `f32`.
321 | | #[stable(feature = "assoc_int_consts", since = "1.43.0")]
322 | | pub const RADIX: u32 = 2;
... |
937 | | }
938 | | }
| |_^
|
= note: the lang item is first defined in crate `core`.
= note: first definition in `core` loaded from /Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-e3cd79f6ad1173fd.rlib
= note: second definition in the local crate (`core`)
and many more errors about other duplicate items
Meta
This is part of #34701 cc @richkadel
rustc --version --verbose:
rustc 1.50.0-nightly (603ab5bd6 2020-11-15)
binary: rustc
commit-hash: 603ab5bd6e0ffefafa7411cd8bd23a6ca82bcff0
commit-date: 2020-11-15
host: x86_64-apple-darwin
release: 1.50.0-nightly
Backtrace
Updating crates.io index
Compiling core v0.0.0 (/Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
error[E0152]: found duplicate lang item `f32`
--> /Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/f32.rs:319:1
|
319 | / impl f32 {
320 | | /// The radix or base of the internal representation of `f32`.
321 | | #[stable(feature = "assoc_int_consts", since = "1.43.0")]
322 | | pub const RADIX: u32 = 2;
... |
937 | | }
938 | | }
| |_^
|
= note: the lang item is first defined in crate `core`.
= note: first definition in `core` loaded from /Users/catena/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-e3cd79f6ad1173fd.rlib
= note: second definition in the local crate (`core`)
Reacted by Inflation and Brian Smith
Metadata
Metadata
Assignees
Labels
-Zfixed-x18Unstable option: -Zfixed-x18Unstable option: -Zfixed-x18A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)Area: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
catenacyber commentedon Nov 25, 2020
By the way, there is a current PR OISF/suricata#5582 with a fix : not using
-Z build-stdwhen-Zinstrument-coverageis in RUSTFLAGSrichkadel commentedon Dec 3, 2020
@catenacyber - Thanks for the bug report!
I did some experimenting (briefly), and I can repro this issue, for instance, with:
RUSTFLAGS="-Zinstrument-coverage" cargo build --release -Z build-std --target x86_64-unknown-linux-gnuI don't fully understand how
-Z build-stdworks, but from the error messages, it looks like the compiler may have built a new version of thestdlibrary (as intended), and then the compiler uses that new version but also (?) loads another version ofstd(or two versions ofcore).One copy loads the standard
LangItems, and the second copy also tries to load them but fails because they were already loaded.(This is a minimually-educated guess, from the error messages.)
Anyhow, I don't think
-Zinstrument-coveragewould be doing anything specifically to cause this problem, so I thought, maybe it's not specific to-Zinstrument-coverage.So I tried:
RUSTFLAGS="-Zprofile" cargo build --release -Z build-std --target x86_64-unknown-linux-gnuSure enough, I get the same errors.
Since
cargo -Z build-stdis also an "experimental" feature, I would redirect this issue to thebuild-stdfeature experts, to see if they can figure out why some compiler options (like-Zinstrument-coverageand-Zprofile) conflict in this way.Note, both
-Z instrument-coverageand-Z profiledo have a dependency on theprofiler_builtinslibrary inrust/library, so one place they might look is where theprofiler_builtinslibrary gets loaded. Maybe it's forcing the defaultstdlibrary to load, as a direct dependency ofprofiler_builtins, rather than using thestdthat was just built.catenacyber commentedon Dec 3, 2020
Indeed, I do not know which experimental feature should fix this.
So, please redirect this report how you see fit 👍
richkadel commentedon Dec 3, 2020
@alexcrichton - Is
cargo -Z build-stdsomething you would be familiar with? Or if not, do you know who might be? (Thanks!)alexcrichton commentedon Dec 3, 2020
I believe the
profiler_builtinscrate is the key here. Using-Zbuild-stdbuilds a fixed set of crates andprofiler_builtinsis not included in that set. This would probably be an issue for https://github.com/rust-lang/wg-cargo-std-aware/issues since I don't think there's much rust-lang/rust can do here for this.richkadel commentedon Dec 3, 2020
@catenacyber - Would you mind copy/pasting your issue into that list (perhaps just linking back to here for context if helpful)?
Thanks!
taiki-e commentedon Jul 12, 2023
@rustbot label +A-code-coverage
Enselic commentedon Nov 21, 2024
@rustbot claim
For me the fix in #133300 makes this work. See the PR for detailed instructions.
Rollup merge of rust-lang#133300 - Enselic:build-std-instrument-cover…
Unrolled build for rust-lang#133300
Enselic commentedon Nov 28, 2024
Fixed by #133369