Skip to content

Commit 2b26b8b

Browse files
committed
Fix documentation example for gcov profiling
Incremental compilation needs to be turned off. Also added the other RUSTFLAGS that should/need to be turned on.
1 parent 62da38d commit 2b26b8b

File tree

1 file changed

+6
-1
lines changed
  • src/doc/unstable-book/src/compiler-flags

1 file changed

+6
-1
lines changed

src/doc/unstable-book/src/compiler-flags/profile.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ For example:
1212
```Bash
1313
cargo new testgcov --bin
1414
cd testgcov
15-
export RUSTFLAGS="-Zprofile"
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
1617
cargo build
1718
cargo run
1819
```
1920

2021
Once you've built and run your program, files with the `gcno` (after build) and `gcda` (after execution) extensions will be created.
2122
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).
23+
24+
Please note that `RUSTFLAGS` apply to everything that cargo builds and runs during a build, including build scripts!
25+
To avoid this, pass a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to rustc for the specific
26+
crates you want to profile.

0 commit comments

Comments
 (0)