summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2018-09-17 08:35:28 +0300
committerTom Rini <trini@konsulko.com>2018-09-26 04:50:34 +0300
commit5bc11922f1f8e0bfb27e8e260c7971405535c257 (patch)
tree07abdd51a12f9a5fb376631423f2fe0372f5843f /Makefile
parentc1523c65fc61d9ec8e779cbfb31314e94f500a3e (diff)
downloadu-boot-5bc11922f1f8e0bfb27e8e260c7971405535c257.tar.xz
Makefile: Use -fno-strict-aliasing globally
The -fstrict-aliasing option is implicitly enabled at levels -O2, -O3, -Os by GCC. This option allows the compiler to assume the strictest aliasing rules applicable to the language being compiled. For example, the practice of reading from a different union member than the one most recently written to (called "type-punning") is common. In this case, "type-punning" only works if the memory is accessed through the union type, but might not work by taking the address, casting the resulting pointer and dereferencing the result, which is an undefined behavior per the "strict aliasing rules". GCC's -Wstrict-aliasing (included in -Wall) option does not catch all cases, but does attempt to catch the more common pitfalls. So there are cases that GCC does not report but the codes are violating the "strict aliasing rules". Given lots of codes that may be written to rely on "type-punning", and Linux kernel disables it by -fno-strict-aliasing globally, since U-Boot currently does this on nds32/riscv/x86 builds only, extend this for all architecture builds. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index e38966edba..3561fb0ca3 100644
--- a/Makefile
+++ b/Makefile
@@ -372,7 +372,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__
KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
-Wno-format-security \
-fno-builtin -ffreestanding $(CSTD_FLAG)
-KBUILD_CFLAGS += -fshort-wchar
+KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing
KBUILD_AFLAGS := -D__ASSEMBLY__
# Don't generate position independent code