Add env var to disable macOS toolchain#744
Open
keith wants to merge 8 commits into
Open
Conversation
Since this toolchain moved out of bazel, and bazel directly depends on apple_support, there's no reason to have a separate toolchain supporting the same platform. On top of that the macOS support in this toolchain isn't fully hermetic, and would require a lot of copy pasting from the apple_support toolchain to get there, for seemingly no benefit. This flips it off by default, with a temporary `--repo_env=BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=1` to keep the existing behavior, but will be removed in a subsequent release. Technically there are flag differences between this and what's in apple_support but apple_support isn't very opinionated so anything major should be fixable.
Member
Author
fmeum
approved these changes
Jun 17, 2026
lilygorsheneva
approved these changes
Jun 17, 2026
armandomontanez
approved these changes
Jun 17, 2026
armandomontanez
approved these changes
Jun 17, 2026
| 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" |
Collaborator
There was a problem hiding this comment.
Nit: this is easier to read if you do early returns
if "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1":
return True
macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "1") == "1"
if repository_ctx.os.name.startswith("mac os") and not macos_legacy_support:
return True
return False
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The toolchain can be disabled with
--repo_env=BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=0Work towards #754