All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: u-boot@lists.denx.de, Tom Rini <trini@konsulko.com>
Cc: Oleh Kravchenko <oleg@kaa.org.ua>, Simon Glass <sjg@chromium.org>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH 2/2] Add option to use -Og
Date: Tue, 22 Feb 2022 12:19:25 -0500	[thread overview]
Message-ID: <20220222171925.1324520-2-sean.anderson@seco.com> (raw)
In-Reply-To: <20220222171925.1324520-1-sean.anderson@seco.com>

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>
---

 Kconfig  | 6 ++++++
 Makefile | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/Kconfig b/Kconfig
index 8159c596c0..112745440b 100644
--- 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
diff --git a/Makefile b/Makefile
index 1d3331c69f..7242eafc1e 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.25.1


  reply	other threads:[~2022-02-22 17:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 17:19 [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs Sean Anderson
2022-02-22 17:19 ` Sean Anderson [this message]
2022-03-12  2:25   ` [PATCH 2/2] Add option to use -Og Simon Glass
2022-03-14 15:36     ` Sean Anderson
2022-03-14 15:46       ` Tom Rini
2022-03-26  2:46   ` Tom Rini
2022-03-12  2:25 ` [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs Simon Glass
2022-03-26  2:46 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220222171925.1324520-2-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=oleg@kaa.org.ua \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.