All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs
@ 2022-02-22 17:19 Sean Anderson
  2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sean Anderson @ 2022-02-22 17:19 UTC (permalink / raw)
  To: u-boot, Tom Rini
  Cc: Oleh Kravchenko, Simon Glass, Sean Anderson, Marek Vasut,
	Nobuhiro Iwamatsu

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.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 Kconfig              | 17 ++++++++++++++---
 Makefile             |  4 +++-
 arch/sh/lib/Makefile |  2 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index 9dd9ec7f6d..8159c596c0 100644
--- a/Kconfig
+++ b/Kconfig
@@ -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
diff --git a/Makefile b/Makefile
index 4b152249ca..1d3331c69f 100644
--- a/Makefile
+++ b/Makefile
@@ -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
 
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index 9618da1cb3..e7520a328d 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] Add option to use -Og
  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
  2022-03-12  2:25   ` Simon Glass
  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
  2 siblings, 2 replies; 8+ messages in thread
From: Sean Anderson @ 2022-02-22 17:19 UTC (permalink / raw)
  To: u-boot, Tom Rini; +Cc: Oleh Kravchenko, Simon Glass, Sean Anderson

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs
  2022-02-22 17:19 [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs Sean Anderson
  2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
@ 2022-03-12  2:25 ` Simon Glass
  2022-03-26  2:46 ` Tom Rini
  2 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2022-03-12  2:25 UTC (permalink / raw)
  To: Sean Anderson
  Cc: U-Boot Mailing List, Tom Rini, Oleh Kravchenko, Marek Vasut,
	Nobuhiro Iwamatsu

On Tue, 22 Feb 2022 at 10:20, Sean Anderson <sean.anderson@seco.com> wrote:
>
> 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.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
>  Kconfig              | 17 ++++++++++++++---
>  Makefile             |  4 +++-
>  arch/sh/lib/Makefile |  2 +-
>  3 files changed, 18 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add option to use -Og
  2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
@ 2022-03-12  2:25   ` Simon Glass
  2022-03-14 15:36     ` Sean Anderson
  2022-03-26  2:46   ` Tom Rini
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Glass @ 2022-03-12  2:25 UTC (permalink / raw)
  To: Sean Anderson; +Cc: U-Boot Mailing List, Tom Rini, Oleh Kravchenko

On Tue, 22 Feb 2022 at 10:20, Sean Anderson <sean.anderson@seco.com> wrote:
>
> 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(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

But how about an update in doc/ ?

Regards,
Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add option to use -Og
  2022-03-12  2:25   ` Simon Glass
@ 2022-03-14 15:36     ` Sean Anderson
  2022-03-14 15:46       ` Tom Rini
  0 siblings, 1 reply; 8+ messages in thread
From: Sean Anderson @ 2022-03-14 15:36 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List, Tom Rini, Oleh Kravchenko



On 3/11/22 9:25 PM, Simon Glass wrote:
> On Tue, 22 Feb 2022 at 10:20, Sean Anderson <sean.anderson@seco.com> wrote:
>>
>> 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(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add option to use -Og
  2022-03-14 15:36     ` Sean Anderson
@ 2022-03-14 15:46       ` Tom Rini
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2022-03-14 15:46 UTC (permalink / raw)
  To: Sean Anderson; +Cc: Simon Glass, U-Boot Mailing List, Oleh Kravchenko

[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]

On Mon, Mar 14, 2022 at 11:36:54AM -0400, Sean Anderson wrote:
> 
> 
> On 3/11/22 9:25 PM, Simon Glass wrote:
> > On Tue, 22 Feb 2022 at 10:20, Sean Anderson <sean.anderson@seco.com> wrote:
> >>
> >> 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(+)
> > 
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> > 
> > 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.

A follow-up to note somewhere under doc/ about this would be good.  I'll
pick up the series for next soon.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs
  2022-02-22 17:19 [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs Sean Anderson
  2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
  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
  2 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2022-03-26  2:46 UTC (permalink / raw)
  To: Sean Anderson
  Cc: u-boot, Oleh Kravchenko, Simon Glass, Marek Vasut, Nobuhiro Iwamatsu

[-- Attachment #1: Type: text/plain, Size: 406 bytes --]

On Tue, Feb 22, 2022 at 12:19:24PM -0500, Sean Anderson wrote:

> 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.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add option to use -Og
  2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
  2022-03-12  2:25   ` Simon Glass
@ 2022-03-26  2:46   ` Tom Rini
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Rini @ 2022-03-26  2:46 UTC (permalink / raw)
  To: Sean Anderson; +Cc: u-boot, Oleh Kravchenko, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 719 bytes --]

On Tue, Feb 22, 2022 at 12:19:25PM -0500, Sean Anderson wrote:

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

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-26  2:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 17:19 [PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs Sean Anderson
2022-02-22 17:19 ` [PATCH 2/2] Add option to use -Og Sean Anderson
2022-03-12  2:25   ` 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

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.