Add option to build with -O3
PATCH 1/1 Add option to build with -O3
From: Jon Ringle <[email protected]>
Signed-off-by Jon Ringle <[email protected]>
--- Makefile | 2 ++ init/Kconfig | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
Makefile +2 -0
@@ -581,6 +581,8 @@ all: vmlinux ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) +else ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED +KBUILD_CFLAGS += -O3 else KBUILD_CFLAGS += -O2 endif
init/Kconfig +16 -3
@@ -1233,13 +1233,26 @@ source "usr/Kconfig" endif +choice + prompt "Optimize" + +config CC_OPTIMIZE_NORMAL + bool "Optimize Normal (-O2)" + help + Enabling this option will pass "-O2" to gcc config CC_OPTIMIZE_FOR_SIZE - bool "Optimize for size" + bool "Optimize for size (-Os)" help - Enabling this option will pass "-Os" instead of "-O2" to gcc + Enabling this option will pass "-Os" to gcc resulting in a smaller kernel. - If unsure, say N. +config CC_OPTIMIZE_FOR_SPEED + bool "Optimze for speed (-O3)" + help + Enabling this option will pass "-O3" to gcc + resulting in a larger kernel (but possibly faster) + +endchoice config SYSCTL bool
Signature · 1 line
1.8.5.4
Quoted 46 lines · On 2014-03-05 02:36, [email protected] wrote:
From: Jon Ringle <[email protected]>
Signed-off-by Jon Ringle <[email protected]>--- Makefile | 2 ++ init/Kconfig | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)Makefile +2
-0@@ -581,6 +581,8 @@ all: vmlinux ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) +else ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED +KBUILD_CFLAGS += -O3 else KBUILD_CFLAGS += -O2 endifinit/Kconfig +9
-3@@ -1233,13 +1233,26 @@ source "usr/Kconfig" endif +choice + prompt "Optimize" + +config CC_OPTIMIZE_NORMAL + bool "Optimize Normal (-O2)" + help + Enabling this option will pass "-O2" to gcc config CC_OPTIMIZE_FOR_SIZE - bool "Optimize for size" + bool "Optimize for size (-Os)" help - Enabling this option will pass "-Os" instead of "-O2" to gcc + Enabling this option will pass "-Os" to gcc resulting in a smaller kernel. - If unsure, say N.
init/Kconfig source "usr/Kconfig" · line 1258
Quoted 10 lines
init/Kconfig +7
-0+config CC_OPTIMIZE_FOR_SPEED + bool "Optimze for speed (-O3)" + help + Enabling this option will pass "-O3" to gcc + resulting in a larger kernel (but possibly faster) + +endchoice config SYSCTL bool
I would suggest putting a warning in the Kconfig text that this might make things break in new and unusual ways (and possibly making it depend on EXPERT). All of the cases of -O3 breaking userspace software that I have seen involve really edgy and complex (and often potentially ambiguous) code, and while the core kernel doesn't have much of this, there are a number drivers that do (The Synopsis DWC USB OTG driver immediately comes to mind, as well as a number of drivers from staging).