Skip to content

fix: use target_compatible_with only for toolchain declarations#126

Open
hunshcn wants to merge 1 commit into
bazel-contrib:mainfrom
hunshcn:fix-exec-toolchain-only
Open

fix: use target_compatible_with only for toolchain declarations#126
hunshcn wants to merge 1 commit into
bazel-contrib:mainfrom
hunshcn:fix-exec-toolchain-only

Conversation

@hunshcn
Copy link
Copy Markdown
Contributor

@hunshcn hunshcn commented Apr 5, 2026

Per discussion in #104/#124:

  • Remove mixed exec+target toolchain registrations
  • Use target_compatible_with only on toolchain() declarations

When the tool is used as an artifact input (rules_oci / pkg_tar), target_compatible_with correctly matches the requested target platform.
When the tool is used as a build tool (cfg="exec"), Bazel sets target_platform = exec_platform in exec config, so target_compatible_with still matches the execution platform.

Using exec_compatible_with instead would break the artifact-input case: it would always pick the host architecture regardless of the requested --platforms, which is the original bug.

Fixes #104, Fixes #124

@hunshcn
Copy link
Copy Markdown
Contributor Author

hunshcn commented Apr 18, 2026

@mark-thm ping

Per discussion in bazel-contrib#104/bazel-contrib#124:
- Remove mixed exec+target toolchain registrations
- Use target_compatible_with only on toolchain() declarations

When the tool is used as an artifact input (rules_oci / pkg_tar),
target_compatible_with correctly matches the target platform.
When the tool is used as a build tool (cfg="exec"), Bazel sets
target_platform = exec_platform in exec config, so
target_compatible_with still matches the execution platform.

Using exec_compatible_with instead would break the artifact-input
case: it would always pick the host architecture regardless of the
requested --platforms, which is the original bug.

Fixes bazel-contrib#104, Fixes bazel-contrib#124
@hunshcn hunshcn force-pushed the fix-exec-toolchain-only branch from 3b4f6b2 to 83e3831 Compare April 23, 2026 15:05
@hunshcn hunshcn changed the title fix: use exec_compatible_with only for toolchain declarations fix: use target_compatible_with only for toolchain declarations Apr 23, 2026
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.

--platforms flag is not respected @multitool//tools/<tool> can resolve host arch instead of target arch in packaging (rules_oci) use cases

1 participant