fix(toolchain): build unpack binary in exec config to prevent ELF-on-macOS failure#910
Merged
gregmagolan merged 1 commit intomainfrom Apr 5, 2026
Merged
fix(toolchain): build unpack binary in exec config to prevent ELF-on-macOS failure#910gregmagolan merged 1 commit intomainfrom
gregmagolan merged 1 commit intomainfrom
Conversation
|
jbedard
reviewed
Apr 5, 2026
jbedard
approved these changes
Apr 5, 2026
5ed1085 to
7672ca5
Compare
7672ca5 to
f9fcfee
Compare
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.

Problem
After #905 removed
resolved_unpack_toolchain, macOS builds fail when the dependency graph contains aplatform_transition_filegrouptargeting Linux (e.g. OCI crossbuild tests):The
unpackbinary is ELF (Linux x86-64) instead of Mach-O (darwin-arm64).Root cause
Bazel analyzes toolchain targets in the same configuration as the requesting rule. When a
platform_transition_filegrouptransitions to a Linux target platform,whl_installis analyzed in that Linux-targeted configuration. With nocfgon thebinattribute ofpy_tool_toolchain, theunpackbinary inherits that Linux target config and is compiled as ELF — which cannot execute on the macOS exec host.resolved_unpack_toolchainworked around this by being a regulardepwithcfg = "exec", explicitly pulling the binary into exec config. The goal of #905 was to remove that workaround, but doing so exposed the underlying issue.Fix
Introduce two source-toolchain rule variants with explicit
cfgon theirbinattribute:source_target_py_tool_toolchain—cfg = "target"(venv, shim: target-side tools placed in runfiles)source_exec_py_tool_toolchain—cfg = "exec"(unpack: runs on the exec host during the build)TOOL_CFGSis already the source of truth for which tools are exec-side (cfg = "exec") vs target-side. Thesource_toolchainmacro now looks up thecfgfromTOOL_CFGSby name and selects the appropriate rule variant automatically — no per-call parameter needed.Note: these
source_*rules are only active whenIS_PRERELEASE = True(i.e. in this repo during development). Consumers get pre-built binaries viaprebuilt_tool_repo, which usesexec_compatible_withon thetoolchain()declaration for correct host selection.