Skip to content

Commit

Permalink
bazel: Don't propagate flags to exec config
Browse files Browse the repository at this point in the history
This will improve cache hit rates, and also allow us to use
@bazel_tool//tools/cpp:link_extra_libs for pw_assert and pw_log
implementation targets (without these flags this does not work because
you invariably end up with circular dependencies).

Requires Bazel 8.

Bug: 234877642
Bug: 315871648
Change-Id: I503c501329638b666c54b8aedd0a294b8563b907
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/220812
Reviewed-by: Armando Montanez <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Jul 10, 2024
1 parent 1d190f2 commit 1fc9620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ common --incompatible_default_to_explicit_init_py
# Required for new toolchain resolution API.
build --incompatible_enable_cc_toolchain_resolution

# Don't propagate flags or defines to the exec config. This will become the
# default one day (https://github.com/bazelbuild/bazel/issues/22457) and will
# improve cache hit rates between builds targeting different platforms.
common --experimental_exclude_defines_from_exec_config
common --experimental_exclude_starlark_flags_from_exec_config

# Skip building or testing C++20 targets by default
# TODO: b/340568834 Remove when a proper solution is available.
build --build_tag_filters=-requires_cxx_20
Expand Down
6 changes: 4 additions & 2 deletions docs/build_system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,10 @@ This can be added in a couple ways:
<https://bazel.build/reference/be/c-cpp#cc_binary.link_extra_lib>`_. Set
the ``@bazel_tools//tools/cpp:link_extra_libs`` label flag to point to
``@pigweed//pw_build:default_link_extra_lib``, probably using `bazelrc
<https://bazel.build/run/bazelrc>`_. This is only supported in Bazel 7.0.0
or newer.
<https://bazel.build/run/bazelrc>`_. This is only likely to work if you
specify the ``--experimental_exclude_starlark_flags_from_exec_config``
flag, available in Bazel 8 and newer; see `bazelbuild/bazel#22457
<https://github.com/bazelbuild/bazel/issues/22457>`__.

The con is that these libraries are linked into *all* C++ binaries that are
part of your project's build, including ones that have no dependencies on
Expand Down

0 comments on commit 1fc9620

Please sign in to comment.