xcompile: Disable null pointer optimizations
According to the C standard, accessing the NULL pointer (memory at address zero) is undefined behaviour, and so GCC is allowed to optimize it out. Of course, accessing this memory location is sometimes necessary, so this optimization can be disabled using -fno-delete-null-pointer-checks. This is already done in coreboot, but adding it to xcompile will also disable it for all the payloads. For example, coreinfo compiled with LTO libpayload crashes when this flag isn't set, presumably because the compiler is optimizing something out that it shouldn't. Change-Id: I4492277f02418ade3fe7a75304e8e0611f49ef36 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38289 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
4519277ca2
commit
84c7d2dfea
|
@ -414,7 +414,6 @@ CFLAGS_common += -Wstrict-aliasing -Wshadow -Wdate-time -Wtype-limits -Wvla
|
||||||
CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
|
CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
|
||||||
CFLAGS_common += -ffunction-sections -fdata-sections -fno-pie
|
CFLAGS_common += -ffunction-sections -fdata-sections -fno-pie
|
||||||
ifeq ($(CONFIG_COMPILER_GCC),y)
|
ifeq ($(CONFIG_COMPILER_GCC),y)
|
||||||
CFLAGS_common += -fno-delete-null-pointer-checks
|
|
||||||
# Don't add these GCC specific flags when running scan-build
|
# Don't add these GCC specific flags when running scan-build
|
||||||
ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
|
ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
|
||||||
CFLAGS_common += -Wno-packed-not-aligned
|
CFLAGS_common += -Wno-packed-not-aligned
|
||||||
|
|
|
@ -221,7 +221,7 @@ SUBARCH_SUPPORTED+=${TSUPP-${TARCH}}
|
||||||
GCC_CC_${TARCH}:=${GCC}
|
GCC_CC_${TARCH}:=${GCC}
|
||||||
GCC_CFLAGS_${TARCH}:=${CFLAGS_GCC}
|
GCC_CFLAGS_${TARCH}:=${CFLAGS_GCC}
|
||||||
# Generally available for GCC's cc1:
|
# Generally available for GCC's cc1:
|
||||||
GCC_CFLAGS_${TARCH}+=-Wlogical-op
|
GCC_CFLAGS_${TARCH}+=-fno-delete-null-pointer-checks -Wlogical-op
|
||||||
GCC_ADAFLAGS_${TARCH}:=${CFLAGS_GCC}
|
GCC_ADAFLAGS_${TARCH}:=${CFLAGS_GCC}
|
||||||
GCC_COMPILER_RT_${TARCH}:=${CC_RT_GCC}
|
GCC_COMPILER_RT_${TARCH}:=${CC_RT_GCC}
|
||||||
GCC_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}
|
GCC_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}
|
||||||
|
|
Loading…
Reference in New Issue