Skip to content

Commit e1857a3

Browse files
samitolvanenvbajs
authored andcommitted
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: George Burgess IV <gbiv@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Yahya Wessam <yahyawessam2002@gmail.com>
1 parent c95c59d commit e1857a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,12 @@ endif
968968
KBUILD_CFLAGS += -mllvm -unroll-threshold=1200
969969
lto-clang-flags += -fvisibility=hidden
970970

971+
# Limit inlining across translation units to reduce binary size
972+
LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5
973+
974+
KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG)
975+
KBUILD_LDFLAGS_MODULE += $(LD_FLAGS_LTO_CLANG)
976+
971977
KBUILD_LDFLAGS_MODULE += -T scripts/module-lto.lds
972978

973979
# allow disabling only clang LTO where needed

0 commit comments

Comments
 (0)