55019c43f4
We set the default optimization mode to --lto-O0 for LTO enabled
projects, in order to save build time. This is missing some performance
optimizations, esp. related to vectorization. Now that we suggest eng
build for developers, we can enable full optimization by default.
When we introduced --lto-O0, we achieved a 4.2% saving in
system-processes-memory-direct. Enabling full LTO optimization will
trade some of the memory / binary size savings for better code
performance. For system-processes-memory-direct, it is 2.0% increase
compared to --lto-O0, or a net 2.2% saving compared to baseline.
Change-Id: I747939ac4d6e4a66e3ef776f4c36eebc7bf34c86
We set the default optimization mode to --lto-O0 for LTO enabled
projects, in order to save build time. This is missing some performance
optimizations, esp. related to vectorization. Now that we suggest eng
build for developers, we can enable full optimization by default.
When we introduced --lto-O0, we achieved a 4.2% saving in
system-processes-memory-direct. Enabling full LTO optimization will
trade some of the memory / binary size savings for better code
performance. For system-processes-memory-direct, it is 2.0% increase
compared to --lto-O0, or a net 2.2% saving compared to baseline.
Test: presubmit
Bug: 328163089
Change-Id: Ia4d0f74e668ed057d6d9d6fc6c60196c2e355fb9
Add the dependency on the fdo_profile module in afdoTransitionMutator
and read the provider in GenerateAndroidBuildActions.
This relands Ied8fd7b52d5694a3691652318e87b8fe14dda126 with a fix
to use the correct LTO ldflag when an afdo variant doesn't have a
profile.
Bug: 319288033
Bug: 324141705
Test: afdo_test.go
Change-Id: I024ca316cfb565b5fb0251793f05a54ce16cc1cb
Convert ltoDepsMutator and ltoMutator to a TransitionMutator as a
step towards variants-on-demand.
Bug: 319288033
Test: lto_test.go
Change-Id: I2c9af73fd526adf58ff626831ababea466338205
Afdo creates more variants to build, and optimizing LTO is costly to
perform. Turn off these two optimizations for eng builds for a faster
build speed.
This reduces total C/C++ invocation time for aosp_arm64-eng by 6.28%.
Test: presubmit
Bug: 307753064
Change-Id: Ibac4269c66a64e896dba2074b607d71a2da37546
For LTO compilation, we do not need MLGO flags in cflags, since codegen
happens during link only.
Fixes compiler warnings for unused command line argument.
Test: presubmit
Change-Id: I361e4292b10a3582fd5c69fa7b5678c654b44a0f
The MLGO model we embed in the Android Clang is trained on ARM64
ThinLTO artefacts. Applying the model across architectures does not
necessarily translate to performance improvement. Therefore only enable
the optimisation on ARM64 ThinLTO for now.
Test: presubmit
Bug: 293827654
Change-Id: Ie64a65c11191cf700a463637a0746c8470d3aa3c
GLOBAL_THINLTO is now default, since it improves build speed, produces
more performant code and smaller binary. Remove the option to turn it
off since we no longer maintain that variation, and that simplifies the
logic (esp. for moving CFI builds to ThinLTO).
Also fixed a bug where ThinLTO is not propagated to its static deps on
non-default targets (32-bit or host).
Test: presubmit
Bug: 169004486
Change-Id: I31f41ba27c2b94a384d2ba5027049c307d6f4334
This is now the default, and we will be removing non-GlobalThinLTO configuration.
Also changed handling for lto: never, it doesn't need to create an
lto-none variant.
Change-Id: I971baa920df867fb762923d925eed22215a89c27
Test: presubmit
Because enabling ThinLTO makes some constructor functions not called
in arm64 executables.
Bug: 295944813
Test: build
Change-Id: Ic0cab5fd80aa86d0d9ca1131564b747a445c6e46
Reduce the import instr limit from the LLVM default (100) to 40. This
helps reduce the binary size as well as improving performance slightly.
Size:
Default(100) 40 30
libhwui.so 11059040 11058912 11060872
libart.so 10697576 10697160 10696568
Performance:
40 vs. default: 0.37% improvement
http://go/art-benchmark?p=BootImageProfileId:36054
30 vs. default: 0.36% improvement
http://go/art-benchmark?p=BootImageProfileId:36058
Test: presubmit
Change-Id: Id800ff7818cde908daab784bac0a312c6a71272d
Build C/C++ targets with ThinLTO with "--lto-O0" by default. This takes
advantage of better dead code elimination and CFG simplification due to
ThinLTO's global view of the program, but do not enable the costly LTO
optimizations. This also makes builds faster because we can avoid doing
codegen for the dead code.
Code size for panther-userdebug:
/system/bin /system/lib /system/lib64
Original 57648 86264 181700
Global ThinLTO 55764 84916 175728
-3.27% -1.56% -3.29%
Build time for aosp_arm64-userdebug:
clang time linker time
Original 56993.87s 1712.36s
Global ThinLTO 52839.18s 3114.93s
saving 4.68% build time in total.
Bug: 169004486
Test: presubmit
Change-Id: Idb0f4675ca4750b8b12b24f4679579419d3448c8
This option is unsupported on the MacOS ld used in Android, leading to
compilation errors when LTO is enabled for binaries.
In particular the error includes:
```
ld64.lld: error: unknown argument '-plugin-opt'
ld64.lld: error: unknown argument '-import-instr-limit=5'
```
Test: m libc++ on a Mac OS machine
Bug: 288983988
Change-Id: I1873e0a77777832f833f211beb42633d462f04d5
We removed Full LTO support, now LTO is a binary choice. This allows us
to greatly simplify the LTO propagation logic.
Test: m
Test: GLBOAL_THINLTO=true m
Bug: 169004486
Change-Id: Ie4e453d7518c7069a7c755734dab1e776c16e656
We do not have any more projects directly depending on Full LTO (except
CFI which manages their own LTO flags), remove full LTO support from the
build system.
Test: presubmit
Bug: 169004486
Change-Id: I8d6b7999d716158b5d8fe34b2f197653d7bae8dd
Building for riscv64 fails with link errors on __thread variables.
Set -fno-emulated-tls to fix it.
Bug: 254713216
Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true ndk_sysroot
Change-Id: I3dca81dfd277d681b6c868a5e8385e3a37335a5f
Building with LTO and CFI enabled for riscv64 causes link failures:
ld.lld: error: lto.tmp: cannot link object files with different floating-point ABI
ld.lld: error: undefined symbol: guard variable for android::hardware::BufferedTextOutput::getBuffer() const::ts
Disable them for now.
Test: lunch aosp_riscv64-userdebug && m ALLOW_MISSING_DEPENDENCIES=true ndk_sysroot
Change-Id: I3489952abebeeb3f4de664fd3e436232aac298d7
Tests are not shipped, no need to spend extra CPU cycles optimising them
during build.
Test: GLOBAL_THINLTO=true m
Bug: 169004486
Change-Id: I66ede9c01d43b574a7fe9f74f0bc6ba97f51be06
This reverts commit b90ff82772.
All the breakages are now fixed or mitigated.
Bug: 169004486
Change-Id: Ibec4b1f0a50c5ef6769bc6916a81721a4ce03c60
Test: presubmit
Apply ThinLTO without optimization (--lto-O0) globally. This saves us
2.24% in binary size for system/lib64, as well as more than 4.68% build
time improvement.
Test: presubmit
Bug: 169004486
Change-Id: I1ed90c2058f9ff1fa8a2d3fd7ac1191c5d98dac1
Due to the lack of engineering efforts into LP32 targets, do not enable
global ThinLTO for them by default.
Test: presubmit
Bug: 169004486
Change-Id: I79b77baecf16fda95ff5dccc5a401596a0557d5d