Skip to content

Add env var to disable macOS toolchain#744

Open
keith wants to merge 8 commits into
bazelbuild:mainfrom
keith:ks/disable-macos-toolchain-by-default
Open

Add env var to disable macOS toolchain#744
keith wants to merge 8 commits into
bazelbuild:mainfrom
keith:ks/disable-macos-toolchain-by-default

Conversation

@keith

@keith keith commented Jun 10, 2026

Copy link
Copy Markdown
Member

The toolchain can be disabled with --repo_env=BAZEL_USE_LEGACY_MACOS_TOOLCHAIN=0

Work towards #754

keith added 7 commits June 10, 2026 16:38
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.
@keith keith changed the title Disable macOS toolchain by default Add env var to disable macOS toolchain Jun 16, 2026
@keith keith marked this pull request as ready for review June 16, 2026 23:44
@keith keith requested review from c-mita, pzembrod and trybka as code owners June 16, 2026 23:44
@keith

keith commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

cc @fmeum @armandomontanez

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants