Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a15c6ebb authored by Sami Tolvanen's avatar Sami Tolvanen Committed by Alistair Delva
Browse files

ANDROID: add support for ThinLTO

This change adds support for ThinLTO, which greatly improves build times
over full LTO while retaining most of the performance benefits:

  https://clang.llvm.org/docs/ThinLTO.html



Bug: 145210207
Change-Id: I8bfc19028266077be2bc1fb5c2bc001b599d3214
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 7e0ea2a7
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -813,10 +813,16 @@ LDFLAGS_vmlinux += --gc-sections
endif

ifdef CONFIG_LTO_CLANG
lto-clang-flags	:= -flto -fvisibility=hidden
ifdef CONFIG_THINLTO
lto-clang-flags	:= -flto=thin
KBUILD_LDFLAGS	+= --thinlto-cache-dir=.thinlto-cache
else
lto-clang-flags	:= -flto
endif
lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit)

# allow disabling only clang LTO where needed
DISABLE_LTO_CLANG := -fno-lto -fvisibility=default
DISABLE_LTO_CLANG := -fno-lto
export DISABLE_LTO_CLANG
endif

@@ -829,7 +835,7 @@ export LTO_CFLAGS DISABLE_LTO
endif

ifdef CONFIG_CFI_CLANG
cfi-clang-flags	+= -fsanitize=cfi $(call cc-option, -fsplit-lto-unit)
cfi-clang-flags	+= -fsanitize=cfi
DISABLE_CFI_CLANG := -fno-sanitize=cfi
ifdef CONFIG_MODULES
cfi-clang-flags	+= -fsanitize-cfi-cross-dso
+12 −0
Original line number Diff line number Diff line
@@ -486,6 +486,18 @@ config ARCH_SUPPORTS_LTO_CLANG
	  - compiling inline assembly with clang's integrated assembler,
	  - and linking with LLD.

config ARCH_SUPPORTS_THINLTO
	bool
	help
	  An architecture should select this if it supports clang's ThinLTO.

config THINLTO
	bool "Use clang ThinLTO (EXPERIMENTAL)"
	depends on LTO_CLANG && ARCH_SUPPORTS_THINLTO
	default y
	help
	  Use ThinLTO to speed up Link Time Optimization.

choice
	prompt "Link-Time Optimization (LTO) (EXPERIMENTAL)"
	default LTO_NONE