Skip to content

Commit 94d4d60

Browse files
nohlsonezio-melottihugovk
authored
Add compiler warning tracking tooling failure remediation guidance (#1364)
Co-authored-by: Ezio Melotti <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent df76764 commit 94d4d60

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

development-tools/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Development tools
99
gdb
1010
clang
1111
coverity
12+
warnings

development-tools/warnings.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. warnings:
2+
3+
Tools for tracking compiler warnings
4+
====================================
5+
6+
.. highlight:: bash
7+
8+
The compiler warning tracking tooling is intended to alert developers about new
9+
compiler warnings introduced by their contributions. The tooling consists of
10+
a Python script which is ran by the following GitHub workflows:
11+
12+
* Ubuntu/build and test (:cpy-file:`.github/workflows/reusable-ubuntu.yml`)
13+
* macOS/build and test (:cpy-file:`.github/workflows/reusable-macos.yml`)
14+
15+
You can check the documentation for the :cpy-file:`Tools/build/check_warnings.py` tool
16+
by running::
17+
18+
python Tools/build/check_warnings.py --help
19+
20+
The script can be run locally by providing the compiler output file
21+
(where the output is saved) and the compiler output type
22+
(either ``json`` or ``clang``) to see a list of unique warnings::
23+
24+
python Tools/build/check_warnings.py --compiler-output-file-path=compiler_output.txt --compiler-output-type=json
25+
26+
.. note:: The ``-fdiagnostics-format=json`` flag is required when compiling with GCC
27+
for the script to properly parse the compiler output.
28+
29+
.. _warning-check-failure:
30+
31+
What to do if a warning check fails GitHub CI
32+
---------------------------------------------
33+
34+
The :cpy-file:`Tools/build/check_warnings.py` tool will fail if the compiler generates
35+
more or less warnings than expected for a given source file as defined in the
36+
platform-specific warning ignore file. The warning ignore file is either
37+
:cpy-file:`Tools/build/.warningignore_ubuntu` or
38+
:cpy-file:`Tools/build/.warningignore_macos` depending on the platform.
39+
40+
If a warning check fails with:
41+
42+
* Unexpected warnings
43+
* Attempt to refactor the code to avoid the warning.
44+
* If it is not possible to avoid the warning document in the PR why it is
45+
reasonable to ignore and add the warning to the platform-specific
46+
warning ignore file. If the file exists in the warning ignore file
47+
increment the count by the number of newly introduced warnings.
48+
* Unexpected improvements (less warnings)
49+
* Document in the PR that the change reduces the number of compiler
50+
warnings. Decrement the count in the platform-specific warning
51+
ignore file or remove the file if the count is now zero.

0 commit comments

Comments
 (0)