r274356 - Driver: support -L for MSVC toolchain under the GNU driver

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 08:36:31 PDT 2016


Author: compnerd
Date: Fri Jul  1 10:36:31 2016
New Revision: 274356

URL: http://llvm.org/viewvc/llvm-project?rev=274356&view=rev
Log:
Driver: support -L for MSVC toolchain under the GNU driver

When not using clang in the CL emulation mode, honour the -L flags as additional
library paths to pass to the linker invocation.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/msvc-link.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274356&r1=274355&r2=274356&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul  1 10:36:31 2016
@@ -9950,6 +9950,10 @@ void visualstudio::Linker::ConstructJob(
                                            WindowsSdkLibPath.c_str()));
   }
 
+  if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L))
+    for (const auto &LibPath : Args.getAllArgValues(options::OPT_L))
+      CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath));
+
   CmdArgs.push_back("-nologo");
 
   if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))

Modified: cfe/trunk/test/Driver/msvc-link.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-link.c?rev=274356&r1=274355&r2=274356&view=diff
==============================================================================
--- cfe/trunk/test/Driver/msvc-link.c (original)
+++ cfe/trunk/test/Driver/msvc-link.c Fri Jul  1 10:36:31 2016
@@ -10,3 +10,9 @@
 // DLL: "-defaultlib:libcmt"
 // DLL: "-nologo"
 // DLL: "-dll"
+
+// RUN: %clang -target i686-pc-windows-msvc -L/var/empty -L/usr/lib -### %s 2>&1 | FileCheck --check-prefix LIBPATH %s
+// LIBPATH: "-libpath:/var/empty"
+// LIBPATH: "-libpath:/usr/lib"
+// LIBPATH: "-nologo"
+




More information about the cfe-commits mailing list