Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make exec_compatible_with configurable #24932

Open
keith opened this issue Jan 15, 2025 · 2 comments
Open

Make exec_compatible_with configurable #24932

keith opened this issue Jan 15, 2025 · 2 comments
Assignees
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request untriaged

Comments

@keith
Copy link
Member

keith commented Jan 15, 2025

Description of the feature request:

In our project we want to represent multiple types of hardware constraints where targets can support A, B, or both, for example:

load("@bazel_skylib//lib:selects.bzl", "selects")

constraint_setting(name = "gpu")

constraint_value(
    name = "gpu_1",
    constraint_setting = ":gpu",
)

constraint_value(
    name = "gpu_2",
    constraint_setting = ":gpu",
)

selects.config_setting_group(
    name = "has_gpu",
    match_any = [
        ":gpu_1",
        ":gpu_2",
    ],
)

sh_test(
    name = "foo",
    srcs = ["foo.sh"],
    exec_compatible_with = [":has_gpu"],
)

Currently this fails with a strange error message:

ERROR: /Users/ksmiley/Downloads/repro/BUILD.bazel:15:29: //:gpu_1 is not a valid select() condition for //:has_gpu.
To inspect the select(), run: bazel query --output=build //:has_gpu.
For more help, see https://bazel.build/reference/be/functions#select.

ERROR: /Users/ksmiley/Downloads/repro/BUILD.bazel:23:8:
ERROR: Analysis of target '//:foo' failed; build aborted

But if you inline the select() that appears to be the core error.

I don't see another way to workaround this type of condition without introducing a parallel constraint_setting that I mirror on every platform that has one of the above constraints.

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

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?

No response

Any other information, logs, or outputs that you want to share?

No response

@fmeum
Copy link
Collaborator

fmeum commented Jan 15, 2025

Cc @gregestren

@keith
Copy link
Member Author

keith commented Jan 15, 2025

Another useful example is when you want to exclude 1 hardware type only, when you otherwise support N types. Ideally in that case you could write:

exec_compatible_with = select({
    "//:gpu_1": ["@platforms//:incompatible"],
    "//conditions:default": [],
})

Unlike my original example I don't see a clear workaround for this besides creating the combination of all hardware like is_not_gpu_1 etc

@katre katre assigned katre and unassigned sgowroji, iancha1992 and satyanandak Jan 15, 2025
@katre katre added the team-Configurability platforms, toolchains, cquery, select(), config transitions label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

6 participants