`config_setting` false positive when `label_flag` points at an `alias`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
If a `config_setting` is set up to detect whether a `label_flag` points to a particular target, it will not fire if that target is pointed to via an alias.
### 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.
Consider the following BUILD file, and assume a file `main.cc` exists.
```
label_flag(
name = "testflag",
build_setting_default = ":one",
)
config_setting(
name = "testflag_one",
flag_values = {
"//:testflag": "//:one",
},
)
config_setting(
name = "testflag_two",
flag_values = {
"//:testflag": "//:two",
},
)
cc_library(
name = "one",
)
cc_library(
name = "two",
)
alias(
name = "alias_for_one",
actual = ":one",
)
cc_binary(
name = "which",
srcs = select({
":testflag_one": ["main.cc"],
":testflag_two": ["doesntexist.cc"],
"//conditions:default": ["alsodoesntexist.cc"],
}),
)
```
Running,
```
bazel build --//:testflag=:one :which
```
builds `main.cc`, as expected. Running,
```
bazel build --//:testflag=:two :which
```
returns an error, `missing input file '//:doesntexist.cc'`. This is also expected.
Running,
```
bazel build --/:testflag=:alias_for_one :which
```
returns an error, `missing input file '//:alsodoesntexist.cc'`. This is *unexpected*. The `testflag` does point to the expected target, it just does so through an alias.
### Which operating system are you running Bazel on?
Linux
### What is the output of `bazel info release`?
release 8.0.0-pre.20240108.6
### 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_
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No, I don't believe this ever worked.
### Have you found anything relevant by searching the web?
This is related to https://github.com/bazelbuild/bazel/issues/13463. That issue was about false negatives arising when the _key_ in `config_setting.flag_value` was an alias. This issue is about false negatives when the _value_ in `config_setting.flag_values` is an alias.
### Any other information, logs, or outputs that you want to share?
I'd appreciate if someone knowledgeable (@lberki ?) could comment on whether this is a relatively trivial issue, or profoundly intractable.
Contributor guide
Assessment
This issue has not been assessed yet.