-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Motivation
Stop Starlark flags from propagating to the exec config by default.
i.e. on:
$ bazel build //foo --//my:flag=some_custom_value
stop compilers, code generators, and other tools from also building with --//my:flag=some_custom_value
.
The vast majority of the time these settings are intended for production code, not compiler tools. Passing them to tools compromises caching, making builds slower and more resource-heavy for no good reason.
Description
With --incompatible_exclude_starlark_flags_from_exec_config=true
, --//my:flag=some_custom_value
resets to its default value when building compiler tools, and any other exec-configured targets.
Incompatible Flag
--incompatible_exclude_starlark_flags_from_exec_config
Migration Guide
This only affects you if you need a Starlark flag to pass its value to exec-configured targets. While this isn't common, there are valid use cases. For example a flag that modifies rules_foo
behavior may want to apply to all rules_foo
targets, no matter their configuration.
To define custom exec propagation logic for a flag, do one of the following:
- (preferred) Add specific exec config logic to the flag definition. Part of a pending proposal. Not live yet, but we don't intend to flip this flag until that API is live
- Set
--experimental_propagate_custom_flag=//my:flag
(at the command line or in a.bazerlc
). With this set, the above example keeps the flag set tosome_custom_value
in the exec config. That's equivalent to--incompatible_exclude_starlark_flags_from_exec_config
being disabled for just this flag.
In which Bazel LTS version will this incompatible change be enabled?
Bazel 9
Additional Context
No response
TODO List
- Implement Starlark flag propagation API so migration step 1 is viable
- Flip the flag