Description of the feature request:
Background
The example below will allow running a test built for wasm+gpu on a platform without any GPU.
Consider the following test toolchain:
toolchain(
name = "wasm_on_linux",
exec_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
target_compatible_with = ["@platforms//cpu:wasm64"],
toolchain = "@bazel_tools//tools/test:empty_toolchain",
toolchain_type = "@bazel_tools//tools/test:default_test_toolchain_type",
)
With this toolchain, tests can run on a Linux amd64 machine when being built for wasm. The problem is that if the target platform has the constraints ["@platforms//cpu:wasm64", "//gpu:small"], it will also match.
One can consider adding another toolchain:
toolchain(
name = "wasm_on_linux",
exec_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64", "//gpu:small"],
target_compatible_with = ["@platforms//cpu:wasm64", "//gpu:small"],
toolchain = "@bazel_tools//tools/test:empty_toolchain",
toolchain_type = "@bazel_tools//tools/test:default_test_toolchain_type",
)
If that toolchain is registered earlier, things will work, as long as no-one tries to build with the constraint //gpu:large in their target platform.
Suggestion
Extend the meaning of use_target_platform_constrains in the toolchain rule to the following algorithm:
exec_constraints = toolchain.exec_compatible_with
if toolchain.use_target_platform_constrains:
unmatched_constraints = target_platform.constraints - toolchain.target_compatible_with
exec_constraints += unmatched_constraints
Existing rules with use_target_platform_constrains=True already have empty target_compatible_with and exec_compatible_with, so that will behave the same. In the example above, the GPU constraint will be added to the exec_compatible_with constraints as it is not matched by the target_compatible_with constraints.
Which category does this issue belong to?
Configurability
What underlying problem are you trying to solve with this feature?
Avoiding running tests on platforms that do not fulfill all the target constraints.
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
release 9.1.0
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
Have you found anything relevant by searching the web?
Implementation tracking issue #25160 for Execution platform selection for test actions in multi-platform builds.
The issue was found in buildbarn/bb-storage#357 where the @rules_go//go/toolchain:cgo_off constraint is problematic.
Any other information, logs, or outputs that you want to share?
No response
Description of the feature request:
Background
The example below will allow running a test built for wasm+gpu on a platform without any GPU.
Consider the following test toolchain:
With this toolchain, tests can run on a Linux amd64 machine when being built for wasm. The problem is that if the target platform has the constraints
["@platforms//cpu:wasm64", "//gpu:small"], it will also match.One can consider adding another toolchain:
If that toolchain is registered earlier, things will work, as long as no-one tries to build with the constraint
//gpu:largein their target platform.Suggestion
Extend the meaning of
use_target_platform_constrainsin thetoolchainrule to the following algorithm:Existing rules with
use_target_platform_constrains=Truealready have emptytarget_compatible_withandexec_compatible_with, so that will behave the same. In the example above, the GPU constraint will be added to theexec_compatible_withconstraints as it is not matched by thetarget_compatible_withconstraints.Which category does this issue belong to?
Configurability
What underlying problem are you trying to solve with this feature?
Avoiding running tests on platforms that do not fulfill all the target constraints.
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release?release 9.1.0
If
bazel info releasereturnsdevelopment versionor(@non-git), tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD?Have you found anything relevant by searching the web?
Implementation tracking issue #25160 for Execution platform selection for test actions in multi-platform builds.
The issue was found in buildbarn/bb-storage#357 where the
@rules_go//go/toolchain:cgo_offconstraint is problematic.Any other information, logs, or outputs that you want to share?
No response