This matches how ld.bfd works in practice; this fixes https://github.com/mstorsjo/llvm-mingw/issues/305. Adding a test for the new lib name combination that this allows, but also adding a few negative tests for combinations that aren't matched when -static is specified (because this change in itself didn't break any of the existing tests either). The logic in how ld.bfd looks for various libraries based on an -l<libname> argument is rather complex; the ldemul_open_dynamic_archive function looks for various combinations: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/emultempl/pep.em;h=e68d1e69f17ad73af065b6bed19ae89ded913172;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l2066 This function is only called if looking for dynamic libraries (i.e. if -static wasn't specified): https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldfile.c;h=731ae5f7aedcf921bd36a1b32a3e0f5bfa189071;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l365 However even this function is skipped, it still looks for libraries in the form of "lib<libname>.a" (this is what lld did before): https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/ldfile.c;h=731ae5f7aedcf921bd36a1b32a3e0f5bfa189071;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l440 But it also calls a format specific function called ldemul_find_potential_libraries, which for PE targets looks for files named "<libname>.lib": https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/emultempl/pep.em;h=e68d1e69f17ad73af065b6bed19ae89ded913172;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l2175 Differential Revision: https://reviews.llvm.org/D135651
58 lines
2.7 KiB
Plaintext
58 lines
2.7 KiB
Plaintext
RUN: rm -rf %t/lib
|
|
RUN: mkdir -p %t/lib
|
|
RUN: not ld.lld -### -m i386pep -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB1 %s
|
|
LIB1: unable to find library -lfoo
|
|
|
|
RUN: echo > %t/lib/libfoo.dll.a
|
|
RUN: ld.lld -### -m i386pep -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB2 %s
|
|
LIB2: libfoo.dll.a
|
|
|
|
RUN: not ld.lld -### -m i386pep -l:barefilename -L%t/lib 2>&1 | FileCheck -check-prefix=LIB-LITERAL-FAIL %s
|
|
LIB-LITERAL-FAIL: unable to find library -l:barefilename
|
|
|
|
RUN: echo > %t/lib/barefilename
|
|
RUN: ld.lld -### -m i386pep -l:barefilename -L%t/lib 2>&1 | FileCheck -check-prefix=LIB-LITERAL %s
|
|
LIB-LITERAL: barefilename
|
|
|
|
RUN: not ld.lld -### -m i386pep -Bstatic -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB3 %s
|
|
RUN: not ld.lld -### -m i386pep -dn -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB3 %s
|
|
RUN: not ld.lld -### -m i386pep -static -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB3 %s
|
|
RUN: not ld.lld -### -m i386pep -non_shared -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 -Bstatic -lfoo -L%t/lib 2>&1 | 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 2>&1 | FileCheck -check-prefix=LIB5 %s
|
|
RUN: ld.lld -### -m i386pep -Bstatic -lfoo -dy -lbar -L%t/lib 2>&1 | FileCheck -check-prefix=LIB5 %s
|
|
RUN: ld.lld -### -m i386pep -Bstatic -lfoo -call_shared -lbar -L%t/lib 2>&1 | FileCheck -check-prefix=LIB5 %s
|
|
LIB5: libfoo.a
|
|
LIB5-SAME: libbar.dll.a
|
|
|
|
RUN: echo > %t/lib/noprefix.dll.a
|
|
RUN: echo > %t/lib/msvcstyle.lib
|
|
RUN: ld.lld -### -m i386pep -L%t/lib -lnoprefix -lmsvcstyle 2>&1 | FileCheck -check-prefix=OTHERSTYLES %s
|
|
OTHERSTYLES: noprefix.dll.a
|
|
OTHERSTYLES-SAME: msvcstyle.lib
|
|
|
|
RUN: not ld.lld -### -m i386pep -L%t/lib -static -lnoprefix 2>&1 | FileCheck -check-prefix=ERROR-NOPREFIX %s
|
|
ERROR-NOPREFIX: unable to find library -lnoprefix
|
|
|
|
RUN: ld.lld -### -m i386pep -L%t/lib -static -lmsvcstyle 2>&1 | FileCheck -check-prefix=MSVCSTYLE %s
|
|
MSVCSTYLE: msvcstyle.lib
|
|
|
|
RUN: echo > %t/lib/libnoimplib.dll
|
|
RUN: echo > %t/lib/noprefix_noimplib.dll
|
|
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
|
|
|
|
RUN: not ld.lld -### -m i386pep -L%t/lib -static -lnoimplib 2>&1 | FileCheck -check-prefix=ERROR-NOIMPLIB %s
|
|
RUN: not ld.lld -### -m i386pep -L%t/lib -static -lnoprefix_noimplib 2>&1 | FileCheck -check-prefix=ERROR-NOPREFIX-NOIMPLIB %s
|
|
ERROR-NOIMPLIB: unable to find library -lnoimplib
|
|
ERROR-NOPREFIX-NOIMPLIB: unable to find library -lnoprefix_noimplib
|