Add -faddrsig to ClangExtraCflags

Emit address-significance table which allows linker to perform safe ICF.
Clang does not emit the table by default on Android since NDK still uses
GNU binutils.

With the flag, binary size is decreased. For Marlin:
               -fno-addrsig  -faddrsig  diff
/system/bin    28012K        27108K     -3.33%
/system/lib    88220K        86964K     -1.44%
/system/lib64  151936K       148108K    -2.58%

Test: m checkbuild
Bug: 128940110
Change-Id: I99511f038a6d4b88b5c849a0f8943c24731ab6ea
(cherry picked from commit a32b5e6a6b)
This commit is contained in:
Yi Kong
2019-03-19 20:05:05 -07:00
parent 2e10ea39a9
commit 1b0ba94e5d

View File

@@ -97,6 +97,10 @@ func init() {
pctx.StaticVariable("ClangExtraCflags", strings.Join([]string{
"-D__compiler_offsetof=__builtin_offsetof",
// Emit address-significance table which allows linker to perform safe ICF. Clang does
// not emit the table by default on Android since NDK still uses GNU binutils.
"-faddrsig",
// -Wimplicit-fallthrough is not enabled by -Wall.
"-Wimplicit-fallthrough",