Skip to content

Improve the documentation to explain usage of LLVM_PROFILE_FILE environment variable #595

@dbr

Description

@dbr

I did cargo new --bin covtest and modified src/main.rs to contain this:

fn main() {
    if std::env::args().len() > 1 {
        println!("Hello, world!");
    } else {
        println!("Nope");
    }
}

I then, to the best of my knowledge, followed the instructions in the README (as of cf5c0a7)

$ cargo +nightly install grcov # unsure if the +nightly part is necessary here, seemed same either way
$ rustup component add --toolchain nightly llvm-tools-preview
$ export RUSTFLAGS="-Zinstrument-coverage"
$ cargo +nightly build
$ cargo +nightly run --
$ wc default.profraw 
  0   3 272 default.profraw
$ grcov . -s . --binary-path ./target/debug/ -t html --branch -o ./target/debug/coverage/

However the resulting report target/debug/coverage/index.html contains an empty table, as if no source files are found:

$ tree target/debug/coverage/
target/debug/coverage/
└── index.html

0 directories, 1 file

If I use the -Zprofile based, I do get output:

$ export CARGO_INCREMENTAL=0
$ export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
$ export RUSTDOCFLAGS="-Cpanic=abort"
$ grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
$ tree target/debug/coverage/
target/debug/coverage/
├── index.html
└── src
    ├── index.html
    └── main.rs.html

1 directory, 3 files
$ rustc +nightly --version
rustc 1.52.0-nightly (94736c434 2021-02-27)
$ grcov --version
grcov 0.7.1

..and this is on Debian Buster. Not sure what other information might be relevant - let me know if there's any other details I can provide. Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions