* [RFC PATCH] allow choosing -Os/-O2 separately for SPL and TPL
@ 2020-06-05 8:36 Rasmus Villemoes
2020-06-16 23:37 ` Simon Glass
0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2020-06-05 8:36 UTC (permalink / raw)
To: u-boot
It can be useful to build U-Boot proper with -O2, but still optimize
the SPL for size. So add separate config options for SPL and TPL.
I had to move the Makefile logic to config.mk, since otherwise
SPL_TPL_ didn't seem to be known. Unfortunately, the SPL translation
units end up getting both -O2 and -Os passed (assuming
CC_OPTIMIZE_FOR_SIZE=n, SPL_CC_OPTIMIZE_FOR_SIZE=y) - it ends up with
the intended effect, but it is still not very pretty.
My Kbuild fu is pretty weak; I wonder how the two uses of $(SPL_) in
the main Makefile works when apparently $(SPL_TPL_) didn't.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
Kconfig | 20 ++++++++++++++++++++
Makefile | 6 ------
config.mk | 6 ++++++
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/Kconfig b/Kconfig
index f698e0a94f..0468bd0089 100644
--- a/Kconfig
+++ b/Kconfig
@@ -66,6 +66,26 @@ config CC_OPTIMIZE_FOR_SIZE
This option is enabled by default for U-Boot.
+config SPL_CC_OPTIMIZE_FOR_SIZE
+ bool "Optimize SPL for size"
+ default y
+ depends on SPL
+ help
+ Enabling this option will pass "-Os" instead of "-O2" to gcc
+ resulting in a smaller U-Boot SPL image.
+
+ This option is enabled by default for U-Boot SPL.
+
+config TPL_CC_OPTIMIZE_FOR_SIZE
+ bool "Optimize TPL for size"
+ default y
+ depends on TPL
+ help
+ Enabling this option will pass "-Os" instead of "-O2" to gcc
+ resulting in a smaller U-Boot TPL image.
+
+ This option is enabled by default for U-Boot TPL.
+
config CC_COVERAGE
bool "Enable code coverage analysis"
depends on SANDBOX
diff --git a/Makefile b/Makefile
index 7c2067f35e..586d5d687a 100644
--- a/Makefile
+++ b/Makefile
@@ -645,12 +645,6 @@ ifeq ($(CONFIG_XTENSA),)
LDPPFLAGS += -ansi
endif
-ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
-else
-KBUILD_CFLAGS += -O2
-endif
-
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
diff --git a/config.mk b/config.mk
index caf0dd9b81..a3eb3f941e 100644
--- a/config.mk
+++ b/config.mk
@@ -70,6 +70,12 @@ RELFLAGS := $(PLATFORM_RELFLAGS)
PLATFORM_CPPFLAGS += $(RELFLAGS)
PLATFORM_CPPFLAGS += -pipe
+ifeq ($(CONFIG_$(SPL_TPL_)CC_OPTIMIZE_FOR_SIZE),y)
+KBUILD_CFLAGS += -Os
+else
+KBUILD_CFLAGS += -O2
+endif
+
LDFLAGS += $(PLATFORM_LDFLAGS)
LDFLAGS_FINAL += -Bstatic
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [RFC PATCH] allow choosing -Os/-O2 separately for SPL and TPL
2020-06-05 8:36 [RFC PATCH] allow choosing -Os/-O2 separately for SPL and TPL Rasmus Villemoes
@ 2020-06-16 23:37 ` Simon Glass
0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2020-06-16 23:37 UTC (permalink / raw)
To: u-boot
On Fri, 5 Jun 2020 at 02:37, Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> It can be useful to build U-Boot proper with -O2, but still optimize
> the SPL for size. So add separate config options for SPL and TPL.
>
> I had to move the Makefile logic to config.mk, since otherwise
> SPL_TPL_ didn't seem to be known. Unfortunately, the SPL translation
> units end up getting both -O2 and -Os passed (assuming
> CC_OPTIMIZE_FOR_SIZE=n, SPL_CC_OPTIMIZE_FOR_SIZE=y) - it ends up with
> the intended effect, but it is still not very pretty.
>
> My Kbuild fu is pretty weak; I wonder how the two uses of $(SPL_) in
> the main Makefile works when apparently $(SPL_TPL_) didn't.
They are defined in Makefile.spl and Kbuild/include.
But SPL_TPL_ is never defined unless CONFIG_SPL_BUILD is defined, i.e.
only in Makefile.spl I think.
+Masahiro Yamada who may know
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
> Kconfig | 20 ++++++++++++++++++++
> Makefile | 6 ------
> config.mk | 6 ++++++
> 3 files changed, 26 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-16 23:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 8:36 [RFC PATCH] allow choosing -Os/-O2 separately for SPL and TPL Rasmus Villemoes
2020-06-16 23:37 ` Simon Glass
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.