summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2024-08-22 23:04:14 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-08-29 13:56:39 +0000
commit86dadcd52aaf0db59d4f770a6ff8527ed681e86e (patch)
treeee3239c0d981b6e08832e5badb7d910c8c361e59
parentaf0da957f59d77f9120e19dfc8a29909180d097a (diff)
lib/rmodules: Add support for LTO
Change-Id: I9cdda036f330486370e8c4120be5b6a0fd982e99 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/84038 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/lib/Makefile.mk4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/Makefile.mk b/src/lib/Makefile.mk
index 89e5b65aef..40df2b8f56 100644
--- a/src/lib/Makefile.mk
+++ b/src/lib/Makefile.mk
@@ -314,7 +314,11 @@ RMODULE_LDFLAGS := -z defs -Bsymbolic
# rmdoule is named $(1).rmod
define rmodule_link
$(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(3)) $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) | $$(RMODTOOL)
+ifeq ($(CONFIG_LTO),y)
+ $$(CC_rmodules_$(3)) $$(CPPFLAGS_rmodules_$(3)) $$(CFLAGS_rmodules_$(3)) $$(LDFLAGS_rmodules_$(3):%=-Wl,%) $$(COMPILER_RT_FLAGS_rmodules_$(3):%=-Wl,%) $(RMODULE_LDFLAGS) $($(1)-ldflags:%=-Wl,%) -T $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) -o $$@ -Wl,--whole-archive -Wl,--start-group $(filter-out %.ld,$(2)) -Wl,--no-whole-archive $$(COMPILER_RT_rmodules_$(3)) -Wl,--end-group
+else
$$(LD_rmodules_$(3)) $$(LDFLAGS_rmodules_$(3)) $(RMODULE_LDFLAGS) $($(1)-ldflags) -T $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --no-whole-archive $$(COMPILER_RT_rmodules_$(3)) --end-group
+endif
$$(NM_rmodules_$(3)) -n $$@ > $$(basename $$@).map
endef