-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document -Zinstrument-coverage #78616
Conversation
016ca3d
to
179ac85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice description!
First, edit the `config.toml` file, and find the `profiler` feature entry. It may be commented out: | ||
|
||
```toml | ||
# Build the profiler runtime (required when compiling with options that depend | ||
# on this runtime, such as `-C profile-generate` or `-Z instrument-coverage`). | ||
#profiler = false | ||
``` | ||
|
||
Uncomment the feature entry and set it to `true`: | ||
|
||
```toml | ||
profiler = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, edit the `config.toml` file, and find the `profiler` feature entry. It may be commented out: | |
```toml | |
# Build the profiler runtime (required when compiling with options that depend | |
# on this runtime, such as `-C profile-generate` or `-Z instrument-coverage`). | |
#profiler = false | |
``` | |
Uncomment the feature entry and set it to `true`: | |
```toml | |
profiler = true | |
First, edit the `config.toml` file, and find the `profiler` feature entry. Uncomment it and set it to `true`: | |
```toml | |
# Build the profiler runtime (required when compiling with options that depend | |
# on this runtime, such as `-C profile-generate` or `-Z instrument-coverage`). | |
profiler = true |
The phrasing here is a bit verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
After running this program, a new file, `default.profraw`, should be in the current working directory: | ||
|
||
```shell | ||
$ ls -l default.profraw | ||
``` | ||
```text | ||
-rw-r--r-- 1 user group 3.3M Oct 31 12:31 default.profraw | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the ls
example here. Again, to verbose for my taste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
179ac85
to
a8dfb26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bors delegate+
r=me after comments
|
||
Then rebuild the Rust compiler (see [rustc-dev-guide-how-to-build-and-run]). | ||
|
||
### Building the demangler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also point to rustfilt, which can be installed with cargo and doesn't require a rust checkout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't heard about rustfilt
before! That's a great option as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
## Enable coverage profiling in the Rust compiler | ||
|
||
*IMPORTANT:* Rust's coverage profiling features may not be enabled, by default. To enable them, you may need to build a version of the Rust compiler with the `profiler` feature enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of the tier 1 distributions ship with this enabled (grep for --enable-profiler
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I now discuss using nightly
as an option
Raw profiles have to be indexed before they can be used to generate coverage reports. This is done using [`llvm-profdata merge`] (which can combine multiple raw profiles and index them at the same time): | ||
|
||
```shell | ||
$ $HOME/rust/build/x86_64-unknown-linux-gnu/llvm/bin/llvm-profdata merge \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can show / mention doing it with system LLVM instead of requiring a rust build?
(Unless it has to match the exact LLVM version?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@bors delegate+ |
✌️ @richkadel can now approve this pull request |
f2fe33b
to
6d94911
Compare
@bors rollup=always r=tmandry |
📌 Commit 6d94911 has been approved by |
…r=tmandry Document -Zinstrument-coverage r? `@tmandry` FYI `@wesleywiser` Here is my proposed document for LLVM source-based code coverage. I based it on the `profile.md` page, in the same directory, and on the Clang guide for LLVM source-based coverage.
Rollup of 8 pull requests Successful merges: - rust-lang#78376 (Treat trailing semicolon as a statement in macro call) - rust-lang#78400 (Fix unindent in doc comments) - rust-lang#78575 (Add a test for compiletest rustc-env & unset-rustc-env directives) - rust-lang#78616 (Document -Zinstrument-coverage) - rust-lang#78663 (Fix ICE when a future-incompat-report has its command-line level capped) - rust-lang#78664 (Fix intrinsic size_of stable link) - rust-lang#78668 (inliner: Remove redundant loop) - rust-lang#78676 (add mipsel-unknown-none target) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
r? @tmandry
FYI @wesleywiser
Here is my proposed document for LLVM source-based code coverage.
I based it on the
profile.md
page, in the same directory, and on the Clang guide for LLVM source-based coverage.