Enable ThinLTO for hwui
ThinLTO will benefit hwui on both performance and code size.
Now that hwui is with PGO, ThinLTO provides 3.8% performance improvement
on top of it (tested using hwui benchmarks on marlin device).
Enabling ThinLTO also decreases current code size of libhwui.so by 3.2%.
To be mentioned, Thinlto property in bp file will go through all static
libraries that hwui depends on (such as libskia) and enable Thinlto for
them when building hwui.
Test: Build and run benchmarks with ThinLTO enabled.
Bug: http://b/62839002
Change-Id: I89466d50c3715f6e7b0518ff10240bf8a5e9714c
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 24d819e..35790b6 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -6,6 +6,7 @@
//"hwui_bugreport_font_cache_usage",
//"hwui_compile_for_perf",
"hwui_pgo",
+ "hwui_lto",
],
cpp_std: "c++17",
@@ -126,6 +127,18 @@
},
}
+// Build hwui library with ThinLTO by default.
+cc_defaults {
+ name: "hwui_lto",
+ target: {
+ android: {
+ lto: {
+ thin: true,
+ },
+ },
+ },
+}
+
// ------------------------
// library
// ------------------------