bazelbuild / rules_cc

C++ Rules for Bazel
https://bazel.build
Apache License 2.0
176 stars 88 forks source link

bazel coverage not working for 0.0.9 #219

Open Ryang20718 opened 6 months ago

Ryang20718 commented 6 months ago

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
comius commented 5 months ago

@c-mita for triage possibly similar to https://github.com/bazelbuild/bazel/issues/20993

comius commented 5 months ago

@c-mita friendly ping

c-mita commented 5 months ago

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.