kernel: Implement build time LTO choice

Change-Id: I898eb50fadb6bde5beebf46f443c5de7e6acc907
This commit is contained in:
Chirayu Desai 2021-12-03 22:39:46 +05:30 committed by Michael Bestas
parent 174ee28d0f
commit d91d695664

View file

@ -55,6 +55,8 @@
# aarch64-linux-gnu- for arm64
# x86_64-linux-gnu- for x86
#
# KERNEL_LTO = Optional, force LTO to none / thin / full
#
# NEED_KERNEL_MODULE_ROOT = Optional, if true, install kernel
# modules in root instead of vendor
# NEED_KERNEL_MODULE_SYSTEM = Optional, if true, install kernel
@ -275,6 +277,31 @@ endef
# $(2): The defconfig to process (just the filename, no need for full path to file)
define make-kernel-config
$(call internal-make-kernel-target,$(1),VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(2))
$(hide) if [ "$(KERNEL_LTO)" = "none" ]; then \
$(KERNEL_SRC)/scripts/config --file $(1)/.config \
-d LTO_CLANG \
-e LTO_NONE \
-d LTO_CLANG_THIN \
-d LTO_CLANG_FULL \
-d THINLTO; \
$(call make-kernel-target,olddefconfig); \
elif [ "$(KERNEL_LTO)" = "thin" ]; then \
$(KERNEL_SRC)/scripts/config --file $(1)/.config \
-e LTO_CLANG \
-d LTO_NONE \
-e LTO_CLANG_THIN \
-d LTO_CLANG_FULL \
-e THINLTO; \
$(call make-kernel-target,olddefconfig); \
elif [ "$(KERNEL_LTO)" = "full" ]; then \
$(KERNEL_SRC)/scripts/config --file $(1)/.config \
-e LTO_CLANG \
-d LTO_NONE \
-d LTO_CLANG_THIN \
-e LTO_CLANG_FULL \
-d THINLTO; \
$(call make-kernel-target,olddefconfig); \
fi
$(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \
echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \
echo $(KERNEL_CONFIG_OVERRIDE) >> $(1)/.config; \