Stefan Reinauer submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Martin Roth: Looks good to me, approved Michael Niewöhner: Looks good to me, but someone else must approve
coreinfo: Add support for link time optimization

This introduces a Kconfig option for compiling coreinfo with LTO.
This option can be used independently of LTO in libpayload, though will
benefit most if that is enabled as well. If both are enabled, the
final size of coreinfo.elf is reduced from 95 KiB to 92 KiB.

Tested in QEMU and on Thinkpad T500.

Change-Id: I6feacdb911b52b946869bff369e03dcf72897c9f
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38293
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-by: Martin Roth <martinroth@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M payloads/coreinfo/Kconfig
M payloads/coreinfo/Makefile
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/payloads/coreinfo/Kconfig b/payloads/coreinfo/Kconfig
index eafb879..2c1f91c 100644
--- a/payloads/coreinfo/Kconfig
+++ b/payloads/coreinfo/Kconfig
@@ -42,6 +42,15 @@
help
The version number of this payload.

+config LTO
+ bool "Use link time optimization (LTO)"
+ default n
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time. This option
+ is most effective when LTO is also enabled in libpayload, which
+ is done separately.
+
endmenu

menu "Modules"
diff --git a/payloads/coreinfo/Makefile b/payloads/coreinfo/Makefile
index d842b46..cd58f39 100644
--- a/payloads/coreinfo/Makefile
+++ b/payloads/coreinfo/Makefile
@@ -76,9 +76,13 @@
include $(src)/.config
real-all: $(TARGET)

+ifeq ($(CONFIG_LTO),y)
+CFLAGS += -flto
+endif
+
$(TARGET): $(src)/.config $(coreinfo_obj)/config.h $(OBJS) libpayload
printf " LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n"
- $(LPCC) -o $@ $(OBJS)
+ $(LPCC) $(CFLAGS) -o $@ $(OBJS)
$(OBJCOPY) --only-keep-debug $@ $(TARGET).debug
$(OBJCOPY) --strip-debug $@
$(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@

To view, visit change 38293. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6feacdb911b52b946869bff369e03dcf72897c9f
Gerrit-Change-Number: 38293
Gerrit-PatchSet: 14
Gerrit-Owner: Jacob Garber <jgarber1@ualberta.ca>
Gerrit-Reviewer: David Hendricks <david.hendricks@gmail.com>
Gerrit-Reviewer: Martin Roth <martinroth@google.com>
Gerrit-Reviewer: Michael Niewöhner <foss@mniewoehner.de>
Gerrit-Reviewer: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-Reviewer: Stefan Reinauer <stefan.reinauer@coreboot.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus@gmail.com>
Gerrit-CC: Patrick Georgi <pgeorgi@google.com>
Gerrit-MessageType: merged