Skip to content

Commit

Permalink
conditionally use unix_cc_toolchain_config.bzl from bazel_tools or ru…
Browse files Browse the repository at this point in the history
…les_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.
  • Loading branch information
malt3 committed Dec 17, 2024
1 parent 44b2669 commit 5190554
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion toolchains/cc/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,16 @@ def _nixpkgs_cc_toolchain_config_impl(repository_ctx):
# `@bazel_tools//tools/cpp:unix_cc_configure.bzl`.
# Uses the corresponding templates from `@bazel_tools` as well, see the
# private attributes of the `_nixpkgs_cc_toolchain_config` rule.

bazel_version_match_8, _ = is_bazel_version_at_least("8.0.0")
unix_toolchain_config = repository_ctx.attr._unix_cc_toolchain_config
if not bazel_version_match_8:
# Bazel 7 and prior requires a matching unix_cc_toolchain_config
# (with the appropriate features for that Bazel version)
unix_toolchain_config = Label("@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl")

repository_ctx.symlink(
repository_ctx.path(repository_ctx.attr._unix_cc_toolchain_config),
repository_ctx.path(unix_toolchain_config),
"cc_toolchain_config.bzl",
)
repository_ctx.symlink(
Expand Down

0 comments on commit 5190554

Please sign in to comment.