Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38291 )
Change subject: libpayload: Add support for link time optimization
......................................................................
libpayload: Add support for link time optimization
Link time optimization is a technique for whole-program optimization.
Instead of doing code generation during compilation, the compiler saves
its intermediate representation to the object files. During the final
linking step, it will then merge all the object files together and
perform optimizations on the entire program. This can often reduce the
final binary size, but also may increase the total compilation time.
This patch introduces a Kconfig option for enabling link time
optimization in libpayload. Since libpayload does no linking of its own,
its LTO archive files will contain only IR and no generated code.
Downstream projects will need to use LTO-aware tools when manipulating
the archives (eg. gcc-ar and gcc-nm), but otherwise do not need to use
LTO themselves -- the compiler will recognize which files are LTO and
which are not, so enabling this option should mostly be "drop in".
For example, when building coreinfo.elf using tinycurses libpayload:
binary size compilation time
default 149K 11.49s
LTO 125K 10.36s
In this case the total compilation time was actually shorter -- despite
the final linking step taking longer, this was offset by the shorter
compilation times for each individual file (since there is no code gen
until the very end).
Change-Id: I048f2ff6298ed0d891098942e1e8b29d35487b91
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M payloads/libpayload/Kconfig
M payloads/libpayload/Makefile.inc
2 files changed, 11 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/38291/1
diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig
index f7501e3..9312f19 100644
--- a/payloads/libpayload/Kconfig
+++ b/payloads/libpayload/Kconfig
@@ -80,6 +80,13 @@
endchoice
+config LTO
+ bool "Use link time optimization"
+ default n
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time.
+
config REMOTEGDB
bool "Remote GDB stub"
default n
diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc
index 1b7986c..ecf7937 100644
--- a/payloads/libpayload/Makefile.inc
+++ b/payloads/libpayload/Makefile.inc
@@ -65,6 +65,10 @@
CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
CFLAGS += -Wstrict-aliasing -Wshadow -Werror
+ifeq ($(CONFIG_LP_LTO),y)
+CFLAGS += -flto=$(CPUS) -fuse-linker-plugin -fno-fat-lto-objects
+endif
+
$(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
cmp $@ $< 2>/dev/null || cp $< $@
--
To view, visit https://review.coreboot.org/c/coreboot/+/38291
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I048f2ff6298ed0d891098942e1e8b29d35487b91
Gerrit-Change-Number: 38291
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-MessageType: newchange
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44675 )
Change subject: cpu/x86/mp_init: Add support for x86_64
......................................................................
cpu/x86/mp_init: Add support for x86_64
Fix compilation on x86_64.
Tested on HP Z220:
* Still boots on x86_32.
Change-Id: Id7190d24172803e40acaf1495ce20f3ea38016b0
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/cpu/x86/mp_init.c
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/44675/1
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index 5807831..da0002f 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -113,7 +113,7 @@
/* The SIPI vector is loaded at the SMM_DEFAULT_BASE. The reason is at the
* memory range is already reserved so the OS cannot use it. That region is
* free to use for AP bringup before SMM is initialized. */
-static const uint32_t sipi_vector_location = SMM_DEFAULT_BASE;
+static const uintptr_t sipi_vector_location = SMM_DEFAULT_BASE;
static const int sipi_vector_location_size = SMM_DEFAULT_SIZE;
struct mp_flight_plan {
@@ -339,16 +339,16 @@
setup_default_sipi_vector_params(sp);
/* Setup MSR table. */
- sp->msr_table_ptr = (uint32_t)&mod_loc[module_size];
+ sp->msr_table_ptr = (uintptr_t)&mod_loc[module_size];
sp->msr_count = num_msrs;
/* Provide pointer to microcode patch. */
- sp->microcode_ptr = (uint32_t)mp_params->microcode_pointer;
+ sp->microcode_ptr = (uintptr_t)mp_params->microcode_pointer;
/* Pass on ability to load microcode in parallel. */
if (mp_params->parallel_microcode_load)
sp->microcode_lock = 0;
else
sp->microcode_lock = ~0;
- sp->c_handler = (uint32_t)&ap_init;
+ sp->c_handler = (uintptr_t)&ap_init;
ap_count = &sp->ap_count;
atomic_set(ap_count, 0);
--
To view, visit https://review.coreboot.org/c/coreboot/+/44675
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Id7190d24172803e40acaf1495ce20f3ea38016b0
Gerrit-Change-Number: 44675
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38293 )
Change subject: coreinfo: Add support for link time optimization
......................................................................
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 125K to 122K.
Change-Id: I6feacdb911b52b946869bff369e03dcf72897c9f
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M payloads/coreinfo/Kconfig
M payloads/coreinfo/Makefile
2 files changed, 12 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/38293/1
diff --git a/payloads/coreinfo/Kconfig b/payloads/coreinfo/Kconfig
index fd4c1b4..5fb17bb 100644
--- a/payloads/coreinfo/Kconfig
+++ b/payloads/coreinfo/Kconfig
@@ -56,6 +56,13 @@
help
The version number of this payload.
+config LTO
+ bool "Use link time optimization"
+ default n
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time.
+
endmenu
menu "Modules"
diff --git a/payloads/coreinfo/Makefile b/payloads/coreinfo/Makefile
index 34c45d9..6452c00 100644
--- a/payloads/coreinfo/Makefile
+++ b/payloads/coreinfo/Makefile
@@ -90,9 +90,13 @@
include $(src)/.config
real-all: $(TARGET)
+ifeq ($(CONFIG_LTO),y)
+CFLAGS += -flto=$(CPUS) -fuse-linker-plugin -fno-fat-lto-objects
+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 https://review.coreboot.org/c/coreboot/+/38293
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6feacdb911b52b946869bff369e03dcf72897c9f
Gerrit-Change-Number: 38293
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange