]> granicus.if.org Git - clang/commitdiff
Driver: Specifically tell the linker the target for mingw-w64
authorMartell Malone <martellmalone@gmail.com>
Sun, 22 Nov 2015 05:40:06 +0000 (05:40 +0000)
committerMartell Malone <martellmalone@gmail.com>
Sun, 22 Nov 2015 05:40:06 +0000 (05:40 +0000)
Cross compiling from linux and OSX results in Error: Exec format.
This is because the linker is expecting ELF formated objects.
By passing the target we can explicitly tell the linker that
it should be linking COFF objects regardless of the host.

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

lib/Driver/Tools.cpp

index 9efaaad55582385c3620b5d291529f5a3937bc40..acf2cbcf1c2098ab396dbd5c78959557675e9bed 100644 (file)
@@ -9478,7 +9478,14 @@ void MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
   if (LinkerName.equals_lower("lld")) {
     CmdArgs.push_back("-flavor");
-    CmdArgs.push_back("old-gnu");
+    CmdArgs.push_back("gnu");
+    CmdArgs.push_back("-target");
+    if (TC.getArch() == llvm::Triple::x86)
+      CmdArgs.push_back("i686--windows-gnu");
+    if (TC.getArch() == llvm::Triple::x86_64)
+      CmdArgs.push_back("x86_64--windows-gnu");
+    if (TC.getArch() == llvm::Triple::arm)
+      CmdArgs.push_back("armv7--windows-gnu");
   } else if (!LinkerName.equals_lower("ld")) {
     D.Diag(diag::err_drv_unsupported_linker) << LinkerName;
   }