[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 26 17:07:19 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL335691: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD. (authored by jhb, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48507

Files:
  cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
  cfe/trunk/test/Driver/freebsd.c


Index: cfe/trunk/test/Driver/freebsd.c
===================================================================
--- cfe/trunk/test/Driver/freebsd.c
+++ cfe/trunk/test/Driver/freebsd.c
@@ -42,6 +42,27 @@
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 //
+// Check that MIPS passes the correct linker emulation.
+//
+// RUN: %clang -target mips-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-LD %s
+// CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd"
+// RUN: %clang -target mipsel-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSEL-LD %s
+// CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64-LD %s
+// CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd"
+// RUN: %clang -target mips64el-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
+// CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32-LD %s
+// CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd"
+// RUN: %clang -target mips64el-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32EL-LD %s
+// CHECK-MIPSN32EL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmipn32_fbsd"
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
Index: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
@@ -165,16 +165,39 @@
     CmdArgs.push_back("--enable-new-dtags");
   }
 
-  // When building 32-bit code on FreeBSD/amd64, we have to explicitly
-  // instruct ld in the base system to link 32-bit code.
-  if (Arch == llvm::Triple::x86) {
+  // Explicitly set the linker emulation for platforms that might not
+  // be the default emulation for the linker.
+  switch (Arch) {
+  case llvm::Triple::x86:
     CmdArgs.push_back("-m");
     CmdArgs.push_back("elf_i386_fbsd");
-  }
-
-  if (Arch == llvm::Triple::ppc) {
+    break;
+  case llvm::Triple::ppc:
     CmdArgs.push_back("-m");
     CmdArgs.push_back("elf32ppc_fbsd");
+    break;
+  case llvm::Triple::mips:
+    CmdArgs.push_back("-m");
+    CmdArgs.push_back("elf32btsmip_fbsd");
+    break;
+  case llvm::Triple::mipsel:
+    CmdArgs.push_back("-m");
+    CmdArgs.push_back("elf32ltsmip_fbsd");
+    break;
+  case llvm::Triple::mips64:
+    CmdArgs.push_back("-m");
+    if (tools::mips::hasMipsAbiArg(Args, "n32"))
+      CmdArgs.push_back("elf32btsmipn32_fbsd");
+    else
+      CmdArgs.push_back("elf64btsmip_fbsd");
+    break;
+  case llvm::Triple::mips64el:
+    CmdArgs.push_back("-m");
+    if (tools::mips::hasMipsAbiArg(Args, "n32"))
+      CmdArgs.push_back("elf32ltsmipn32_fbsd");
+    else
+      CmdArgs.push_back("elf64ltsmip_fbsd");
+    break;
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_G)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48507.152991.patch
Type: text/x-patch
Size: 3301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180627/868251d9/attachment-0001.bin>


More information about the cfe-commits mailing list