Merge "Revert^3 "Enable full LTO optimization by default"" into main am: 139218906b

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3016846

Change-Id: I34c152b4afaeb97ea8f1b12ffcbb09d12ca8622f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chungro Lee
2024-03-28 01:51:25 +00:00
committed by Automerger Merge Worker

View File

@@ -54,9 +54,6 @@ type LTOProperties struct {
// Use -fwhole-program-vtables cflag.
Whole_program_vtables *bool
// Use --lto-O0 flag.
Lto_O0 *bool
}
type lto struct {
@@ -109,8 +106,12 @@ func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags {
ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
var ltoLdFlags []string
// Do not perform costly LTO optimizations for Eng builds.
if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
// The module did not explicitly turn on LTO. Only leverage LTO's
// better dead code elimination and CFG simplification, but do
// not perform costly optimizations for a balance between compile
// time, binary size and performance.
// Apply the same for Eng builds as well.
if !lto.ThinLTO() || ctx.Config().Eng() {
ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}