[PATCH] D104531: [LLD] [MinGW] Allow linking to DLLs directly
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 06:07:28 PDT 2021
mstorsjo created this revision.
mstorsjo added reviewers: rnk, mati865.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
As the COFF linker is capable of linking directly against a DLL now
(after D104530 <https://reviews.llvm.org/D104530>, as long as it is running in mingw mode), don't error
out here but successfully load libraries specified with "-l" from DLLs
if that's what ld.bfd would have matched.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104531
Files:
lld/MinGW/Driver.cpp
lld/test/MinGW/lib.test
Index: lld/test/MinGW/lib.test
===================================================================
--- lld/test/MinGW/lib.test
+++ lld/test/MinGW/lib.test
@@ -40,7 +40,7 @@
RUN: echo > %t/lib/libnoimplib.dll
RUN: echo > %t/lib/noprefix_noimplib.dll
-RUN: not ld.lld -### -m i386pep -L%t/lib -lnoimplib 2>&1 | FileCheck -check-prefix=UNSUPPORTED-DLL1 %s
-RUN: not ld.lld -### -m i386pep -L%t/lib -lnoprefix_noimplib 2>&1 | FileCheck -check-prefix=UNSUPPORTED-DLL2 %s
-UNSUPPORTED-DLL1: lld doesn't support linking directly against {{.*}}libnoimplib.dll, use an import library
-UNSUPPORTED-DLL2: lld doesn't support linking directly against {{.*}}noprefix_noimplib.dll, use an import library
+RUN: ld.lld -### -m i386pep -L%t/lib -lnoimplib | FileCheck -check-prefix=DLL1 %s
+RUN: ld.lld -### -m i386pep -L%t/lib -lnoprefix_noimplib | FileCheck -check-prefix=DLL2 %s
+DLL1: libnoimplib.dll
+DLL2: noprefix_noimplib.dll
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -142,16 +142,10 @@
if (!bStatic) {
if (Optional<std::string> s = findFile(dir, name + ".lib"))
return *s;
- if (Optional<std::string> s = findFile(dir, "lib" + name + ".dll")) {
- error("lld doesn't support linking directly against " + *s +
- ", use an import library");
- return "";
- }
- if (Optional<std::string> s = findFile(dir, name + ".dll")) {
- error("lld doesn't support linking directly against " + *s +
- ", use an import library");
- return "";
- }
+ if (Optional<std::string> s = findFile(dir, "lib" + name + ".dll"))
+ return *s;
+ if (Optional<std::string> s = findFile(dir, name + ".dll"))
+ return *s;
}
}
error("unable to find library -l" + name);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104531.352990.patch
Type: text/x-patch
Size: 1867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/0cd9b353/attachment.bin>
More information about the llvm-commits
mailing list