Skip to content

Commit e8bb4c7

Browse files
authored
Rollup merge of #72615 - jschwe:fix-Zprofile-documentation, r=steveklabnik
Fix documentation example for gcov profiling closes #72546 Improves the documentation for the unstable Rustflag `-Zprofile` by: - stating that Incremental compilation must be turned off. - Adding the other `RUSTFLAGS` that should/need to be turned on (taken from [grcov documentation](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project)) - Mentioning `RUSTC_WRAPPER` to prevent everything getting instrumented. r? @steveklabnik
2 parents b0559be + 7bf026e commit e8bb4c7

File tree

1 file changed

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

1 file changed

+7
-1
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ 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` 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.

0 commit comments

Comments
 (0)