]> granicus.if.org Git - clang/commitdiff
Fix two bugs for musl-libc on ARM
authorDiana Picus <diana.picus@linaro.org>
Mon, 8 Aug 2016 08:27:36 +0000 (08:27 +0000)
committerDiana Picus <diana.picus@linaro.org>
Mon, 8 Aug 2016 08:27:36 +0000 (08:27 +0000)
Bug 1: triples like armv7-pc-linux-musl use the wrong linker name
ld-musl-armv7.so.1; the right name should be ld-musl-arm.so.1, disregarding the
subarch field.

Bug 2: when compiler option -mhard-float is used, we should use the "hardfloat"
linker, no matter whether the triple itself mentions "hardfloat".

Patch by Lei Zhang!

Differential Revision: https://reviews.llvm.org/D22904

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
test/Driver/linux-ld.c

index d0477f7dd512e054a445b3b04df562aa43e8d889..175acd89228658f5b9f0de970dd8d8d4881c7642 100644 (file)
@@ -4274,19 +4274,28 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
 
   if (Triple.isAndroid())
     return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
-  else if (Triple.isMusl()) {
+
+  if (Triple.isMusl()) {
     std::string ArchName;
+    bool IsArm = false;
+
     switch (Arch) {
+    case llvm::Triple::arm:
     case llvm::Triple::thumb:
       ArchName = "arm";
+      IsArm = true;
       break;
+    case llvm::Triple::armeb:
     case llvm::Triple::thumbeb:
       ArchName = "armeb";
+      IsArm = true;
       break;
     default:
       ArchName = Triple.getArchName().str();
     }
-    if (Triple.getEnvironment() == llvm::Triple::MuslEABIHF)
+    if (IsArm &&
+        (Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
+         tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard))
       ArchName += "hf";
 
     return "/lib/ld-musl-" + ArchName + ".so.1";
index 87bd55fc4c8f0bd227b059a770e6945bf1213d90..60b30dd5438de2950d50cb4d51be46195ae446eb 100644 (file)
 // RUN:     --target=thumb-pc-linux-musleabihf \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=thumbv7-pc-linux-musleabi -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s
+// RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=thumbeb-pc-linux-musleabi \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEB %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=thumbeb-pc-linux-musleabihf \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=thumbv7eb-pc-linux-musleabi -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s
+// RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=arm-pc-linux-musleabi \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARM %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=arm-pc-linux-musleabihf \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=armv7-pc-linux-musleabi -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s
+// RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=armeb-pc-linux-musleabi \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEB %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=armeb-pc-linux-musleabihf \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s
 // RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=armv7eb-pc-linux-musleabi -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s
+// RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=aarch64-pc-linux-musleabi \
 // RUN:   | FileCheck --check-prefix=CHECK-MUSL-AARCH64 %s
 // RUN: %clang %s -### -o %t.o 2>&1 \