From 97f68587fff22676d3f71b7e0ea7f2d2c4649558 Mon Sep 17 00:00:00 2001 From: Chungro Lee Date: Thu, 28 Mar 2024 01:13:59 +0000 Subject: [PATCH] Revert^3 "Enable full LTO optimization by default" 7549990a957c66d1ed29bde27da05be001491f9f Reason for revert: b/331528903 Change-Id: Idb013e97c84aeaf969522dc77abf94f23f721181 --- cc/lto.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cc/lto.go b/cc/lto.go index e2d99ebd1..05fa8eea5 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -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 { @@ -113,8 +110,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") }