mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
ANDROID: kbuild: add support for Clang LTO
This change adds the configuration option CONFIG_LTO_CLANG, and build system support for Clang's Link Time Optimization (LTO). In preparation for LTO support with other compilers, potentially common parts of the changes are gated behind CONFIG_LTO instead. With -flto, instead of object files, Clang produces LLVM bitcode, which is compiled into a native object at link time, allowing the final binary to be optimized globally. For more details, see: https://llvm.org/docs/LinkTimeOptimization.html While the kernel normally uses GNU ld for linking, LLVM supports LTO only with LLD or GNU gold linkers. This change assumes LLD is used. Bug: 145210207 Change-Id: If1164ff33d073358ee7d4bba84cbb06c349c4a88 Signed-off-by: Sami Tolvanen <[email protected]>
This commit is contained in:
parent
548c06ceb9
commit
2e39b40dd2
8 changed files with 221 additions and 17 deletions
47
arch/Kconfig
47
arch/Kconfig
|
|
@ -554,6 +554,53 @@ config SHADOW_CALL_STACK_VMAP
|
|||
provides better stack exhaustion protection, but increases per-thread
|
||||
memory consumption as a full page is allocated for each shadow stack.
|
||||
|
||||
config LTO
|
||||
bool
|
||||
|
||||
config ARCH_SUPPORTS_LTO_CLANG
|
||||
bool
|
||||
help
|
||||
An architecture should select this option if it supports:
|
||||
- compiling with 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 ThinLTO.
|
||||
|
||||
config THINLTO
|
||||
bool "Use Clang's 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
|
||||
help
|
||||
This option turns on Link-Time Optimization (LTO).
|
||||
|
||||
config LTO_NONE
|
||||
bool "None"
|
||||
|
||||
config LTO_CLANG
|
||||
bool "Use Clang's Link Time Optimization (LTO) (EXPERIMENTAL)"
|
||||
depends on ARCH_SUPPORTS_LTO_CLANG
|
||||
depends on !KASAN
|
||||
depends on !FTRACE_MCOUNT_RECORD
|
||||
depends on CC_IS_CLANG && CLANG_VERSION >= 100000 && LD_IS_LLD
|
||||
select LTO
|
||||
help
|
||||
This option enables Clang's Link Time Optimization (LTO), which allows
|
||||
the compiler to optimize the kernel globally at link time. If you
|
||||
enable this option, the compiler generates LLVM IR instead of object
|
||||
files, and the actual compilation from IR occurs at the LTO link step,
|
||||
which may take several minutes.
|
||||
|
||||
endchoice
|
||||
|
||||
config HAVE_ARCH_WITHIN_STACK_FRAMES
|
||||
bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue