Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cc_compatibility_proxy autoloads break rules_cc >= 2.12 #27582

@mbland

Description

@mbland

Description of the bug:

Bazel 8 legacy WORKSPACE builds that instantiate cc_compatibility_proxy from rules_cc >= 2.12 fail with:

ERROR: Cycle caused by autoloads, failed to load .bzl file
  '@@cc_compatibility_proxy//:symbols.bzl'.
Add 'cc_compatibility_proxy' to --repositories_without_autoloads or
  disable autoloads by setting '--incompatible_autoload_externally='
More information on https://github.com/bazelbuild/bazel/issues/23043.
ERROR: cycles detected during target parsing

This is because rules_cc 0.2.12 introduced @cc_compatibility_proxy//:symbols.bzl. Loading Bazel native symbols from this file causes Bazel 8 to autoload them from @rules_cc. This leads to a cycle while autoloading @rules_cc, something like:

It appears that a future Bazel 8 release should add cc_compatibility_proxy to PREDECLARED_REPOS_DISALLOWING_AUTOLOADS:

Which category does this issue belong to?

Core

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ mkdir tmp && cd tmp
$ cat >WORKSPACE
workspace(name = "bazel-8-rules-cc-compat-proxy")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "bazel_features",
    sha256 = "07271d0f6b12633777b69020c4cb1eb67b1939c0cf84bb3944dc85cc250c0c01",
    strip_prefix = "bazel_features-1.38.0",
    url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.38.0/bazel_features-v1.38.0.tar.gz",
)

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

http_archive(
    name = "rules_cc",
    sha256 = "472ddca8cec1e64ad78e4f0cabbec55936a3baddbe7bef072764ca91504bd523",
    strip_prefix = "rules_cc-0.2.13",
    url = "https://github.com/bazelbuild/rules_cc/releases/download/0.2.13/rules_cc-0.2.13.tar.gz",
)

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

compatibility_proxy_repo()
^D

$ cat >BUILD
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(name = "foobar")
^D

$ USE_BAZEL_VERSION=8.4.2 bazel build --nobuild \
  --noenable_bzlmod --enable_workspace //...
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
ERROR: Cycle caused by autoloads, failed to load .bzl file '@@cc_compatibility_proxy//:symbols.bzl'.
Add 'cc_compatibility_proxy' to --repositories_without_autoloads or disable autoloads by setting '--incompatible_autoload_externally='
More information on https://github.com/bazelbuild/bazel/issues/23043.
ERROR: cycles detected during target parsing
INFO: Elapsed time: 5.620s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

Adding --repositories_without_autoloads=cc_compatibility_proxy works around the error:

$ USE_BAZEL_VERSION=8.4.2 bazel build --nobuild \
  --noenable_bzlmod --enable_workspace \
  --repositories_without_autoloads=cc_compatibility_proxy //...
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
INFO: Analyzed target //:foobar (60 packages loaded, 265 targets configured).
INFO: Found 1 target...
INFO: Elapsed time: 1.450s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions

Which operating system are you running Bazel on?

macOS Tahoe 26.1

What is the output of bazel info release?

release 8.4.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions