Skip to content

Commit 85faf90

Browse files
tpudlikCQ Bot Account
authored and
CQ Bot Account
committed
pw_toolchain: Document conversion_warnings feature
Bug: 259746255 Change-Id: I296784dba145455382995153b314bc156431440a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/276892 Reviewed-by: Wyatt Hepler <hepler@google.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Commit-Queue: Ted Pudlik <tpudlik@google.com>
1 parent 0f049d6 commit 85faf90

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

pw_toolchain/bazel.rst

+42
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,48 @@ To integrate Pigweed's toolchain with `bazel_clang_tidy
168168
Now ``bazelisk build --config=clang-tidy //...`` will run clang-tidy for all
169169
``cc_library`` targets in your repo!
170170

171+
Conversion warnings
172+
===================
173+
By default, upstream Pigweed is built with `-Wconversion
174+
<https://clang.llvm.org/docs/DiagnosticsReference.html#wconversion>`__ enabled.
175+
However, this was not always the case, and many Pigweed targets contain
176+
``-Wconversion`` violations. (:bug:`259746255` tracks fixing all of these.)
177+
178+
Upstream allowlist
179+
------------------
180+
Do not add new ``-Wconversion`` violations to the Pigweed codebase.
181+
182+
If you write new code that fails to build because it includes a header with a
183+
pre-existing ``-Wconversion`` violation, try to fix the pre-existing violation.
184+
185+
As a last resort, you may add the ``features = ["-conversion_warnings"]`` (note
186+
the ``-``!) attribute to your ``cc_library`` or other build target:
187+
188+
.. code-block:: py
189+
190+
cc_library(
191+
name = "",
192+
features = ["-conversion_warnings"],
193+
)
194+
195+
This will disable ``-Wconversion`` for this target.
196+
197+
Downstream use
198+
--------------
199+
If you would like to enable ``-Wconversion`` in a downstream project that uses
200+
Pigweed's toolchains, add a `REPO.bazel
201+
<https://bazel.build/external/overview#repo.bazel>`__ file at the root of
202+
your project, with the following content:
203+
204+
.. code-block:: py
205+
206+
repo(
207+
features = ["conversion_warnings"],
208+
)
209+
210+
This will enable ``-Wconversion`` for all code in your project, but not for
211+
code coming from any external dependencies also built with Bazel.
212+
171213
.. _module-pw_toolchain-bazel-compiler-specific-logic:
172214

173215
-----------------------------

0 commit comments

Comments
 (0)