Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs
PATCH 1/2 Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs
This adds a separate CONFIG_CC_OPTIMIZE_FOR_SPEED option in a choice, in preparation for adding another optimization option. Also convert SH's makefile to use this new option.
---
Kconfig | 17 ++++++++++++++--- Makefile | 4 +++- arch/sh/lib/Makefile | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-)
Kconfig +14 -3
@@ -72,15 +72,26 @@ config CLANG_VERSION int default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) +choice + prompt "Optimization level" + default CC_OPTIMIZE_FOR_SIZE + config CC_OPTIMIZE_FOR_SIZE bool "Optimize for size" - default y help - Enabling this option will pass "-Os" instead of "-O2" to gcc - resulting in a smaller U-Boot image. + Enabling this option will pass "-Os" to gcc, resulting in a smaller + U-Boot image. This option is enabled by default for U-Boot. +config CC_OPTIMIZE_FOR_SPEED + bool "Optimize for speed" + help + Enabling this option will pass "-O2" to gcc, resulting in a faster + U-Boot image. + +endchoice + config OPTIMIZE_INLINING bool "Allow compiler to uninline functions marked 'inline' in full U-Boot" help
Makefile +3 -1
@@ -682,7 +682,9 @@ endif ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os -else +endif + +ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED KBUILD_CFLAGS += -O2 endif
arch/sh/lib/Makefile +1 -1
@@ -12,7 +12,7 @@ obj-$(CONFIG_CMD_SH_ZIMAGEBOOT) += zimageboot.o udivsi3-y := udivsi3_i4i-Os.o -ifneq ($(CONFIG_CC_OPTIMIZE_FOR_SIZE),y) +ifeq ($(CONFIG_CC_OPTIMIZE_FOR_SPEED),y) udivsi3-$(CONFIG_CPU_SH4) := udivsi3_i4i.o endif udivsi3-y += udivsi3.o
Signature · 1 line
2.25.1
PATCH 2/2 Add option to use -Og
This adds support for using -Og when building U-Boot. According to the gcc man page:
Quoted 3 lines
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
This optimization level is roughly -O1 minus a few additional optimizations. It provides a noticably better debugging experience, with many fewer variables <optimized out>.
---
Kconfig | 6 ++++++ Makefile | 4 ++++ 2 files changed, 10 insertions(+)
Kconfig +6 -0
@@ -90,6 +90,12 @@ config CC_OPTIMIZE_FOR_SPEED Enabling this option will pass "-O2" to gcc, resulting in a faster U-Boot image. +config CC_OPTIMIZE_FOR_DEBUG + bool "Optimize for debugging" + help + Enabling this option will pass "-Og" to gcc, enabling optimizations + which don't interfere with debugging. + endchoice config OPTIMIZE_INLINING
Makefile +4 -0
@@ -688,6 +688,10 @@ ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED KBUILD_CFLAGS += -O2 endif +ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUG +KBUILD_CFLAGS += -Og +endif + LTO_CFLAGS := LTO_FINAL_LDFLAGS := export LTO_CFLAGS LTO_FINAL_LDFLAGS
Signature · 1 line
2.25.1
Re: [PATCH 2/2] Add option to use -Og
Quoted 12 lines · Sean Anderson
This adds support for using -Og when building U-Boot. According to the gcc man page:
Quoted 3 lines
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
This optimization level is roughly -O1 minus a few additional optimizations. It provides a noticably better debugging experience, with many fewer variables <optimized out>.
Quoted 6 lines
Signed-off-by Sean Anderson <[email protected]>---
Kconfig | 6 ++++++ Makefile | 4 ++++ 2 files changed, 10 insertions(+)
But how about an update in doc/ ?
Regards,
Simon
Re: [PATCH 2/2] Add option to use -Og
Quoted 16 lines · Simon Glass
Quoted 15 lines · Sean Anderson
This adds support for using -Og when building U-Boot. According to the gcc man page:
Quoted 3 lines
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
This optimization level is roughly -O1 minus a few additional optimizations. It provides a noticably better debugging experience, with many fewer variables <optimized out>.
Signed-off-by Sean Anderson <[email protected]>---
Quoted 7 lines
Quoted 3 lines
Kconfig | 6 ++++++ Makefile | 4 ++++ 2 files changed, 10 insertions(+)Reviewed-by Simon Glass <[email protected]>But how about an update in doc/ ?
What should be updated? As far as I can tell, optimization level is not otherwise documented. IMO the Kconfig does a reasonable job of documentation.
--Sean
Re: [PATCH 2/2] Add option to use -Og
Quoted 23 lines · Sean Anderson
Quoted 20 lines · Simon Glass
Quoted 18 lines · Sean Anderson
This adds support for using -Og when building U-Boot. According to the gcc man page:
Quoted 3 lines
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
This optimization level is roughly -O1 minus a few additional optimizations. It provides a noticably better debugging experience, with many fewer variables <optimized out>.
Signed-off-by Sean Anderson <[email protected]>---
Kconfig | 6 ++++++ Makefile | 4 ++++ 2 files changed, 10 insertions(+)
Quoted 7 lines
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>But how about an update in doc/ ?
What should be updated? As far as I can tell, optimization level is not otherwise documented. IMO the
Kconfigdoes a reasonable job of documentation.
A follow-up to note somewhere under doc/ about this would be good. I'll pick up the series for next soon.
Signature · 1 line
Tom
Re: [PATCH 2/2] Add option to use -Og
In reply to Sean AndersonQuoted 7 lines · Sean Anderson
This adds support for using -Og when building U-Boot. According to the gcc man page:
Quoted 3 lines
-Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
Quoted 6 lines
This optimization level is roughly -O1 minus a few additional optimizations. It provides a noticably better debugging experience, with many fewer variables <optimized out>.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
Quoted 5 lines · Sean Anderson
This adds a separate
CONFIG_CC_OPTIMIZE_FOR_SPEEDoption in a choice, in preparation for adding another optimization option. Also convert SH's makefile to use this new option.
Quoted 7 lines
Signed-off-by Sean Anderson <[email protected]>---
Kconfig | 17 ++++++++++++++--- Makefile | 4 +++- arch/sh/lib/Makefile | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-)
Quoted 6 lines · Sean Anderson
This adds a separate
CONFIG_CC_OPTIMIZE_FOR_SPEEDoption in a choice, in preparation for adding another optimization option. Also convert SH's makefile to use this new option.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom