bazelbuild / bazelbuild/bazel

Skip an incompatible target only if there exists some configuration under which it can be built

Open
#31,019 5 comments 0 reactions 0 assignees View on GitHub
P3 team-Configurability type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

Skip an incompatible target only if there exists some configuration under which it can be built; otherwise fail the build as there is a target that is unbuildable by any configuration.

### Which category does this issue belong to?

Configurability

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

When a user runs `bazel build --platforms=//platforms:linux_x86_64 //...`, they expect to build everything in that closure that can be built for linux x86_64. This is useful as some targets have dependencies that are only compatible with certain platforms e.g. freebsd_arm64, and skipping makes sense here. However, this behavior can hide an unbuildable target introduced by a new dependency.

Consider the following example:

```
# BUILD.bazel

linux_image(
name = "linux_image",
efi = "//:efi_image", # transitions to uefi
)

efi_image(
name = "efi_image",
deps = [
...
"//:lib",
]
)

cc_library(
name = "lib",
srcs = [...],
deps = [
"...",
"//:new_lib", # new dependency gets added
],
)

# incompatible with uefi
cc_library(
name = "new_lib",
srcs = [...],
target_compatible_with = ["@platforms//os:linux"],
)
```

//:linux_image should be compatible with the requested platform, but it is skipped because a transitive dependency (//:new_lib) is incompatible in the uefi configuration introduced by the efi transition. Since that transition happens regardless of the top-level platform, no configuration can build //:linux_image. Skipping in this case hides an unconditionally broken dependency graph, so it should fail loudly.

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

Linux

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

release 8.5.1

### 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` ?

```text

```

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

https://github.com/bazelbuild/bazel/issues/16280
https://github.com/bazelbuild/bazel/issues/16280#issuecomment-1835575031
https://github.com/bazelbuild/bazel/issues/18707
https://github.com/bazelbuild/bazel/issues/18707#issuecomment-1819575576
https://github.com/bazelbuild/bazel/discussions/19200

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the example in BUILD.bazel and reproduce `bazel build --platforms=//platforms:linux_x86_64 //...` on Bazel 8.5.1. Read the related discussions in issues #16280 and #18707 to understand current incompatible-target handling and configuration transitions. Done means an unbuildable target is not silently skipped when no configuration can build it, while targets buildable under another configuration can still be skipped.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.