bazel-contrib / bazel-contrib/toolchains_llvm

Coverage flags included when target does not have coverage

Open
#521 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
371
Forks
283
Avg merge
1d 55m
Merged PRs (30d)
25

Description

Not sure if this issue is related to this repo or not, however I noticed that

```starlark
def get_cc_compile_args_and_env(cc_toolchain, feature_configuration):
"""Gather cc environment variables from the given `cc_toolchain`

Args:
cc_toolchain (cc_toolchain): The current rule's `cc_toolchain`.
feature_configuration (FeatureConfiguration): Class used to construct command lines from CROSSTOOL features.

Returns:
tuple: A tuple of the following items:
- (sequence): A flattened C command line flags for given action.
- (sequence): A flattened CXX command line flags for given action.
- (dict): C environment variables to be set for given action.
"""
compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
)
cc_c_args = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = ACTION_NAMES.c_compile,
variables = compile_variables,
)
cc_cxx_args = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = ACTION_NAMES.cpp_compile,
variables = compile_variables,
)
cc_env = cc_common.get_environment_variables(
feature_configuration = feature_configuration,
action_name = ACTION_NAMES.c_compile,
variables = compile_variables,
)
return cc_c_args, cc_cxx_args, cc_env
```

The following macro if invoked via `bazel coverage //...` will always return `c_args` and `cxx_args` including `-fprofile-instr-generate -fcoverage-mapping` even if the target is not selected for coverage using `--instrumentation_filter`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the get_cc_compile_args_and_env macro and reproduce the behavior with bazel coverage //..., including an --instrumentation_filter that excludes the target. Trace how the returned c_args and cxx_args are constructed for an excluded target; done means coverage flags are absent when that target is not selected for coverage.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.