Skip to content

Pin xcode_swift_toolchain to a macOS execution platform - #1886

Open
mauriciogg wants to merge 1 commit into
bazelbuild:mainfrom
mauriciogg:pin-xcode-toolchain-to-macos
Open

Pin xcode_swift_toolchain to a macOS execution platform#1886
mauriciogg wants to merge 1 commit into
bazelbuild:mainfrom
mauriciogg:pin-xcode-toolchain-to-macos

Conversation

@mauriciogg

Copy link
Copy Markdown
Contributor

xcode_swift_toolchain requires Xcode and can only run on macOS, but the rule carries no execution-platform constraint. In builds that register non-mac execution platforms first (e.g. Linux remote executors used to cross-compile for Apple platforms), toolchain resolution hands the rule a Linux execution platform, and use_cc_toolchain() then pairs the Xcode Swift toolchain with that platform's C++ toolchain, breaking analysis.

Before the migration to use_cc_toolchain(), the constraint was expressed through the rule's default exec group; restore it on the rule itself.

xcode_swift_toolchain requires Xcode and can only run on macOS, but the
rule carries no execution-platform constraint. In builds that register
non-mac execution platforms first (e.g. Linux remote executors used to
cross-compile for Apple platforms), toolchain resolution hands the rule a
Linux execution platform, and use_cc_toolchain() then pairs the Xcode
Swift toolchain with that platform's C++ toolchain, breaking analysis.

Before the migration to use_cc_toolchain(), the constraint was expressed
through the rule's default exec group; restore it on the rule itself.

@keith keith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought these were enough for this case?

exec_compatible_with = [
"@platforms//os:macos",
],
target_compatible_with = constraints,
toolchain = ":xcode-sdk-toolchain",
toolchain_type = "//toolchains:sdk_toolchain_type",
visibility = ["//visibility:public"],
)
for arch, constraints in APPLE_PLATFORMS_CONSTRAINTS.items()
]
[
toolchain(
name = "xcode-toolchain-" + arch,
exec_compatible_with = [
"@platforms//os:macos",
],

seems harmless to me tho

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