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

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

ANDROID: kbuild: limit LTO inlining



This change limits function inlining across translation unit
boundaries in order to reduce the binary size with LTO.

The -import-instr-limit flag defines a size limit, as the number
of LLVM IR instructions, for importing functions from other TUs.
The default value is 100, and decreasing it to 5 reduces the size
of a stripped arm64 defconfig vmlinux by 11%.

Bug: 145297228
Change-Id: Iaf366f843582972a5dfadc4695abb8f9c59882af
Suggested-by: default avatarGeorge Burgess IV <gbiv@google.com>
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 6cea0477
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -821,6 +821,12 @@ lto-clang-flags := -flto
endif
endif
lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit)
lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit)


# Limit inlining across translation units to reduce binary size
LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5

KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG)
KBUILD_LDFLAGS_MODULE += $(LD_FLAGS_LTO_CLANG)

KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds
KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds


# allow disabling only clang LTO where needed
# allow disabling only clang LTO where needed