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 Bug: 140525226 Change-Id: Iaf366f843582972a5dfadc4695abb8f9c59882af Suggested-by: George Burgess IV <gbiv@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com> (cherry picked from commit 2ee80bf76d779d4ee3ef386774522208979d48ae) Signed-off-by: Kyle Lin <kylelin@google.com> Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
This commit is contained in:
parent
363329502b
commit
3180aedfe1
1 changed files with 6 additions and 0 deletions
6
Makefile
6
Makefile
|
@ -752,6 +752,12 @@ endif
|
||||||
ifdef CONFIG_LTO_CLANG
|
ifdef CONFIG_LTO_CLANG
|
||||||
lto-clang-flags := -flto -fvisibility=hidden
|
lto-clang-flags := -flto -fvisibility=hidden
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
# allow disabling only clang LTO where needed
|
# allow disabling only clang LTO where needed
|
||||||
DISABLE_LTO_CLANG := -fno-lto -fvisibility=default
|
DISABLE_LTO_CLANG := -fno-lto -fvisibility=default
|
||||||
export DISABLE_LTO_CLANG
|
export DISABLE_LTO_CLANG
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue