bazelbuild / bazelbuild/bazel

Unexpected results with select that mixes config_setting_group and config_setting

Open
#16,139 3 comments 0 reactions 0 assignees View on GitHub
P2 team-Documentation type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

### Description of the bug:

A `select` with some labels that refer to a `config_setting_group` and some labels that refer to a `config_setting` seems to never resolve to the `config_setting_group`, even when the same condition matches in other `select`s.

If Bazel considers such a combination ambiguous, it should say so. Although this behavior happens even in situations where I would consider the `config_setting_group` an unambiguous specialization.

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

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

config_setting(
name = "fastbuild",
values = {"compilation_mode": "fastbuild"},
)

selects.config_setting_group(
name = "mac_fastbuild",
match_all = [
":fastbuild",
"@platforms//os:osx",
],
)

sh_binary(
name = "test",
srcs = ["test.sh"],
args = select({
":mac_fastbuild": ["mac_fastbuild"],
}) + select({
":mac_fastbuild": ["mac_fastbuild"],
":fastbuild": ["fastbuild"],
}),
)
```

_test.sh_:
```
echo "$@"
```

On macOS, the expected output of `bazel run test` is "mac_fastbuild mac_fastbuild". But the actual result is "mac_fastbuild fastbuild".

### Which operating system are you running Bazel on?

macOS

### What is the output of `bazel info release`?

release 5.2.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 master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the case from BUILD.bazel and test.sh, focusing on the two selects that mix :mac_fastbuild and :fastbuild and on selects.config_setting_group. Trace how select resolves config_setting_group versus config_setting, then add or update coverage for the macOS fastbuild case. Done means the mixed select either chooses the specialized group consistently or reports the ambiguity clearly.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.