WARNING: LTO is disabled by default on GKI (gki_defconfig
) on android14-6.1 and above. This should only be modified when the trade-offs are fully understood.
Building with link-time optimization (LTO) may take a very long time that brings little benefit during development. You may disable LTO to shorten the build time for development purposes.
The default value for LTO is set per branch (i.e. mainline
's default might differ from the android14-5.15
one, etc).
You may examine the defconfig of a kernel_build
to see the default LTO setting. For GKI, this is gki_defconfig
in
common/arch/arm64/configs/gki_defconfig common/arch/x86/configs/gki_defconfig common/arch/riscv/configs/gki_defconfig
For example:
$ tools/bazel build --lto=none //private/path/to/sources:tuna_dist
The --lto
option is applied to the build, not the copy_to_dist_dir
or pkg_install
target. Hence, put it before the --
delimiter when running a *_dist
target. For example:
$ tools/bazel run --lto=none //private/path/to/sources:tuna_dist -- --destdir=out/dist
You only need to do this once per workspace.
# Do this at workspace root next to the file WORKSPACE $ test -f WORKSPACE && echo 'build --lto=none' >> user.bazelrc # Future builds in this workspace always disables LTO. $ tools/bazel build //private/path/to/sources:tuna_dist
As of 2024-04-30, there may be incremental build issues with LTO due to caching. See