Use --hash-style=both for NDK binaries
Old devices don't support gnu hashes, use --hash-style=both when
the sdk_version property is set.
Test: m -j checkbuild
Bug: 64608507
Change-Id: Iec5229a08fc192f1c8872466ee4bf866adf50443
diff --git a/cc/linker.go b/cc/linker.go
index 1a842ae..59bc9bd 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -232,6 +232,14 @@
}
}
+ if ctx.sdk() && (ctx.Arch().ArchType != android.Mips && ctx.Arch().ArchType != android.Mips64) {
+ // The bionic linker now has support gnu style hashes (which are much faster!), but shipping
+ // to older devices requires the old style hash. Fortunately, we can build with both and
+ // it'll work anywhere.
+ // This is not currently supported on MIPS architectures.
+ flags.LdFlags = append(flags.LdFlags, "-Wl,--hash-style=both")
+ }
+
if flags.Clang {
flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainClangLdflags())
} else {