Skip to content

Constrain macOS-only tool rules to macOS execution platforms - #3044

Open
mauriciogg wants to merge 1 commit into
bazelbuild:mainfrom
mauriciogg:mac-tools-exec-constraints
Open

Constrain macOS-only tool rules to macOS execution platforms#3044
mauriciogg wants to merge 1 commit into
bazelbuild:mainfrom
mauriciogg:mac-tools-exec-constraints

Conversation

@mauriciogg

Copy link
Copy Markdown

Constrain macOS-only tool rules to macOS execution platforms

Several standalone tool rules run macOS-only tools but carry no execution-platform constraint which causes failures where there are multiple execution platforms available. E.g. RBE with a linux toolchains (see rules_applecross)

Also switch apple_mac_tools_toolchain alticonstool to cfg = "target" like the toolchain's other tool attributes: the toolchain target is already resolved for a mac execution platform, so "exec" would re-resolve against the first registered execution platform.

Several standalone tool rules run macOS-only tools but carry no
execution-platform constraint: environment_plist runs
xcodebuild/xcrun, apple_intent_library runs xcrun intentbuilderc,
apple_metal_library runs xcrun metal/metallib, and apple_bundle_version's
versiontool is resolved for the host. The bundling rules already carry
this constraint via rule_factory, but in builds that register non-mac
execution platforms first (e.g. Linux remote executors used to
cross-compile for Apple platforms), these standalone rules resolve to a
non-mac execution platform and fail.

Also pin default_cc_toolchain_forwarder to macOS - it resolves the C++
toolchain apple binary rules link with, independently of the rule itself
(which rule_factory pins to macOS); letting it float hands the
mac-executed link action a toolchain resolved for another platform. And
switch apple_mac_tools_toolchain's alticonstool to cfg = "target" like
the toolchain's other tool attributes: the toolchain target is already
resolved for a mac execution platform, so "exec" would re-resolve
against the first registered execution platform.
@keith

keith commented Aug 18, 2026

Copy link
Copy Markdown
Member

shouldn't most of these platform selections be done correctly by the toolchain registered in the exec groups? the toolchain itself should be the one forcing actions to run on the right platform.

rules that only fetch the "xplat" toolchain but then are being modified here seem like we must be doing something wrong since those should also be up to the toolchain to decide the platform

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.

2 participants