build system: Add various compiler flags that enable warnings on UB

Some types of Undefined Behavior can be determined statically at compile
time and gcc now has a set of flags that make it emit warnings in that
case instead of doing the __builtin_trap() / optimize / UD2-opcode dance
that silently breaks the resulting binary.

BUG=chromium:958270
BRANCH=none
TEST=abuild passes (probably not)

Change-Id: I3aa5ca00c9838cc7517160069310a1ef85372027
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32814
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Patrick Georgi 2019-05-15 21:39:57 +02:00
parent 556cc26337
commit 4100c2a6e3
1 changed files with 1 additions and 0 deletions

View File

@ -419,6 +419,7 @@ CFLAGS_common += -fno-delete-null-pointer-checks
ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),) ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
CFLAGS_common += -Wno-packed-not-aligned CFLAGS_common += -Wno-packed-not-aligned
CFLAGS_common += -fconserve-stack CFLAGS_common += -fconserve-stack
CFLAGS_common += -Wnull-dereference -Wreturn-type
# cf. commit f69a99db (coreboot: x86: enable gc-sections) # cf. commit f69a99db (coreboot: x86: enable gc-sections)
CFLAGS_common += -Wno-unused-but-set-variable CFLAGS_common += -Wno-unused-but-set-variable
endif endif