]> granicus.if.org Git - clang/commitdiff
[VS Toolchain] Correctly forward -l linker inputs to link.exe.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 18 Jun 2012 16:56:04 +0000 (16:56 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 18 Jun 2012 16:56:04 +0000 (16:56 +0000)
Patch by Nikola Smiljanic!

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

lib/Driver/Tools.cpp
test/Driver/msvc_forward.c [new file with mode: 0644]

index 150815096f6a178c7c5c8a24bee932cdf5f51ea5..f354c13a74681a2989337681e03b935b8f14168e 100644 (file)
@@ -5739,7 +5739,14 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA,
 
   CmdArgs.push_back("-nologo");
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  Args.AddAllArgValues(CmdArgs, options::OPT_l);
+
+  // Add filenames immediately.
+  for (InputInfoList::const_iterator
+       it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
+    if (it->isFilename())
+      CmdArgs.push_back(it->getFilename());
+  }
 
   const char *Exec =
     Args.MakeArgString(getToolChain().GetProgramPath("link.exe"));
diff --git a/test/Driver/msvc_forward.c b/test/Driver/msvc_forward.c
new file mode 100644 (file)
index 0000000..fe0ae84
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang -target i686-pc-win32 -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s
+// CHECK-NOT: "-lkernel32.lib"
+// CHECK-NOT: "-luser32.lib"
+// CHECK: "kernel32.lib"
+// CHECK: "user32.lib"