[PATCH] D61931: [Driver] Use --android-tls for Android ARM/AArch64 when lld is used

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 23:21:44 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: danalbert, pirama, rprichard, srhines.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

See D61825 <https://reviews.llvm.org/D61825> for the temporary lld option --android-tls.


Repository:
  rC Clang

https://reviews.llvm.org/D61931

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/android-aarch64-link.cpp
  test/Driver/android-arm-link.cpp


Index: test/Driver/android-arm-link.cpp
===================================================================
--- /dev/null
+++ test/Driver/android-arm-link.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-linux-androideabi -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target arm-linux-androideabi -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+
+// TLS: --android-tls
Index: test/Driver/android-aarch64-link.cpp
===================================================================
--- test/Driver/android-aarch64-link.cpp
+++ test/Driver/android-aarch64-link.cpp
@@ -16,7 +16,13 @@
 // RUN:   -### -v %s 2> %t
 // RUN: FileCheck -check-prefix=MAX-PAGE-SIZE < %t %s
 //
+// RUN: %clang -target aarch64-linux-android -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target aarch64-linux-android -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+//
 // GENERIC-ARM: --fix-cortex-a53-843419
 // CORTEX-A53: --fix-cortex-a53-843419
 // CORTEX-A57-NOT: --fix-cortex-a53-843419
 // MAX-PAGE-SIZE: max-page-size=4096
+// TLS: --android-tls
Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -390,10 +390,21 @@
       CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
-  // Android does not allow shared text relocations. Emit a warning if the
-  // user's code contains any.
-  if (isAndroid)
-      CmdArgs.push_back("--warn-shared-textrel");
+  if (isAndroid) {
+    // Android does not allow shared text relocations. Emit a warning if the
+    // user's code contains any.
+    CmdArgs.push_back("--warn-shared-textrel");
+
+    // FIXME In lld, --android-tls is a temporary option that makes its TLS
+    // layout compatible with Android Bionic on ARM/AArch64. Delete once the
+    // reservation of extra TLS slots is done in a proper layer (e.g.
+    // crtbegin_{dynamic,static}.o).
+    if (Triple.isARM() || Triple.isAArch64()) {
+      const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+      if (A && StringRef(A->getValue()).contains("lld"))
+        CmdArgs.push_back("--android-tls");
+    }
+  }
 
   for (const auto &Opt : ToolChain.ExtraOpts)
     CmdArgs.push_back(Opt.c_str());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61931.199558.patch
Type: text/x-patch
Size: 2379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190515/7b9e9893/attachment.bin>


More information about the cfe-commits mailing list