未验证 提交 e8bb4c70 编写于 作者: R Ralf Jung 提交者: GitHub

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
......@@ -12,10 +12,16 @@ For example:
```Bash
cargo new testgcov --bin
cd testgcov
export RUSTFLAGS="-Zprofile"
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export CARGO_INCREMENTAL=0
cargo build
cargo run
```
Once you've built and run your program, files with the `gcno` (after build) and `gcda` (after execution) extensions will be created.
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).
Please note that `RUSTFLAGS` by default applies to everything that cargo builds and runs during a build!
When the `--target` flag is explicitly passed to cargo, the `RUSTFLAGS` no longer apply to build scripts and procedural macros.
For more fine-grained control consider passing a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to
rustc for the specific crates you want to profile.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册