refactor(whl_install): remove resolved_unpack_toolchain workaround#905
Merged
Conversation
|
5274347 to
28f5615
Compare
xangcastle
approved these changes
Apr 4, 2026
09e3dd3 to
5957450
Compare
UNPACK_TOOLCHAIN is registered in repo.bzl with exec_compatible_with (via the cfg="exec" TOOL_CFGS entry), so ctx.toolchains[UNPACK_TOOLCHAIN] already resolves the exec-platform binary without any indirection. The resolved_unpack_toolchain rule and its cfg="exec" _unpack attr in whl_install were an unnecessary workaround, analogous to resolved_py_toolchain which was removed in #903. Remove resolved_unpack_toolchain from tools.bzl and BUILD.bazel, and replace the ctx.attr._unpack indirection in rule.bzl with a direct toolchain lookup. Add an analysis-time regression test (exec_toolchain_resolution_test) that confirms UNPACK_TOOLCHAIN resolves the exec-platform binary even when the target platform is arm64. The test writes the resolved binary path to a file for both native and arm64-transitioned targets and asserts they are identical, proving exec-platform resolution is honoured throughout platform transitions.
c8eb976 to
4dbc2f2
Compare
gregmagolan
added a commit
that referenced
this pull request
Apr 5, 2026
…macOS failure (#910) ## Problem After #905 removed `resolved_unpack_toolchain`, macOS builds fail when the dependency graph contains a `platform_transition_filegroup` targeting Linux (e.g. OCI crossbuild tests): ``` bazel-out/darwin_arm64-opt-ST-.../bin/py/tools/unpack_bin/unpack: cannot execute binary file ``` The `unpack` binary 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_filegroup` transitions to a Linux target platform, `whl_install` is analyzed in that Linux-targeted configuration. With no `cfg` on the `bin` attribute of `py_tool_toolchain`, the `unpack` binary inherits that Linux target config and is compiled as ELF — which cannot execute on the macOS exec host. `resolved_unpack_toolchain` worked around this by being a regular `dep` with `cfg = "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 `cfg` on their `bin` attribute: - `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_CFGS` is already the source of truth for which tools are exec-side (`cfg = "exec"`) vs target-side. The `source_toolchain` macro now looks up the `cfg` from `TOOL_CFGS` by name and selects the appropriate rule variant automatically — no per-call parameter needed. Note: these `source_*` rules are only active when `IS_PRERELEASE = True` (i.e. in this repo during development). Consumers get pre-built binaries via `prebuilt_tool_repo`, which uses `exec_compatible_with` on the `toolchain()` declaration for correct host selection.
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.

Summary
UNPACK_TOOLCHAINis registered withexec_compatible_with(viacfg="exec"inTOOL_CFGS), soctx.toolchains[UNPACK_TOOLCHAIN]already resolves the exec-platform binary — no indirection needed.resolved_unpack_toolchainrule fromtools.bzlandBUILD.bazel.cfg="exec"_unpackattr +ctx.attr._unpack[ToolchainInfo].bin.binpattern inwhl_install/rule.bzlwith a directctx.toolchains[UNPACK_TOOLCHAIN].bin.binlookup.exec_toolchain_resolution_testto theuv-deps-650/crossbuilde2e case: writes the resolved unpack binary path for both a native target and an arm64-transitioned target, then asserts the paths are identical (proving exec-platform resolution is preserved across target-platform transitions).This is a follow-on cleanup to #903, which removed the analogous
resolved_py_toolchainworkaround.Test plan
exec_toolchain_resolution_testpasses on Linux CI (arm64 and amd64 transitions resolve the same exec-platform binary)resolved_unpack_toolchainremain