aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChungro Lee <chungro@google.com>2024-03-28 01:35:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-28 01:35:37 +0000
commit139218906b4c754b05aa6b4bae54b76acc5fe47c (patch)
tree6073604c574ebb3bacec529906b2295573d78e8c
parent96ae1409897fb16b8fc45bd90a0b71f4c70a3ba2 (diff)
parent97f68587fff22676d3f71b7e0ea7f2d2c4649558 (diff)
downloadsoong-139218906b4c754b05aa6b4bae54b76acc5fe47c.tar.gz
Merge "Revert^3 "Enable full LTO optimization by default"" into main
-rw-r--r--cc/lto.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/cc/lto.go b/cc/lto.go
index a7e777526..a084db7be 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 {
@@ -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")
}