Merge "Revert^2 "Enable full LTO optimization by default"" into main am: 2590054333
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3009938
Change-Id: Ied3836f4504dcac15f0802285c2b9aba13918fae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/cc/lto.go b/cc/lto.go
index a084db7..a7e7775 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -54,6 +54,9 @@
// Use -fwhole-program-vtables cflag.
Whole_program_vtables *bool
+
+ // Use --lto-O0 flag.
+ Lto_O0 *bool
}
type lto struct {
@@ -106,12 +109,8 @@
ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
var ltoLdFlags []string
- // 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() {
+ // Do not perform costly LTO optimizations for Eng builds.
+ if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}