Add "Optimize_for_size" build property

Projects with this property will be aggresively optimized for size. This
is useful for large binaries that are rarely executed and performance
insensitive (e.g. debugging tools, deprecated libraries).

This changeset reduces total system native binary size by 1.1%.

Test: presubmit
Bug: 342090838
Change-Id: I46a1db0c44e2e7d482b14eca1299f8ad48661d2d
This commit is contained in:
Yi Kong
2024-05-28 02:22:34 +09:00
parent 6c9fa02204
commit 5786f5cf1d
2 changed files with 19 additions and 0 deletions

View File

@@ -693,6 +693,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp")
}
if ctx.optimizeForSize() {
flags.Local.CFlags = append(flags.Local.CFlags, "-Oz")
}
// Exclude directories from manual binder interface allowed list.
//TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
if android.HasAnyPrefix(ctx.ModuleDir(), allowedManualInterfacePaths) {