arch/clang: add support for Clang LTO
add support of Clang's Link Time Optimization (LTO) on NuttX build system Reference: https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html https://llvm.org/docs/LinkTimeOptimization.html Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
67fbfda974
commit
0315283c21
43
arch/Kconfig
43
arch/Kconfig
@ -222,6 +222,49 @@ config ARCH_TOOLCHAIN_GNU
|
||||
bool
|
||||
default n
|
||||
|
||||
config ARCH_TOOLCHAIN_CLANG
|
||||
bool
|
||||
select ARCH_TOOLCHAIN_GNU
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Link Time Optimization (LTO)"
|
||||
default LTO_NONE
|
||||
---help---
|
||||
This option enables Link Time Optimization (LTO), which allows the
|
||||
compiler to optimize binaries globally.
|
||||
|
||||
If unsure, select LTO_NONE. Note that LTO is very resource-intensive
|
||||
so it's disabled by default.
|
||||
|
||||
config LTO_NONE
|
||||
bool "None"
|
||||
---help---
|
||||
Build the kernel normally, without Link Time Optimization (LTO).
|
||||
|
||||
config LTO_FULL
|
||||
bool "GNU Full LTO (EXPERIMENTAL)"
|
||||
depends on ARCH_TOOLCHAIN_GNU || ARCH_TOOLCHAIN_CLANG
|
||||
---help---
|
||||
Link time optimization is implemented as a GCC front end for a bytecode
|
||||
bytecode representation of GIMPLE that is emitted in special sections
|
||||
of .o files. Currently, LTO support is enabled in most ELF-based systems,
|
||||
as well as darwin, cygwin and mingw systems.
|
||||
|
||||
config LTO_THIN
|
||||
bool "Clang ThinLTO (EXPERIMENTAL)"
|
||||
depends on ARCH_TOOLCHAIN_CLANG
|
||||
---help---
|
||||
This option enables Clang's ThinLTO, which allows for parallel
|
||||
optimization and faster incremental compiles compared to the
|
||||
CONFIG_LTO_FULL option. More information can be found
|
||||
from Clang's documentation:
|
||||
|
||||
https://clang.llvm.org/docs/ThinLTO.html
|
||||
|
||||
If unsure, say Y.
|
||||
endchoice
|
||||
|
||||
config ARCH_GNU_NO_WEAKFUNCTIONS
|
||||
bool
|
||||
depends on ARCH_TOOLCHAIN_GNU
|
||||
|
@ -22,6 +22,6 @@ config ARMV6M_TOOLCHAIN_GNU_EABI
|
||||
|
||||
config ARMV6M_TOOLCHAIN_CLANG
|
||||
bool "Generic Clang toolchain"
|
||||
select ARCH_TOOLCHAIN_GNU
|
||||
select ARCH_TOOLCHAIN_CLANG
|
||||
|
||||
endchoice
|
||||
|
@ -80,6 +80,14 @@ ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG)
|
||||
TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys
|
||||
endif
|
||||
|
||||
# Link Time Optimization
|
||||
|
||||
ifeq ($(CONFIG_LTO_THIN),y)
|
||||
MAXOPTIMIZATION += -flto=thin
|
||||
else ifeq ($(CONFIG_LTO_FULL),y)
|
||||
MAXOPTIMIZATION += -flto
|
||||
endif
|
||||
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
|
||||
ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),BUILDROOT)
|
||||
|
@ -110,7 +110,7 @@ config ARMV7M_TOOLCHAIN_GNU_EABI
|
||||
|
||||
config ARMV7M_TOOLCHAIN_CLANG
|
||||
bool "Generic Clang toolchain"
|
||||
select ARCH_TOOLCHAIN_GNU
|
||||
select ARCH_TOOLCHAIN_CLANG
|
||||
|
||||
endchoice
|
||||
|
||||
|
@ -130,6 +130,14 @@ ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG)
|
||||
|
||||
endif
|
||||
|
||||
# Link Time Optimization
|
||||
|
||||
ifeq ($(CONFIG_LTO_THIN),y)
|
||||
MAXOPTIMIZATION += -flto=thin
|
||||
else ifeq ($(CONFIG_LTO_FULL),y)
|
||||
MAXOPTIMIZATION += -flto
|
||||
endif
|
||||
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),BUILDROOT)
|
||||
|
@ -85,7 +85,7 @@ config ARMV8M_TOOLCHAIN_GNU_EABI
|
||||
|
||||
config ARMV8M_TOOLCHAIN_CLANG
|
||||
bool "Generic Clang toolchain"
|
||||
select ARCH_TOOLCHAIN_GNU
|
||||
select ARCH_TOOLCHAIN_CLANG
|
||||
|
||||
endchoice
|
||||
|
||||
|
@ -139,6 +139,14 @@ ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG)
|
||||
|
||||
endif
|
||||
|
||||
# Link Time Optimization
|
||||
|
||||
ifeq ($(CONFIG_LTO_THIN),y)
|
||||
MAXOPTIMIZATION += -flto=thin
|
||||
else ifeq ($(CONFIG_LTO_FULL),y)
|
||||
MAXOPTIMIZATION += -flto
|
||||
endif
|
||||
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
|
||||
ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),BUILDROOT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user