Add USE_CLANG_LLD and use_clang_lld.

* USE_CLANG_LLD is unedefined in current builds.
* When USE_CLANG_LLD is defined to 'true' or '1',
  use clang's lld instead of ld or ld.gold.
* When lld is enabled:
  * ld-only flags are not passed to 'lld'.
  * location_packer is disabled.
  * Use new lld's --pack-dyn-relocs=android.
* When lld does not work:
  * In Android.mk files use LOCAL_USE_CLANG_LLD := false.
  * In Android.bp files use use_clang_lld: false.
* Only arm, arm64, x86, and x86_64_devices have LLD flags;
  all other hosts and targets do not call lld yet.

Bug: 73768157
Test: make checkbuild and boot
Change-Id: I06b8a1e868a600997a7e70fe05c299d751d23d5f
This commit is contained in:
Chih-Hung Hsieh
2018-04-03 11:33:34 -07:00
parent 18f568f651
commit 02b4da53a7
20 changed files with 178 additions and 4 deletions

View File

@@ -83,6 +83,15 @@ var ClangUnknownCflags = sorted([]string{
"--enable-stdcall-fixup",
})
// 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",
})
var ClangLibToolingUnknownCflags = []string{
"-flto*",
"-fsanitize*",
@@ -182,6 +191,17 @@ func ClangFilterUnknownCflags(cflags []string) []string {
return ret
}
func ClangFilterUnknownLldflags(lldflags []string) []string {
ret := make([]string, 0, len(lldflags))
for _, f := range lldflags {
if !inListSorted(f, ClangUnknownLldflags) {
ret = append(ret, f)
}
}
return ret
}
func inListSorted(s string, list []string) bool {
for _, l := range list {
if s == l {