From c31afb2e2e22786afe38390601b9b8aa7fe4453a Mon Sep 17 00:00:00 2001 From: Andy Deng Date: Sat, 2 Apr 2016 01:22:10 +0800 Subject: [PATCH] Fix gcc-4.7.4 and above led to device booting error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In gcc version updated to 4.7.4, when using standard optimization (-O2) compile code, our device exception reboot at runtime. When using gcc 4.8.0 and above, device could not even start, and this problem also appeared on lge mako. When I check gcc-4.9.3 official manual, I notice that ftree-xxx optimization may cause very serious problem. I tried to remove these -ftree-xxx optimization flag when compiling the kernel using gcc-4.9.3, I found -ftree- vrp led to the device can not start. gcc-4.9.3 manual is this description for -ftree-vrp: > Perform Value Range Propagation on trees. This is similar to the constant prop- agation pass, but instead of values, ranges of values are propagated. This allows the optimizers to remove unnecessary range checks like array bound checks and null pointer checks. This is enabled by default at ‘-O2’ and higher. Null pointer check elimination is only done if ‘-fdelete-null-pointer-checks’ is enabled. To fix errors, use -fno-tree-vrp when compiling the kernel. Signed-off-by: Andy Deng --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 24efbdef..f5f7d91a 100644 --- a/Makefile +++ b/Makefile @@ -602,6 +602,8 @@ endif KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) +KBUILD_CFLAGS += $(call cc-option, -fno-tree-vrp) + ifdef CONFIG_DEBUG_INFO KBUILD_CFLAGS += -g KBUILD_AFLAGS += -gdwarf-2