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
On second thought, this is actually counter-productive rather than an
optimisation. LTOing test code is usually quite cheap, however since
tests can pull in additional static libraries (e.g. to set up test
environment), we will have to create non-LTO variants for these
dependent libraries, which can be much more expensive.
This reverts commit 85d7297318.
Bug: 195134194
Bug: 203737712
Change-Id: I1a105136075133a5b5895d00847d8796c419964c
Test: m GLOBAL_THINLTO=true dist device-tests platform_tests
There's not a great return on investment for spending additional
compilation/link time on tests that may only be run once or very few
times (as compared to actual library code that ships and is run orders
of magnitude more times).
Bug: 195134194
Bug: 203737712
Test: m GLOBAL_THINLTO=true dist device-tests platform_tests
Change-Id: I7149c4140f7c52b22bedbe322f1bf2c81f7ad66b
Instead of making everything into ThinLTO variant by default (it works
but many Soong tests don't like this, and got bit rot due to lack of
active builder for this configuration), let the default option be
ThinLTO and no LTO be a special variant.
Test: m GLOBAL_THINLTO=true
Test: m
Bug: 195134194
Change-Id: I2fd98061ba55eba1fdfdd056fb2f8c2051fd2553
With global ThinLTO enabled, vndk version has different symbol ordering
from the platform version. Opt out any binaries that has vndk enabled as
a temporary workaround.
Test: GLOBAL_THINLTO=true m
Bug: 169217596
Change-Id: I75b060cbe6c74421d283c6dfbd669af20f466d1f