From dd5887577d5b77105375859efe4e426f71186077 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Tue, 25 Oct 2016 21:44:35 +0000 Subject: [PATCH] Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation. Summary: This is only forced on if there is no non-Cortex-A53 CPU specified as well. Android's platform and NDK builds need to assume that the code can be run on Cortex-A53 devices, so we always enable the fix unless we know specifically that the code is only running on a different kind of CPU. Reviewers: cfe-commits Subscribers: aemerson, rengolin, tberghammer, pirama, danalbert Differential Revision: https://reviews.llvm.org/D25761 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285127 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 8 ++++++++ test/Driver/android-aarch64-link.cpp | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/Driver/android-aarch64-link.cpp diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7d77cd1bb9..691bb85a07 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -9712,6 +9712,14 @@ void gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) arm::appendEBLinkFlags(Args, CmdArgs, Triple); + // Most Android ARM64 targets should enable the linker fix for erratum + // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. + if (Arch == llvm::Triple::aarch64 && isAndroid) { + std::string CPU = getCPUName(Args, Triple); + if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53") + CmdArgs.push_back("--fix-cortex-a53-843419"); + } + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); diff --git a/test/Driver/android-aarch64-link.cpp b/test/Driver/android-aarch64-link.cpp new file mode 100644 index 0000000000..2c4cfb9898 --- /dev/null +++ b/test/Driver/android-aarch64-link.cpp @@ -0,0 +1,17 @@ +// Check that we automatically add relevant linker flags for Android aarch64. + +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -### -v %s 2> %t +// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a53 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a57 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s +// +// GENERIC-ARM: --fix-cortex-a53-843419 +// CORTEX-A53: --fix-cortex-a53-843419 +// CORTEX-A57-NOT: --fix-cortex-a53-843419 -- 2.40.0