[PATCH] D37794: [LLD] [MinGW] Only apply -Bstatic to following libraries
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 00:56:53 PDT 2017
mstorsjo created this revision.
This is how the flag is documented in GNU binutils ld; -Bstatic only applies to -l options after it, until the next -Bdynamic.
https://reviews.llvm.org/D37794
Files:
MinGW/Driver.cpp
test/MinGW/lib.test
Index: test/MinGW/lib.test
===================================================================
--- test/MinGW/lib.test
+++ test/MinGW/lib.test
@@ -7,9 +7,15 @@
RUN: ld.lld -### -m i386pep -lfoo -L%t/lib | FileCheck -check-prefix=LIB2 %s
LIB2: libfoo.dll.a
-RUN: not ld.lld -### -m i386pep -lfoo -L%t/lib -Bstatic 2>&1 | FileCheck -check-prefix=LIB3 %s
+RUN: not ld.lld -### -m i386pep -Bstatic -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB3 %s
LIB3: unable to find library -lfoo
RUN: echo > %t/lib/libfoo.a
-RUN: ld.lld -### -m i386pep -lfoo -L%t/lib -Bstatic | FileCheck -check-prefix=LIB4 %s
+RUN: ld.lld -### -m i386pep -Bstatic -lfoo -L%t/lib | FileCheck -check-prefix=LIB4 %s
LIB4: libfoo.a
+
+RUN: echo > %t/lib/libbar.dll.a
+RUN: echo > %t/lib/libbar.a
+RUN: ld.lld -### -m i386pep -Bstatic -lfoo -Bdynamic -lbar -L%t/lib | FileCheck -check-prefix=LIB5 %s
+LIB5: libfoo.a
+LIB5-SAME: libbar.dll.a
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -174,25 +174,32 @@
SearchPaths.push_back(A->getValue());
StringRef Prefix = "";
- for (auto *A : Args.filtered(OPT_INPUT, OPT_l, OPT_whole_archive,
- OPT_no_whole_archive)) {
+ bool Static = false;
+ for (auto *A :
+ Args.filtered(OPT_INPUT, OPT_l, OPT_whole_archive, OPT_no_whole_archive,
+ OPT_Bstatic, OPT_Bdynamic)) {
switch (A->getOption().getID()) {
case OPT_INPUT:
if (StringRef(A->getValue()).endswith(".def"))
Add("-def:" + StringRef(A->getValue()));
else
Add(Prefix + StringRef(A->getValue()));
break;
case OPT_l:
- Add(Prefix +
- searchLibrary(A->getValue(), SearchPaths, Args.hasArg(OPT_Bstatic)));
+ Add(Prefix + searchLibrary(A->getValue(), SearchPaths, Static));
break;
case OPT_whole_archive:
Prefix = "-wholearchive:";
break;
case OPT_no_whole_archive:
Prefix = "";
break;
+ case OPT_Bstatic:
+ Static = true;
+ break;
+ case OPT_Bdynamic:
+ Static = false;
+ break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37794.114989.patch
Type: text/x-patch
Size: 2170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/046930fe/attachment.bin>
More information about the llvm-commits
mailing list