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

Incompatible targets with selects on a label flag config produce spurious "is not a valid select() condition" errors, are not skipped #23003

Open
tpudlik opened this issue Jul 12, 2024 · 5 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@tpudlik
Copy link
Contributor

tpudlik commented Jul 12, 2024

Description of the bug:

A target with a select statement referencing a config_setting based on a label_flag will not be correctly detected as incompatible with the target platform. Instead, you get the message <config setting> is not a valid select() condition for //:library_with_select.

This is particularly severe because it breaks incompatible target skipping. Instead of skipping the incompatible target, Bazel prints the error message above.

This bug is a little hard to understand based on this description, but it's easy to reproduce. See https://github.com/tpudlik/not_a_valid_select for a simple BUILD.bazel file and repro steps.

Which category does this issue belong to?

Configurability

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://github.com/tpudlik/not_a_valid_select

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 8.0.0-pre.20240618.2

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 ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

I don't believe this ever worked. I get the same error on Bazel 7.2.1, too.

Have you found anything relevant by searching the web?

No response

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

This bug may sound a little academic, but it's not! We've run into this in a real project (http://pwrev.dev/221036).

@github-actions github-actions bot added the team-Configurability platforms, toolchains, cquery, select(), config transitions label Jul 12, 2024
copybara-service bot pushed a commit to google/pigweed that referenced this issue Jul 12, 2024
This is intended as a workaround for
bazelbuild/bazel#23003 only, and will be
deleted soon. Do not depend on any targets introduced in this CL from
outside Pigweed!

I verified that with this change and updates to
`target_compatible_with`, http://pwrev.dev/221036 doesn't get any
Bazel-level errors. (It still doesn't build, but the errors I get come
from the C++ compiler, not Bazel---something about missing headers.)

Bug: 352808542
Change-Id: I645f2e8b56691d080b661a9d8e4021b1346ae375
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/222812
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
@tpudlik
Copy link
Contributor Author

tpudlik commented Jul 15, 2024

@katre FYI

@katre
Copy link
Member

katre commented Jul 15, 2024

Also @gregestren and @AustinSchuh

@gregestren gregestren added the P1 I'll work on this now. (Assignee required) label Jul 15, 2024
@gregestren gregestren self-assigned this Jul 15, 2024
@gregestren
Copy link
Contributor

Weird. It's got to be something with label_flag acting alias-like and somehow not propagating the right info.

I'll dig in and diagnose.

@gregestren gregestren assigned aranguyen and unassigned gregestren Jul 17, 2024
@gregestren
Copy link
Contributor

@aranguyen is looking now.

dpemmons pushed a commit to dpemmons/pigweed-quickstart that referenced this issue Aug 5, 2024
This is intended as a workaround for
bazelbuild/bazel#23003 only, and will be
deleted soon. Do not depend on any targets introduced in this CL from
outside Pigweed!

I verified that with this change and updates to
`target_compatible_with`, http://pwrev.dev/221036 doesn't get any
Bazel-level errors. (It still doesn't build, but the errors I get come
from the C++ compiler, not Bazel---something about missing headers.)

Original-Bug: 352808542
Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/222812
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>

https://pigweed.googlesource.com/pigweed/pigweed
pigweed, pw_toolchain Rolled-Commits: e15bd2067e7a244..990ed9bb2f16bec
Roller-URL: https://ci.chromium.org/b/8742574672140296577
GitWatcher: ignore
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I531f21e6c3204955c91359c430c0ad49c124e1e0
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/quickstart/bazel/+/222643
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Bot-Commit: Pigweed Roller <pigweed-roller@pigweed-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Pigweed Roller <pigweed-roller@pigweed-service-accounts.iam.gserviceaccount.com>
@aranguyen
Copy link
Contributor

Hi all, the error is being thrown here due to null ConfigMatchingProvider from ConfiguredTarget.getProvider(ConfigMatchingProvider.class)

The ConfiguredTarget is being produced by ConfiguredTargetAndDataProducer which has been noted to possibly produced a different configuration for alias. And Bazel treatslabel_flag as an alias. In addition, the current implementation of ConfigSettings probably also needs modification to work with label_flag. Tracing back to a few previous release, this issue was also observed.

For immediate usage, please use constraint_setting as a workaround. I will lower the priority of this issue but we're planning to pick them up in the future as this seems to be an oversight and there aren't obvious reason why label_flag can't be used with config_setting.

@aranguyen aranguyen added P2 We'll consider working on this in future. (Assignee optional) and removed P1 I'll work on this now. (Assignee required) labels Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

No branches or pull requests

7 participants