Skip to content
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

Merged
merged 2 commits into from
Nov 3, 2020

Conversation

richkadel
Copy link
Contributor

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 31, 2020
@richkadel richkadel force-pushed the unstable-book-instr-cov branch 3 times, most recently from 016ca3d to 179ac85 Compare November 1, 2020 00:31
Copy link
Contributor

@Julian-Wollersberger Julian-Wollersberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice description!

cc #34701 and rust-lang/compiler-team#278

Comment on lines 31 to 36
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 90 to 97
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
```
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@richkadel
Copy link
Contributor Author

cc #34701 and rust-lang/compiler-team#278

Copy link
Member

@tmandry tmandry left a 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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
Copy link
Member

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)

Copy link
Contributor Author

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 \
Copy link
Member

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?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@tmandry
Copy link
Member

tmandry commented Nov 2, 2020

@bors delegate+

@bors
Copy link
Contributor

bors commented Nov 2, 2020

✌️ @richkadel can now approve this pull request

@richkadel
Copy link
Contributor Author

@bors rollup=always r=tmandry

@bors
Copy link
Contributor

bors commented Nov 2, 2020

📌 Commit 6d94911 has been approved by tmandry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 3, 2020
…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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 3, 2020
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
@bors bors merged commit 416dd67 into rust-lang:master Nov 3, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants