Skip to content

rules_cc >= 0.1.2 breaks cc_test when using --incompatible_check_visibility_for_toolchains #445

@martis42

Description

@martis42

Description

While testing the rules_cc 1.2 release I stumbled over the following error:

ERROR: ../_repro/BUILD:5:8: in cc_test rule //:my_test: Visibility error:
target '@@rules_cc+//cc/private/toolchain/test:default_test_runner' is not visible from
target '@@_builtins//:common/cc/cc_test.bzl'
Recommendation: modify the visibility declaration if you think the dependency is legitimate. For more info see https://bazel.build/concepts/visibility
ERROR: ../_repro/BUILD:5:8: Analysis of target '//:my_test' failed

The reproducer below works fine with rules_cc 0.1.1.

Also, it is noteworthy that the rolling releases for Bazel 9.x define rules_cc 0.1.2 as the minimum required version. Thus, for rolling --incompatible_check_visibility_for_toolchains seems now generally broken when working with rules_cc.

Reproduction

Command bazel build --incompatible_check_visibility_for_toolchains //:my_test

MODULE.bazel

# Change to '0.1.1' to fix build
bazel_dep(name = "rules_cc", version = "0.1.2")

.bazelversion

8.3.1

BUILD

load("@rules_cc//cc:cc_test.bzl", "cc_test")

cc_test(
    name = "my_test",
    srcs = ["my_test.cpp"], # content of .cpp does not matter
)

Environment

  • Ubuntu 22.04 via WSL2
  • Tested multiple Bazel versions, which all show the same behavior: [7.x, 8.x, rolling]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions