Skip to content

Commit

Permalink
Fix gcc-4.7.4 and above led to device booting error
Browse files Browse the repository at this point in the history
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 <theandy.deng@gmail.com>
  • Loading branch information
andytimes committed Apr 1, 2016
1 parent 1d16f16 commit c31afb2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c31afb2

Please sign in to comment.