[MinGW] Pass libpath to the COFF linker
authorMartin Storsjo <martin@martin.st>
Wed, 10 Oct 2018 09:00:03 +0000 (09:00 +0000)
committerMartin Storsjo <martin@martin.st>
Wed, 10 Oct 2018 09:00:03 +0000 (09:00 +0000)
This is necessary for handling defaultlib directives embedded in
object files, unless they use an absolute path.

Differential Revision: https://reviews.llvm.org/D53015

llvm-svn: 344123

lld/MinGW/Driver.cpp
lld/test/MinGW/driver.test

index dc9b046..d682baf 100644 (file)
@@ -216,8 +216,10 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
     Add("-include:" + StringRef(A->getValue()));
 
   std::vector<StringRef> SearchPaths;
-  for (auto *A : Args.filtered(OPT_L))
+  for (auto *A : Args.filtered(OPT_L)) {
     SearchPaths.push_back(A->getValue());
+    Add("-libpath:" + StringRef(A->getValue()));
+  }
 
   StringRef Prefix = "";
   bool Static = false;
index 58c589c..3222bb1 100644 (file)
@@ -148,3 +148,6 @@ MAP: -lldmap:bar.map
 
 RUN: ld.lld -### foo.o -m i386pe -require-defined _foo --require-defined _bar -require-defined=_baz --require-defined=_foo2 | FileCheck -check-prefix=REQUIRE-DEFINED %s
 REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2
+
+RUN: ld.lld -### -m i386pep foo.o -Llibpath | FileCheck -check-prefix LIBPATH %s
+LIBPATH: -libpath:libpath