diff mbox series

[1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs

Message ID 20220222171925.1324520-1-sean.anderson@seco.com
State Accepted
Commit f38cb2aca7ab95c4be53eb54497f91ba8a35e4a9
Delegated to: Tom Rini
Headers show
Series [1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs | expand

Commit Message

Sean Anderson Feb. 22, 2022, 5:19 p.m. UTC
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(-)

Comments

Simon Glass March 12, 2022, 2:25 a.m. UTC | #1
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>
Tom Rini March 26, 2022, 2:46 a.m. UTC | #2
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!
diff mbox series

Patch

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