3 The tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524).
5 ------------------------
7 This feature allows the generation of code coverage reports.
9 Set the `-Zprofile` compiler flag in order to enable gcov profiling.
13 cargo new testgcov --bin
15 export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
16 export CARGO_INCREMENTAL=0
21 Once you've built and run your program, files with the `gcno` (after build) and `gcda` (after execution) extensions will be created.
22 You can parse them with [llvm-cov gcov](https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/mozilla/grcov).
24 Please note that `RUSTFLAGS` by default applies to everything that cargo builds and runs during a build!
25 When the `--target` flag is explicitly passed to cargo, the `RUSTFLAGS` no longer apply to build scripts and procedural macros.
26 For more fine-grained control consider passing a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to
27 rustc for the specific crates you want to profile.