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

Support code-coverage #63

Open
catenacyber opened this issue Dec 3, 2020 · 4 comments
Open

Support code-coverage #63

catenacyber opened this issue Dec 3, 2020 · 4 comments
Labels
plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. S-needs-design Status: needs design work

Comments

@catenacyber
Copy link

Reported first in rust-lang/rust#79401

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
cd rust
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 rust-lang/rust#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`)

@Amanieu
Copy link
Member

Amanieu commented Jan 26, 2021

I am successfully using -Z build-std and -Z instrument-coverage in my codebase. Can you double-check if this is still an issue in your case?

@catenacyber
Copy link
Author

Can you double-check if this is still an issue in your case?

Failed with rustc 1.50.0-nightly (603ab5bd6 2020-11-15) and again after running dustup update and using rustc 1.51.0-nightly (d1aed50ab 2021-01-26)

I use RUSTFLAGS="-Zinstrument-coverage" instead of -Z instrument-coverage cargo build -Z build-std -Z instrument-coveragefails witherror: unknown -Z flag specified: instrument-coverage`

@saethlin
Copy link
Member

saethlin commented Mar 8, 2022

I can reproduce this problem with the default bin crate.

cargo new --bin scratch
cd scratch
RUSTFLAGS=-Cinstrument-coverage cargo build -Zbuild-std --target=x86_64-unknown-linux-gnu

My rustc is

rustc 1.61.0-nightly (38a0b81b1 2022-03-06)
binary: rustc
commit-hash: 38a0b81b1c32764d6a583a5efb6f306b8c44c503
commit-date: 2022-03-06
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

@Amanieu I'm very curious to know what you're doing that makes this work.

@Amanieu
Copy link
Member

Amanieu commented Mar 16, 2022

I looked into this: the reason it works for me is that I use -Zno-profiler-runtime and instead use minicov as the profiler runtime.

@ehuss ehuss changed the title Incompatibility using both -Zinstrument-coverage and -Z build-std Support code-coverage May 3, 2023
@ehuss ehuss added plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. S-needs-design Status: needs design work labels May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan before stabilization This needs a plan for how to address before stabilization, but does not need to be implemented. S-needs-design Status: needs design work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants