Skip to content

Commit 32c4886

Browse files
committed
conditionally use unix_cc_toolchain_config.bzl from bazel_tools or rules_cc
Bazel 7 and prior requires a matching unix_cc_toolchain_config (with the appropriate features for that Bazel version). That one is bound to the Bazel version and can be loaded from @bazel_tools up to Bazel 8, where it was moved to rules_cc.
1 parent 85fb94f commit 32c4886

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

toolchains/cc/cc.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,16 @@ def _nixpkgs_cc_toolchain_config_impl(repository_ctx):
140140
# `@bazel_tools//tools/cpp:unix_cc_configure.bzl`.
141141
# Uses the corresponding templates from `@bazel_tools` as well, see the
142142
# private attributes of the `_nixpkgs_cc_toolchain_config` rule.
143+
144+
bazel_version_match_8, _ = is_bazel_version_at_least("8.0.0")
145+
unix_toolchain_config = repository_ctx.attr._unix_cc_toolchain_config
146+
if not bazel_version_match_8:
147+
# Bazel 7 and prior requires a matching unix_cc_toolchain_config
148+
# (with the appropriate features for that Bazel version)
149+
unix_toolchain_config = Label("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl")
150+
143151
repository_ctx.symlink(
144-
repository_ctx.path(repository_ctx.attr._unix_cc_toolchain_config),
152+
repository_ctx.path(unix_toolchain_config),
145153
"cc_toolchain_config.bzl",
146154
)
147155
repository_ctx.symlink(

0 commit comments

Comments
 (0)