r317511 - Vary Windows toolchain selection by -fuse-ld
Dave Lee via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 6 13:18:05 PST 2017
Author: kastiglione
Date: Mon Nov 6 13:18:05 2017
New Revision: 317511
URL: http://llvm.org/viewvc/llvm-project?rev=317511&view=rev
Log:
Vary Windows toolchain selection by -fuse-ld
Summary:
This change allows binutils to be used for linking with MSVC. Currently, when
using an MSVC target and `-fuse-ld=bfd`, the driver produces an invalid linker
invocation.
Reviewers: rnk, compnerd
Reviewed By: compnerd
Subscribers: smeenai, cfe-commits
Differential Revision: https://reviews.llvm.org/D39509
Added:
cfe/trunk/test/Driver/Inputs/Windows/usr/
cfe/trunk/test/Driver/Inputs/Windows/usr/bin/
cfe/trunk/test/Driver/Inputs/Windows/usr/bin/ld.bfd (with props)
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/fuse-ld.c
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=317511&r1=317510&r2=317511&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Nov 6 13:18:05 2017
@@ -3880,7 +3880,13 @@ const ToolChain &Driver::getToolChain(co
break;
case llvm::Triple::MSVC:
case llvm::Triple::UnknownEnvironment:
- TC = llvm::make_unique<toolchains::MSVCToolChain>(*this, Target, Args);
+ if (Args.getLastArgValue(options::OPT_fuse_ld_EQ)
+ .startswith_lower("bfd"))
+ TC = llvm::make_unique<toolchains::CrossWindowsToolChain>(
+ *this, Target, Args);
+ else
+ TC =
+ llvm::make_unique<toolchains::MSVCToolChain>(*this, Target, Args);
break;
}
break;
Added: cfe/trunk/test/Driver/Inputs/Windows/usr/bin/ld.bfd
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/Windows/usr/bin/ld.bfd?rev=317511&view=auto
==============================================================================
(empty)
Propchange: cfe/trunk/test/Driver/Inputs/Windows/usr/bin/ld.bfd
------------------------------------------------------------------------------
svn:executable = *
Modified: cfe/trunk/test/Driver/fuse-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuse-ld.c?rev=317511&r1=317510&r2=317511&view=diff
==============================================================================
--- cfe/trunk/test/Driver/fuse-ld.c (original)
+++ cfe/trunk/test/Driver/fuse-ld.c Mon Nov 6 13:18:05 2017
@@ -67,3 +67,29 @@
// RUN: -gcc-toolchain %S/Inputs/basic_android_tree 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ANDROID-ARM-GOLD-TC
// CHECK-ANDROID-ARM-GOLD-TC: Inputs/basic_android_tree/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin{{/|\\+}}ld.gold
+
+
+// RUN: %clang %s -### -fuse-ld=link \
+// RUN: -target i686-unknown-windows-msvc 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LINK
+// CHECK-WINDOWS-MSVC-LINK: "{{.*}}link.exe"
+// CHECK-WINDOWS-MSVC-LINK-SAME: "-out:{{.*}}"
+
+// RUN: %clang %s -### -fuse-ld=lld \
+// RUN: -target i686-unknown-windows-msvc 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD
+// CHECK-WINDOWS-MSVC-LLD: "{{.*}}lld-link"
+// CHECK-WINDOWS-MSVC-LLD-SAME: "-out:{{.*}}"
+
+// RUN: %clang %s -### -fuse-ld=lld-link \
+// RUN: -target i686-unknown-windows-msvc 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-LLD-LINK
+// CHECK-WINDOWS-MSVC-LLD-LINK: "{{.*}}lld-link"
+// CHECK-WINDOWS-MSVC-LLD-LINK-SAME: "-out:{{.*}}"
+
+// RUN: %clang %s -### -fuse-ld=bfd \
+// RUN: -target i686-unknown-windows-msvc \
+// RUN: -B %S/Inputs/Windows/usr/bin 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-BFD
+// CHECK-WINDOWS-MSVC-BFD: "{{.*}}ld.bfd"
+// CHECK-WINDOWS-MSVC-BFD-SAME: "-o"
More information about the cfe-commits
mailing list