bazel coverage not working for 0.0.9
Description of the problem / feature request:
Bazel Coverage failing with rules_cc 0.0.9
Feature requests: what underlying problem are you trying to solve with this feature?
We're trying to uprev our rules_cc from ancient 0.0.1 to latest version as we prepare to migrate to bazel 7.0.0
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
test.cpp
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
BUILD
cc_library(
name = "test_lib",
srcs = ["test.cpp"],
)
cc_test(
name = "test",
srcs = [":test_lib"],
)
What operating system are you running Bazel on?
ubuntu 20.04
What's the output of bazel info release?
release 6.3.2
What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?
0.0.9
What Bazel options do you use to trigger the issue? What C++ toolchain do you use?
I ran this with bazel 6.3.2 in the rules cc example section by adding the following section above. I'm using the cc toolchain configured by rules_cc.
System gcc is 9.0.0
Have you found anything relevant by searching the web?
https://groups.google.com/d/topic/bazel-discuss/dtduJBlb-nw (doesn't seem relevant)
Any other information, logs, or outputs that you want to share?
bazelisk coverage //examples/my_c_archive/...
ERROR: /home/ryang/repos/rules_cc/examples/my_c_archive/BUILD:36:13: in my_c_compile rule //examples/my_c_archive:object:
Traceback (most recent call last):
File "/home/ryang/repos/rules_cc/examples/my_c_compile/my_c_compile.bzl", line 30, column 57, in _my_c_compile_impl
feature_configuration = cc_common.configure_features(
Error in configure_features: Symbol profile is provided by all of the following features: coverage gcc_coverage_map_format
ERROR: /home/ryang/repos/rules_cc/examples/my_c_archive/BUILD:36:13: Analysis of target '//examples/my_c_archive:object' failed
ERROR: Analysis of target '//examples/my_c_archive:object' failed; build aborted:
INFO: Elapsed time: 0.090s
@c-mita for triage possibly similar to https://github.com/bazelbuild/bazel/issues/20993
@c-mita friendly ping
I can't even build the example in this repo with Bazel 6.0.0 or later...
Regardless, I suspect the issue is here: https://github.com/bazelbuild/rules_cc/blob/35fe45e91bdca3128c873ebc7dd18f52063524c5/cc/private/toolchain/unix_cc_toolchain_config.bzl#L997
The "coverage" feature is a duplicate of the "gcc_coverage_map_format" one, but the latter "requires" the former and there's a conflict since they provide the same "profile" symbol.
I got that issue too on Debian 12 with GCC 12. If you enable rool_cc toolchain coverage fails (because symbol profile is provided by several features. Using the built-in toolchains the issue is gone. To reproduce using the OP's code and BUILD file, use the following WORKSPACE.bazel.
workspace(name = "cov_issue")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# ----------------- rules_cc -----------------------------------
http_archive(
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.10-rc1/rules_cc-0.0.10-rc1.tar.gz"],
sha256 = "d75a040c32954da0d308d3f2ea2ba735490f49b3a7aa3e4b40259ca4b814f825",
)
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
# ----------------------------------------------------
rules_cc_dependencies()
rules_cc_toolchains()
Running bazel coverage --noenable_bzlmod --combined_report=lcov //:test produces the error. Commenting the last two lines in the workspace file and running the bazel command again, succeeds.