r211598 - [mips] Correct linux dynamic linker for -mnan=2008
Daniel Sanders
daniel.sanders at imgtec.com
Tue Jun 24 08:04:16 PDT 2014
Author: dsanders
Date: Tue Jun 24 10:04:16 2014
New Revision: 211598
URL: http://llvm.org/viewvc/llvm-project?rev=211598&view=rev
Log:
[mips] Correct linux dynamic linker for -mnan=2008
Summary:
The dynamic linker is named ld-linux-mipsn8.so.1 when -mnan=2008 is given (or
is the default). It remains ld.so.1 for other cases.
This is necessary for MIPS32r6/MIPS64r6 since these ISA's default to -mnan=2008.
Differential Revision: http://reviews.llvm.org/D4273
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/linux-ld.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=211598&r1=211597&r2=211598&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jun 24 10:04:16 2014
@@ -5102,6 +5102,22 @@ bool mips::hasMipsAbiArg(const ArgList &
return A && (A->getValue() == StringRef(Value));
}
+bool mips::isNaN2008(const ArgList &Args) {
+ if (Arg *NaNArg = Args.getLastArg(options::OPT_mnan_EQ))
+ return llvm::StringSwitch<bool>(NaNArg->getValue())
+ .Case("2008", true)
+ .Case("legacy", false)
+ .Default(false);
+
+ // NaN2008 is the default for MIPS32r6/MIPS64r6.
+ if (Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ))
+ return llvm::StringSwitch<bool>(CPUArg->getValue())
+ .Cases("mips32r6", "mips64r6", true)
+ .Default(false);
+
+ return false;
+}
+
llvm::Triple::ArchType darwin::getArchTypeForMachOArchName(StringRef Str) {
// See arch(3) and llvm-gcc's driver-driver.c. We don't implement support for
// archs which Darwin doesn't use.
@@ -6921,14 +6937,17 @@ static StringRef getLinuxDynamicLinker(c
else
return "/lib/ld-linux.so.3"; /* TODO: check which dynamic linker name. */
} else if (ToolChain.getArch() == llvm::Triple::mips ||
- ToolChain.getArch() == llvm::Triple::mipsel)
+ ToolChain.getArch() == llvm::Triple::mipsel) {
+ if (mips::isNaN2008(Args))
+ return "/lib/ld-linux-mipsn8.so.1";
return "/lib/ld.so.1";
- else if (ToolChain.getArch() == llvm::Triple::mips64 ||
+ } else if (ToolChain.getArch() == llvm::Triple::mips64 ||
ToolChain.getArch() == llvm::Triple::mips64el) {
+ std::string LinkerFile = mips::isNaN2008(Args) ? "ld-linux-mipsn8.so.1"
+ : "ld.so.1";
if (mips::hasMipsAbiArg(Args, "n32"))
- return "/lib32/ld.so.1";
- else
- return "/lib64/ld.so.1";
+ return "/lib32/" + LinkerFile;
+ return "/lib64/" + LinkerFile;
} else if (ToolChain.getArch() == llvm::Triple::ppc)
return "/lib/ld.so.1";
else if (ToolChain.getArch() == llvm::Triple::ppc64 ||
Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=211598&r1=211597&r2=211598&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Tue Jun 24 10:04:16 2014
@@ -209,6 +209,7 @@ namespace arm {
namespace mips {
bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
+ bool isNaN2008(const llvm::opt::ArgList &Args);
}
namespace darwin {
Modified: cfe/trunk/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=211598&r1=211597&r2=211598&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Tue Jun 24 10:04:16 2014
@@ -456,6 +456,7 @@
// CHECK-MIPS: "-m" "elf32btsmip"
// CHECK-MIPS: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
// CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=mipsel-linux-gnu \
// RUN: | FileCheck --check-prefix=CHECK-MIPSEL %s
@@ -463,6 +464,21 @@
// CHECK-MIPSEL: "-m" "elf32ltsmip"
// CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
// CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-gnu -mnan=2008 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPSEL-NAN2008 %s
+// CHECK-MIPSEL-NAN2008: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPSEL-NAN2008: "-m" "elf32ltsmip"
+// CHECK-MIPSEL-NAN2008: "-dynamic-linker" "{{.*}}/lib/ld-linux-mipsn8.so.1"
+// CHECK-MIPSEL-NAN2008-NOT: "--hash-style={{gnu|both}}"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 --target=mipsel-linux-gnu -mcpu=mips32r6 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS32R6EL %s
+// CHECK-MIPS32R6EL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS32R6EL: "-m" "elf32ltsmip"
+// CHECK-MIPS32R6EL: "-dynamic-linker" "{{.*}}/lib/ld-linux-mipsn8.so.1"
+// CHECK-MIPS32R6EL-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=mips64-linux-gnu \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64 %s
@@ -470,6 +486,7 @@
// CHECK-MIPS64: "-m" "elf64btsmip"
// CHECK-MIPS64: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
// CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=mips64el-linux-gnu \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL %s
@@ -477,6 +494,21 @@
// CHECK-MIPS64EL: "-m" "elf64ltsmip"
// CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
// CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 --target=mips64el-linux-gnu -mnan=2008 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-NAN2008 %s
+// CHECK-MIPS64EL-NAN2008: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64EL-NAN2008: "-m" "elf64ltsmip"
+// CHECK-MIPS64EL-NAN2008: "-dynamic-linker" "{{.*}}/lib64/ld-linux-mipsn8.so.1"
+// CHECK-MIPS64EL-NAN2008-NOT: "--hash-style={{gnu|both}}"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 --target=mips64el-linux-gnu -mcpu=mips64r6 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64R6EL %s
+// CHECK-MIPS64R6EL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64R6EL: "-m" "elf64ltsmip"
+// CHECK-MIPS64R6EL: "-dynamic-linker" "{{.*}}/lib64/ld-linux-mipsn8.so.1"
+// CHECK-MIPS64R6EL-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=mips64-linux-gnu -mabi=n32 \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64-N32 %s
@@ -484,6 +516,7 @@
// CHECK-MIPS64-N32: "-m" "elf32btsmipn32"
// CHECK-MIPS64-N32: "-dynamic-linker" "{{.*}}/lib32/ld.so.1"
// CHECK-MIPS64-N32-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=mips64el-linux-gnu -mabi=n32 \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-N32 %s
@@ -492,6 +525,13 @@
// CHECK-MIPS64EL-N32: "-dynamic-linker" "{{.*}}/lib32/ld.so.1"
// CHECK-MIPS64EL-N32-NOT: "--hash-style={{gnu|both}}"
//
+// RUN: %clang %s -### -o %t.o 2>&1 --target=mips64el-linux-gnu -mabi=n32 \
+// RUN: -mnan=2008 | FileCheck --check-prefix=CHECK-MIPS64EL-N32-NAN2008 %s
+// CHECK-MIPS64EL-N32-NAN2008: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64EL-N32-NAN2008: "-m" "elf32ltsmipn32"
+// CHECK-MIPS64EL-N32-NAN2008: "-dynamic-linker" "{{.*}}/lib32/ld-linux-mipsn8.so.1"
+// CHECK-MIPS64EL-N32-NAN2008-NOT: "--hash-style={{gnu|both}}"
+//
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=sparc-linux-gnu \
// RUN: | FileCheck --check-prefix=CHECK-SPARCV8 %s
More information about the cfe-commits
mailing list