[PATCH] um: Support LTO

From: Peter Foley
Date: Fri Jan 13 2023 - 12:03:18 EST


Only a handful of changes are necessary to get it to work.

Signed-off-by: Peter Foley <pefoley2@xxxxxxxxxxx>
---
arch/um/Kconfig | 2 ++
arch/um/Makefile | 2 +-
arch/x86/um/vdso/Makefile | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index ad4ff3b0e91e..7c94ca7ff758 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -25,6 +25,8 @@ config UML
select GENERIC_IRQ_SHOW
select GENERIC_CPU_DEVICES
select HAVE_GCC_PLUGINS
+ select ARCH_SUPPORTS_LTO_CLANG
+ select ARCH_SUPPORTS_LTO_CLANG_THIN
select TRACE_IRQFLAGS_SUPPORT
select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK
diff --git a/arch/um/Makefile b/arch/um/Makefile
index f1d4d67157be..a41dde204b08 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -142,7 +142,7 @@ endif
LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt))

# Used by link-vmlinux.sh which has special support for um link
-export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
+export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO)
export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK)

# When cleaning we don't include .config, so we don't include
diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile
index 6fbe97c52c99..6825e146a62f 100644
--- a/arch/x86/um/vdso/Makefile
+++ b/arch/x86/um/vdso/Makefile
@@ -61,7 +61,7 @@ CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
#
quiet_cmd_vdso = VDSO $@
cmd_vdso = $(CC) -nostdlib -o $@ \
- $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
+ $(CC_FLAGS_LTO) $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'


---
base-commit: d9fc1511728c15df49ff18e49a494d00f78b7cd4
change-id: 20230113-umlto-c7f6731306e7

Best regards,
--
Peter Foley <pefoley2@xxxxxxxxxxx>