Do not set --lto-O0 for optimize_for_size targets
--lto-O0 produces smaller binaries compared to --lto-O2 under -O2.
However under -Oz (the default for optimize_for_size), --lto-O2 actually
produces smaller binaries.
--lto-O0 --lto-O2
StatsD 2796856 2673728
libLLVM_android.so 15552712 14595544
Test: m
Change-Id: I33151cfd6abc273c4836418a6d8e0b935db02af4
diff --git a/cc/lto.go b/cc/lto.go
index f3af7d2..4444152 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -110,7 +110,7 @@
var ltoLdFlags []string
// Do not perform costly LTO optimizations for Eng builds.
- if Bool(lto.Properties.Lto_O0) || ctx.optimizeForSize() || ctx.Config().Eng() {
+ if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
}