Register apple_support's C++ toolchains (#984) With Bazel 9 and later, rules_cc disables its autodetected C++ toolchain on macOS, which makes the toolchain provided by apple_support the default. Register it from rules_cc, after rules_cc's own toolchains, so that it stays the default when only the module defining a toolchain type may register toolchains for it, as proposed in https://github.com/bazelbuild/bazel/discussions/32428. apple_support already registers the same toolchains, which only match macOS execution platforms. Today, the only effect is that they can take precedence over C++ toolchains registered by modules that come after rules_cc and before apple_support in the dependency graph. Registering them after rules_cc's own toolchains keeps the autodetected toolchain first with Bazel 7 and 8 and with `BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=1`. Closes #984 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/984 from fmeum:register-apple-cc-toolchain 0a636ff52ea6c8b5f4a61d92fddd984ef40b038d PiperOrigin-RevId: 1024077036 Change-Id: I19f6cdce425f6440acc1e03cdece2251f8ab6e95
diff --git a/MODULE.bazel b/MODULE.bazel index 6d27460..6d03c2a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -13,8 +13,12 @@ cc_configure = use_extension("//cc:extensions.bzl", "cc_configure_extension") use_repo(cc_configure, "local_config_cc", "local_config_cc_toolchains") +apple_cc_configure = use_extension("@apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") +use_repo(apple_cc_configure, "local_config_apple_cc_toolchains") + register_toolchains( "@local_config_cc_toolchains//:all", + "@local_config_apple_cc_toolchains//:all", "//cc/private/toolchain/test:default_test_runner_toolchain", )