]> git.lizzy.rs Git - rust.git/commitdiff
Fix documentation example for gcov profiling
authorJonathan Schwender <schwenderjonathan@gmail.com>
Tue, 26 May 2020 13:16:57 +0000 (15:16 +0200)
committerJonathan Schwender <schwenderjonathan@gmail.com>
Tue, 26 May 2020 13:43:19 +0000 (15:43 +0200)
Incremental compilation needs to be turned off. Also added the other RUSTFLAGS that should/need to be turned on.

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

index 452aca51532c96da55dc58e5b649122aa1c3cb01..b3b3e4eb4058f1c65e6723958e6e46857b09f259 100644 (file)
@@ -12,10 +12,15 @@ 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` apply to everything that cargo builds and runs during a build, including build scripts!
+To avoid this, pass a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to rustc for the specific 
+crates you want to profile.