forked from OSchip/llvm-project
[LLD] [MinGW] Allow linking to DLLs directly
As the COFF linker is capable of linking directly against a DLL now (after 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. Differential Revision: https://reviews.llvm.org/D104531
This commit is contained in:
parent
a9ff1ce1b9
commit
c09e5e50b1
|
@ -142,16 +142,10 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
|
|||
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);
|
||||
|
|
|
@ -40,7 +40,7 @@ OTHERSTYLES-SAME: msvcstyle.lib
|
|||
|
||||
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 2>&1 | FileCheck -check-prefix=DLL1 %s
|
||||
RUN: ld.lld -### -m i386pep -L%t/lib -lnoprefix_noimplib 2>&1 | FileCheck -check-prefix=DLL2 %s
|
||||
DLL1: libnoimplib.dll
|
||||
DLL2: noprefix_noimplib.dll
|
||||
|
|
Loading…
Reference in New Issue