]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Add option to use -Og
authorSean Anderson <sean.anderson@seco.com>
Tue, 22 Feb 2022 17:19:25 +0000 (12:19 -0500)
committerTom Rini <trini@konsulko.com>
Fri, 25 Mar 2022 17:35:50 +0000 (13:35 -0400)
This adds support for using -Og when building U-Boot. According to the
gcc man page:

> -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 <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Kconfig
Makefile

diff --git a/Kconfig b/Kconfig
index 8159c596c018bb375f2a7578bde3b3bd00829fef..112745440b5a2a3ff4887838a602f2d8ca257604 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -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
index c04b58d46a799cad5742b300d14add598c1ffd9a..a981cc5e7d1b3bb9c68bde60e13de641ba161251 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -689,6 +689,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