Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -377,7 +377,17 @@ bool HasExt = Filename.contains('.'); if (!HasExt) Filename = Saver.save(Filename + ".lib"); - return doFindFile(Filename); + StringRef Ret = doFindFile(Filename); + if (Config->MinGW && Ret == Filename && HasExt && !Filename.contains('/') && + !Filename.contains('\\')) { + SmallString<128> S = Filename; + sys::path::replace_extension(S, ".a"); + StringRef LibName = Saver.save("lib" + S.str()); + StringRef LibNameRet = doFindFile(LibName); + if (LibNameRet != LibName) + return LibNameRet; + } + return Ret; } // Resolves a library path. /nodefaultlib options are taken into Index: test/COFF/libname-mingw.test =================================================================== --- /dev/null +++ test/COFF/libname-mingw.test @@ -0,0 +1,8 @@ +# RUN: mkdir -p %t/a +# RUN: cp %p/Inputs/std64.lib %t/a/libstd64.a + +# RUN: lld-link /lldmingw /out:%t.exe /entry:main /verbose \ +# RUN: /defaultlib:std64.lib /subsystem:console %p/Inputs/hello64.obj \ +# RUN: /libpath:%t/a 2>&1 | FileCheck %s + +CHECK: a{{[/\\]}}libstd64.a