-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[POC] cmake: Introduce LLVM's Source-based Code Coverage reports #31394
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
Conversation
The new `BUILD_FOR_COVERAGE` build option enables instrumentation for LLVM's Source-based Code Coverage reports.
warning: 502 functions have mismatched data - test_bitcoin: 2 - bitcoin-util: 329 - bitcoin-tx: 171
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31394. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Would we keep supporting generating coverage with gcc? |
I haven't played with coverage in CMake much, but this seems like a more reasonable approach than the build type.
I don't think we should keep both approaches. If we do want to continue to support gcc, IMO it should be migrated to this setting rather than keeping it as a build type. But.. there's a lot of duplicated/hard-coded logic here. Can we not deduce how to filter/what to run based on target properties? |
If gcc support is removed, it would be good to make sure https://github.com/corecheck/corecheck/blob/d15e92618a519e125758a6294e85ee9d6ce89265/workers/coverage-worker/entrypoint.sh#L50 and other places that currently rely on it are taken care of. |
I suggest treating the broken GCC-based coverage as a 29.0 blocker, as it seems it's been effectively unusable anyway. Adding an LLVM-based coverage mechanism then seems like an independent improvement. |
I don't see why this should be a 29.0 blocker at all, or why GCC is unusable, given that it is used, for example, see the previous comment above: #31394 (comment) Let's continue discussion in the thread #31047 (comment)? |
Why not? GCC is the native compiler on Linux, a widely used OS for developing Bitcoin Core. |
I've removed the milestone here for now, because this looks like it is adding a new feature that never existed before, so shouldn't be a blocker. |
🐙 This pull request conflicts with the target branch and needs rebase. |
What is the status here? This still needs rebase, if relevant, due to the conflict from February. Also, #31933 was merged. |
My 2 sats:
|
A good chunk of the time people will want to create coverage only for a subset of tests (or pass test options) (see #28772 (comment) or https://github.com/bitcoin/bitcoin/tree/master/contrib/devtools#deterministic-fuzz-coverage). Also, they may want to modify the coverage report generation. Not sure how easy it is to support all that in cmake. It may be easier to just use a justfile with snippets for each part. However, a self-brewed script or bash alias seems most flexible. (The same is conceptually true for running the functional tests, see #18816 (comment)) |
The
gcov
-based code coverage does not work with Clang (please refer to #31047 for more details).This PR employs the LLVM's Source-based Code Coverage.
Here are some examples of usage:
or
or
As a proof of concept, the new targets still lack the ability to customize
llvm-cov
options.I haven't yet assessed the quality of the resulting coverage reports. However, messages like this:
are quite concerning.
Also see a discussion in hebasto#233.