Skip to content

Parameterize tool downloads by execution platform - #7

Open
trevorc wants to merge 1 commit into
seh:mainfrom
trevorc:fix-cross-compile-toolchains
Open

trevorc wants to merge 1 commit into
seh:mainfrom
trevorc:fix-cross-compile-toolchains

Conversation

@trevorc

@trevorc trevorc commented Sep 13, 2026

Copy link
Copy Markdown

Previously, the existing toolchain configuration directed all target platforms to a single artifact repository (e.g., @helm_tool//:tool). This base repository used host platform detection to download a single binary. Consequently, cross-compilation and remote execution failed when the execution platform architecture differed from that of the host.

This commit enables cross-compilation by isolating artifacts into platform-specific repositories:

  • The download_tool macro iterates over _TOOLS_BY_RELEASE to instantiate independent repositories for each OS and architecture combination (e.g., @helm_tool_linux_arm64).
  • The base repository fallback is removed to prevent host-architecture leakage in remote execution environments.
  • The native.toolchain declarations point to @{tool_repo}_{os}_{arch}//:tool, directing Bazel to fetch the artifact repository matching the requested execution platform.
  • An analysistest suite in toolchain_test.bzl verifies that linux_amd64 and linux_arm64 constraints resolve to their respective architectural repositories.

Previously, the existing toolchain configuration directed all target
platforms to a single artifact repository (e.g., @helm_tool//:tool).
This base repository used host platform detection to download a single
binary. Consequently, cross-compilation and remote execution failed
when the execution platform architecture differed from that of the host.

This commit enables cross-compilation by isolating artifacts into
platform-specific repositories:

- The `download_tool` macro iterates over `_TOOLS_BY_RELEASE` to
  instantiate independent repositories for each OS and architecture
  combination (e.g., @helm_tool_linux_arm64).
- The base repository fallback is removed to prevent host-architecture
  leakage in remote execution environments.
- The `native.toolchain` declarations point to
  `@{tool_repo}_{os}_{arch}//:tool`, directing Bazel to fetch the
  artifact repository matching the requested execution platform.
- An `analysistest` suite in `toolchain_test.bzl` verifies that
  `linux_amd64` and `linux_arm64` constraints resolve to their
  respective architectural repositories.
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.

1 participant