Skip to content

Commit 291be19

Browse files
committed
docs: describe the new warning levels
When -Wextra was added, the warning levels changed their meaning. Add a description in the build option section and leave the security hardening section as mostly a pointer to it. Signed-off-by: Boyan Karatotev <[email protected]> Change-Id: Iabf2f598d0bf3e865c9b991c5d44d2acb9572bd5
1 parent d141e63 commit 291be19

File tree

2 files changed

+48
-32
lines changed

2 files changed

+48
-32
lines changed

docs/getting_started/build-options.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ Common build options
219219

220220
- ``E``: Boolean option to make warnings into errors. Default is 1.
221221

222+
When specifying higher warnings levels (``W=1`` and higher), this option
223+
defaults to 0. This is done to encourage contributors to use them, as they
224+
are expected to produce warnings that would otherwise fail the build. New
225+
contributions are still expected to build with ``W=0`` and ``E=1`` (the
226+
default).
227+
222228
- ``EL3_PAYLOAD_BASE``: This option enables booting an EL3 payload instead of
223229
the normal boot flow. It must specify the entry point address of the EL3
224230
payload. Please refer to the "Booting an EL3 payload" section for more
@@ -955,6 +961,43 @@ Common build options
955961
regrouped and put in the root Makefile. This flag can take the values 0 to 3,
956962
each level enabling more warning options. Default is 0.
957963

964+
This option is closely related to the ``E`` option, which enables
965+
``-Werror``.
966+
967+
- ``W=0`` (default)
968+
969+
Enables a wide assortment of warnings, most notably ``-Wall`` and
970+
``-Wextra``, as well as various bad practices and things that are likely to
971+
result in errors. Includes some compiler specific flags. No warnings are
972+
expected at this level for any build.
973+
974+
- ``W=1``
975+
976+
Enables warnings we want the generic build to include but are too time
977+
consuming to fix at the moment. It re-enables warnings taken out for
978+
``W=0`` builds (a few of the ``-Wextra`` additions). This level is expected
979+
to eventually be merged into ``W=0``. Some warnings are expected on some
980+
builds, but new contributions should not introduce new ones.
981+
982+
- ``W=2`` (recommended)
983+
984+
Enables warnings we want the generic build to include but cannot be enabled
985+
due to external libraries. This level is expected to eventually be merged
986+
into ``W=0``. Lots of warnings are expected, primarily from external
987+
libraries like zlib and compiler-rt, but new controbutions should not
988+
introduce new ones.
989+
990+
- ``W=3``
991+
992+
Enables warnings that are informative but not necessary and generally too
993+
verbose and frequently ignored. A very large number of warnings are
994+
expected.
995+
996+
The exact set of warning flags depends on the compiler and TF-A warning
997+
level, however they are all succinctly set in the top-level Makefile. Please
998+
refer to the `GCC`_ or `Clang`_ documentation for more information on the
999+
individual flags.
1000+
9581001
- ``WARMBOOT_ENABLE_DCACHE_EARLY`` : Boolean option to enable D-cache early on
9591002
the CPU after warm boot. This is applicable for platforms which do not
9601003
require interconnect programming to enable cache coherency (eg: single
@@ -1162,3 +1205,5 @@ Firmware update options
11621205
.. _DEN0115: https://developer.arm.com/docs/den0115/latest
11631206
.. _PSA FW update specification: https://developer.arm.com/documentation/den0118/a/
11641207
.. _PSA DRTM specification: https://developer.arm.com/documentation/den0113/a
1208+
.. _GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
1209+
.. _Clang: https://clang.llvm.org/docs/DiagnosticsReference.html

docs/process/security-hardening.rst

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -131,38 +131,9 @@ Several build options can be used to check for security issues. Refer to the
131131
overflows.
132132

133133
- The ``W`` build flag can be used to enable a number of compiler warning
134-
options to detect potentially incorrect code.
135-
136-
- W=0 (default value)
137-
138-
The ``Wunused`` with ``Wno-unused-parameter``, ``Wdisabled-optimization``
139-
and ``Wvla`` flags are enabled.
140-
141-
The ``Wunused-but-set-variable``, ``Wmaybe-uninitialized`` and
142-
``Wpacked-bitfield-compat`` are GCC specific flags that are also enabled.
143-
144-
- W=1
145-
146-
Adds ``Wextra``, ``Wmissing-format-attribute``, ``Wmissing-prototypes``,
147-
``Wold-style-definition`` and ``Wunused-const-variable``.
148-
149-
- W=2
150-
151-
Adds ``Waggregate-return``, ``Wcast-align``, ``Wnested-externs``,
152-
``Wshadow``, ``Wlogical-op``.
153-
154-
- W=3
155-
156-
Adds ``Wbad-function-cast``, ``Wcast-qual``, ``Wconversion``, ``Wpacked``,
157-
``Wpointer-arith``, ``Wredundant-decls`` and
158-
``Wswitch-default``.
159-
160-
Refer to the GCC or Clang documentation for more information on the individual
161-
options: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html and
162-
https://clang.llvm.org/docs/DiagnosticsReference.html.
163-
164-
NB: The ``Werror`` flag is enabled by default in TF-A and can be disabled by
165-
setting the ``E`` build flag to 0.
134+
options to detect potentially incorrect code. TF-A is tested with ``W=0`` but
135+
it is recommended to develop against ``W=2`` (which will eventually become the
136+
default).
166137

167138
.. rubric:: References
168139

0 commit comments

Comments
 (0)