Implement configuration settings that pertain to a single binary
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
It would be nice if one could implement configuration fragments that pertain to a part of the configured target graph.
The use case is that some projects want to compile a binary in different configurations, but not necessarily its dependencies. For example, one might want to compile a C++ binary with some sort of sanitizer. The natural place for the "which sanitizer to use" knob is the configuration, but that propagates to the whole transitive closure of the binary, even to places which are obviously unaffected by it (for example, a genrule that generates a source file) or to places where the decision as to which sanitizer to use is different (for example, another binary in the `data=` attribute.
So it looks like there is some room for the concept of "configuration variable that applies to whatever is built into a binary":.
There are ways one could work around this: for example, one could write their own custom C++ rule that has "remove sanitizer" transition for every dependency that's not through `deps=`, but that's only a partial answer, because one could imagine cases where this flag needs to be removed from `deps=`, too (for example, if it's a genrule that generates an object file)
Implementing this purely in Starlark isn't possible because it requires knowing the rule class on both ends of the dependency edge and neither outgoing nor incoming transitions can do that.
### What underlying problem are you trying to solve with this feature?
_No response_
### Which operating system are you running Bazel on?
_No response_
### What is the output of `bazel info release`?
_No response_
### 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
Research direction
The issue names no files, tests, or entry points. Start by studying Bazel configuration transitions and how dependency edges are analyzed, including the limits of incoming and outgoing Starlark transitions. Done means supporting configuration fragments scoped to what is built into a binary without propagating them through unrelated dependencies.
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
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100