Merge "Revert^4 "Enable full LTO optimization by default"" into main

This commit is contained in:
Pirama Arumuga Nainar 2024-06-14 21:54:50 +00:00 committed by Gerrit Code Review
commit 52436e1574

View file

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