Closed
Description
llvm-cov
refuses to load coverage data for this code when running rustc
with optimizations enabled:
fn bar() {
loop {}
}
pub trait Trait {
fn foo(&self) {
bar();
}
}
impl Trait for u8 {}
fn main() {
println!("hi")
}
Here's how I'm generating the coverage data:
#!/bin/sh
LLVM_TOOLCHAIN=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/
rm -rf main target default.profdata default.profraw
# RUSTFLAGS="-Z instrument-coverage" cargo run --verbose --release
rustc main.rs -O -o main -Z instrument-coverage
./main
$LLVM_TOOLCHAIN/llvm-profdata merge -sparse default.profraw -o default.profdata
$LLVM_TOOLCHAIN/llvm-cov show --instr-profile=default.profdata main
And what I'm observing:
+ rustc main.rs -O -o main -Z instrument-coverage
+ ./main
hi
+ /home/mrmaxmeier/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin//llvm-profdata merge -sparse default.profraw -o default.profdata
+ /home/mrmaxmeier/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin//llvm-cov show --instr-profile=default.profdata main
error: main: Failed to load coverage: Malformed instrumentation profile data
rustc --version --verbose
:
rustc 1.50.0-nightly (c919f490b 2020-11-17)
binary: rustc
commit-hash: c919f490bbcd2b29b74016101f7ec71aaa24bdbb
commit-date: 2020-11-17
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
cc @richkadel #79121