Skip to content

--incompatible_exclude_starlark_flags_from_exec_config #26909

@gregestren

Description

@gregestren

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:

  1. (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
  2. 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 to some_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions