Merge "Mark generated renderscript header files as implicit outputs"
diff --git a/cc/lto.go b/cc/lto.go
index 2ced124..d7526e2 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -74,12 +74,27 @@
var ltoFlag string
if Bool(lto.Properties.Lto.Thin) {
ltoFlag = "-flto=thin"
+
} else {
ltoFlag = "-flto"
}
flags.CFlags = append(flags.CFlags, ltoFlag)
flags.LdFlags = append(flags.LdFlags, ltoFlag)
+
+ if ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") && Bool(lto.Properties.Lto.Thin) {
+ // Set appropriate ThinLTO cache policy
+ cacheDirFormat := "-Wl,-plugin-opt,cache-dir="
+ cacheDir := android.PathForOutput(ctx, "thinlto-cache").String()
+ flags.LdFlags = append(flags.LdFlags, cacheDirFormat+cacheDir)
+
+ // Limit the size of the ThinLTO cache to the lesser of 10% of available
+ // disk space and 10GB.
+ cachePolicyFormat := "-Wl,-plugin-opt,cache-policy="
+ policy := "cache_size=10%:cache_size_bytes=10g"
+ flags.LdFlags = append(flags.LdFlags, cachePolicyFormat+policy)
+ }
+
if ctx.Device() {
// Work around bug in Clang that doesn't pass correct emulated
// TLS option to target. See b/72706604 or