r335691 - [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.
John Baldwin via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 26 17:02:16 PDT 2018
Author: jhb
Date: Tue Jun 26 17:02:16 2018
New Revision: 335691
URL: http://llvm.org/viewvc/llvm-project?rev=335691&view=rev
Log:
[mips] Explicitly specify the linker emulation for MIPS on FreeBSD.
FreeBSD's mips64 builds O32 binaries for /usr/lib32 by default and
thus needs to be able to link O32 binaries which requires an explicit
linker emulation. Go ahead and list all the linker emulation variants
for MIPS so that any supported MIPS ABI binary can be linked by any
linker supporting MIPS.
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D48507
Modified:
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/test/Driver/freebsd.c
Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=335691&r1=335690&r2=335691&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Tue Jun 26 17:02:16 2018
@@ -165,16 +165,39 @@ void freebsd::Linker::ConstructJob(Compi
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)) {
Modified: cfe/trunk/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=335691&r1=335690&r2=335691&view=diff
==============================================================================
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Tue Jun 26 17:02:16 2018
@@ -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 \
More information about the cfe-commits
mailing list