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

Disable coverage when a C library is not instrumented #1021

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion foreign_cc/private/cc_toolchain_util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ FOREIGN_CC_DISABLED_FEATURES = [
]

def _configure_features(ctx, cc_toolchain):
disabled_features = ctx.disabled_features + FOREIGN_CC_DISABLED_FEATURES
if not ctx.coverage_instrumented():
# In coverage mode, cc_common.configure_features() adds coverage related flags,
# such as --coverage to the compiler and linker. However, if this library is not
# instrumented, we don't need to pass those flags, and avoid unncessary rebuilds.
disabled_features.append("coverage")
return cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features + FOREIGN_CC_DISABLED_FEATURES,
unsupported_features = disabled_features,
)

def _create_libraries_to_link(ctx, files):
Expand Down