Do not enable global ThinLTO for tests
Tests are not shipped, no need to spend extra CPU cycles optimising them
during build.
Test: GLOBAL_THINLTO=true m
Bug: 169004486
Change-Id: I66ede9c01d43b574a7fe9f74f0bc6ba97f51be06
diff --git a/cc/cc.go b/cc/cc.go
index 0ed9bb6..3129160 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -485,6 +485,7 @@
static() bool
staticBinary() bool
testBinary() bool
+ testLibrary() bool
header() bool
binary() bool
object() bool
@@ -1486,6 +1487,10 @@
return ctx.mod.testBinary()
}
+func (ctx *moduleContextImpl) testLibrary() bool {
+ return ctx.mod.testLibrary()
+}
+
func (ctx *moduleContextImpl) header() bool {
return ctx.mod.Header()
}
diff --git a/cc/lto.go b/cc/lto.go
index 455ff7e..5d2fba0 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -140,12 +140,13 @@
lib32 := ctx.Arch().ArchType.Multilib == "lib32"
// CFI enables full LTO.
cfi := ctx.isCfi()
- // Performance and binary size are less important for host binaries.
+ // Performance and binary size are less important for host binaries and tests.
host := ctx.Host()
+ test := ctx.testBinary() || ctx.testLibrary()
// FIXME: ThinLTO for VNDK produces different output.
// b/169217596
vndk := ctx.isVndk()
- return GlobalThinLTO(ctx) && !lto.Never() && !lib32 && !cfi && !host && !vndk
+ return GlobalThinLTO(ctx) && !lto.Never() && !lib32 && !cfi && !host && !test && !vndk
}
func (lto *lto) FullLTO() bool {