Split coverage features into coverage_enabled and coverage_instrumented - #842
Split coverage features into coverage_enabled and coverage_instrumented#842fmeum wants to merge 3 commits into
coverage_enabled and coverage_instrumented#842Conversation
|
The coverage failure is preexisting, will send a fix to Bazel. |
|
I pushed a new commit with further cleanup enabled by this change. |
66eaf86 to
c2c13a3
Compare
|
CI is green now @pzembrod |
…ented` `cc_common.configure_features` only requested a single `coverage` feature when building with coverage, which doesn't allow toolchains to distinguish between targets that are instrumented for coverage and those that aren't. The default toolchains thus end up instrumenting everything even with a narrow `--instrumentation_filter`, which is wasteful. `coverage_enabled` is now requested whenever coverage is generally enabled (matching `coverage`), whereas `coverage_instrumented` is only requested if the current target is instrumented. This gives toolchains a clean way to only instrument the targets that require it, see bazelbuild#424 for an example. Along the way, `implementation_deps` is added to the check for an instrumented dependency, which apparently wasn't updated when this attribute was added. This is a port of bazelbuild/bazel#26355, with the coverage feature computation kept in `configure_features` instead of moved into the individual rules: unlike Bazel's Java implementation, the Starlark one has access to `ctx`, so every rule calling `cc_common.configure_features` benefits without losing the existing `coverage` and `*_coverage_map_format` features.
Derive coverage outputs and build variables directly from the coverage_instrumented feature. Inject legacy coverage marker features independently to avoid partial-definition conflicts.
c2c13a3 to
c35fed2
Compare
|
@pzembrod Resolved the conflict |
|
@c-mita I addressed the comments |
|
want to add to features.md? |
|
@keith I already added them. @lilygorsheneva This should be ready for import. |
|
Sorry; I've been out a while. |
|
can cc_helper.is_code_coverage_enabled remain temporarily while we migrate the other rulesets? |
Sure. Can you make the change to the import directly or do you want me to change the PR? |
|
If you don't anticipate anything strange happening from leaving it in, I can change it internally; thank you for confirmation |
Before this change, rules_cc only enabled a single coverage feature when building with coverage, which doesn't directly allow toolchains to distinguish between targets that are instrumented for coverage and those which are not. The default toolchain thus ends up instrumenting everything even with a narrow
--instrumentation_filter, which is wasteful. Blaze relies on the presence of thegcov_gcno_filevariable to avoid this, but that's really more of a hack and undocumented (and also undocumentable).This change lets rules_cc request two new coverage-related features:
coverage_enabledis requested whenever coverage is generally enabled (matchingcoverage), whereascoverage_instrumentedis only requested when the current target is instrumented. This provides a clean way for toolchains to instrument only those targets that require it (see #424 for an example of such a toolchain).Along the way, implementation_deps is added to the check for an instrumented dependency, which apparently wasn't updated when this attribute was added.
Older versions of rules_cc only request
coverage, so toolchains that want to support them as well can keep their existingcoverageflag sets and guard them withwith_feature_set(not_features = ["coverage_enabled"]).Fixes bazelbuild/bazel#15627
Fixes bazelbuild/bazel#21911