From 0c0727d2fe019667895e5390d8c5867be7a8dab5 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 18 Jun 2026 12:31:49 -0700 Subject: [PATCH 1/6] Disable macOS toolchain by default You can get back the previous toolchain with `--repo_env=BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=1` for now. Please report any issues you hit! Work towards https://github.com/bazelbuild/rules_cc/issues/754 --- cc/private/toolchain/cc_configure.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index 1d5314489..fdb9cce9b 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -25,7 +25,7 @@ def _should_disable_toolchain(repository_ctx): """Returns true if the toolchain should be disabled based on environment variables.""" env = repository_ctx.os.environ disabled_via_env = "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1" - macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "1") == "1" + macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "0") == "1" return disabled_via_env or (repository_ctx.os.name.startswith("mac os") and not macos_legacy_support) def cc_autoconf_toolchains_impl(repository_ctx): From ba01ab47edece6d85b23feed5be3339ed1ca4d94 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 18 Jun 2026 12:34:24 -0700 Subject: [PATCH 2/6] improve --- cc/private/toolchain/cc_configure.bzl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index fdb9cce9b..2ba824332 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -24,9 +24,14 @@ load(":windows_cc_configure.bzl", "configure_windows_toolchain") def _should_disable_toolchain(repository_ctx): """Returns true if the toolchain should be disabled based on environment variables.""" env = repository_ctx.os.environ - disabled_via_env = "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1" + if env.get("BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN") == "1": + return True + macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "0") == "1" - return disabled_via_env or (repository_ctx.os.name.startswith("mac os") and not macos_legacy_support) + if repository_ctx.os.name.startswith("mac os") and not macos_legacy_support: + return True + + return False def cc_autoconf_toolchains_impl(repository_ctx): """Generate BUILD file with 'toolchain' targets for the local host C++ toolchain. From 54c6032e07198ba0e409bb10e0f75a62b67ca408 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 18 Jun 2026 12:50:42 -0700 Subject: [PATCH 3/6] disable nodeps for macos --- tests/integration/cc_tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/cc_tests.sh b/tests/integration/cc_tests.sh index f13ad7aa2..5bd89d06b 100755 --- a/tests/integration/cc_tests.sh +++ b/tests/integration/cc_tests.sh @@ -203,6 +203,7 @@ def _cc_aspect_impl(target, ctx): feature_configuration = feature_configuration, name = ctx.label.name + "_aspect", cc_toolchain = toolchain, + disallow_dynamic_library = True, compilation_outputs = compilation_outputs, ) ) @@ -240,6 +241,7 @@ def _cc_skylark_library_impl(ctx): feature_configuration=feature_configuration, linking_contexts = dep_linking_contexts, name = ctx.label.name, + disallow_dynamic_library = True, compilation_outputs=compilation_outputs) ) return [CcInfo( From 11c311459c6023f37b3219effab8e7cfdcb861e1 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 18 Jun 2026 12:57:03 -0700 Subject: [PATCH 4/6] missing dep on 8.x --- tests/integration/test_launcher.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test_launcher.sh b/tests/integration/test_launcher.sh index 563cc6f1a..06b7e4c0f 100755 --- a/tests/integration/test_launcher.sh +++ b/tests/integration/test_launcher.sh @@ -59,6 +59,8 @@ cd "$scratch_workspace" cat > MODULE.bazel << EOF module(name = "test_module") +# Bring in macOS toolchain for basic testing +bazel_dep(name = "apple_support", version = "2.6.1") bazel_dep(name = "rules_cc", version = "0.0.0") local_path_override( module_name = "rules_cc", From 72944bfbbab3dabf024354b7d9e4f63d01022fc4 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 18 Jun 2026 12:57:16 -0700 Subject: [PATCH 5/6] comment --- tests/integration/test_launcher.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/test_launcher.sh b/tests/integration/test_launcher.sh index 06b7e4c0f..988e63140 100755 --- a/tests/integration/test_launcher.sh +++ b/tests/integration/test_launcher.sh @@ -59,6 +59,7 @@ cd "$scratch_workspace" cat > MODULE.bazel << EOF module(name = "test_module") +# TODO: Remove when we drop bazel 8.x support # Bring in macOS toolchain for basic testing bazel_dep(name = "apple_support", version = "2.6.1") bazel_dep(name = "rules_cc", version = "0.0.0") From 7dd05a4b5c4667e5ba7f59f9e0644a4c9289f448 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 23 Jun 2026 16:34:16 -0700 Subject: [PATCH 6/6] only disable for 9.x+ --- cc/private/toolchain/cc_configure.bzl | 5 +++++ tests/integration/test_launcher.sh | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index 2ba824332..0d5a07827 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -13,6 +13,7 @@ # limitations under the License. """Rules for configuring the C++ toolchain (experimental).""" +load("@bazel_features//:features.bzl", "bazel_features") load( ":lib_cc_configure.bzl", "get_cpu_value", @@ -27,6 +28,10 @@ def _should_disable_toolchain(repository_ctx): if env.get("BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN") == "1": return True + # Keep macOS toolchain before bazel 9.x + if not bazel_features.cc.cc_common_is_in_rules_cc: + return False + macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "0") == "1" if repository_ctx.os.name.startswith("mac os") and not macos_legacy_support: return True diff --git a/tests/integration/test_launcher.sh b/tests/integration/test_launcher.sh index 988e63140..563cc6f1a 100755 --- a/tests/integration/test_launcher.sh +++ b/tests/integration/test_launcher.sh @@ -59,9 +59,6 @@ cd "$scratch_workspace" cat > MODULE.bazel << EOF module(name = "test_module") -# TODO: Remove when we drop bazel 8.x support -# Bring in macOS toolchain for basic testing -bazel_dep(name = "apple_support", version = "2.6.1") bazel_dep(name = "rules_cc", version = "0.0.0") local_path_override( module_name = "rules_cc",