bazelbuild / bazelbuild/bazel

Duplicate builds due to transitions of targets that don't depend on build settings

Open
#13,281 8 comments 8 reactions 0 assignees View on GitHub
not stale P2 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 problem:

Targets that don't depend on a user defined build setting are effectively duplicated when depended upon by targets that depend on a build setting and use a configuration transition.

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

- Check out https://github.com/aherrmann/bazel-configuration-rebuild/commit/2be2a622a57b7428fe8741505ba27a07a9c6a3a4
- Follow the steps in the README:
The target `//:cat` is independent of the user defined build flag `//:flag`.
The target `//:flag_cat` on the other hand depends on the value of the flag and
on `//:cat` as well.

The target `//:cat` is only built once, and cached under the same action cache
key, if the configuration is set via command-line flag.

```
$ bazel clean --expunge; bazel build //:flag_cat --disk_cache=.cache/default --build_event_publish_all_actions --build_event_json_file=default.json

$ bazel clean --expunge; bazel build //:flag_cat --//:flag=different_flag --disk_cache=.cache/different --build_event_publish_all_actions --build_event_json_file=different.json

$ jq 'select(.id.actionCompleted.label == "//:cat")'

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction commit 2be2a622a57b7428fe8741505ba27a07a9c6a3a4 and follow its README commands for the transition targets. Investigate Bazel's configuration transitions and dependency analysis; done means an unaffected target such as //:cat is built once and reuses the same action-cache key across the transition builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.