From 486e42c35375a70c748db7b4aadad77ab12d777a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 25 Oct 2018 10:53:44 -0700 Subject: [PATCH] Enable safe ICF with LLD. Support for safe ICF was added to LLD in LLVM r337429. This reduces the size of sailfish system.img by 7.6MB. The address-significance tables created by Clang to support LLD's implementation of safe ICF are incompatible with ld -r. Therefore we need to pass -fno-addrsig to the compiler to prevent it from creating an address-significance table when building a cc_object. Change-Id: I83e28741e6b3cdf09566447d2658ce48594f2074 --- cc/config/clang.go | 1 - cc/object.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cc/config/clang.go b/cc/config/clang.go index 5c82604b4..bbc78faad 100644 --- a/cc/config/clang.go +++ b/cc/config/clang.go @@ -86,7 +86,6 @@ var ClangUnknownCflags = sorted([]string{ // Ldflags that should be filtered out when linking with clang lld var ClangUnknownLldflags = sorted([]string{ "-fuse-ld=gold", - "-Wl,--icf=safe", "-Wl,--fix-cortex-a8", "-Wl,--no-fix-cortex-a8", "-Wl,-m,aarch64_elf64_le_vec", diff --git a/cc/object.go b/cc/object.go index 0010621df..552f63997 100644 --- a/cc/object.go +++ b/cc/object.go @@ -39,6 +39,10 @@ func ObjectFactory() android.Module { baseLinker: NewBaseLinker(nil), } module.compiler = NewBaseCompiler() + + // Clang's address-significance tables are incompatible with ld -r. + module.compiler.appendCflags([]string{"-fno-addrsig"}) + module.stl = &stl{} return module.Init() }