-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
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 parsingThis 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:
-
A legacy
WORKSPACEfile invokescompatibility_proxy_repo(), which generates@cc_compatibility_proxy//:symbols.bzl. On Bazels before 9.0.0-pre.20250911, this file loads symbols from@rules_cc//cc/private/rules_impl:native.bzl. Namely:cc_common,CcInfo,DebugPackageInfo,CcToolchainConfigInfo.- bazelbuild/rules_cc: Enable C++ symbols using compatiblity proxy
bazelbuild/rules_cc@b81a4f4 - https://github.com/bazelbuild/rules_cc/blob/0.2.13/cc/extensions.bzl#L135-L150
- https://github.com/bazelbuild/rules_cc/blob/0.2.13/cc/private/rules_impl/native.bzl
- bazelbuild/rules_cc: Enable C++ symbols using compatiblity proxy
-
Some
.bzlfile loads a symbol from a@rules_ccfile, which in turn loads from@cc_compatibility_proxy//:symbols.bzl. -
@cc_compatibility_proxy//:symbols.bzlloads symbols from@rules_cc//cc/private/rules_impl:native.bzl. All of these imported native symbols are listed inAutoloadSymbols.javafrom: -
These autoloaded symbols redirect back to
@rules_cc, which then tries to load@cc_compatibility_proxy, and goes boom.
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 successfullyAdding --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 actionsWhich 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