[PATCH] D53017: [LLD] [COFF] Look for libfoo.a if foo.lib is specified, for MinGW
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 9 14:16:23 PDT 2018
mstorsjo updated this revision to Diff 168872.
mstorsjo retitled this revision from "[LLD] [COFF] Look for libfoo.a and libfoo.dll.a, if foo.lib is specified as defaultlibrary, for MinGW" to "[LLD] [COFF] Look for libfoo.a if foo.lib is specified, for MinGW".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.
Simplified it to only care about the case of system libraries for now. As this feature isn't available in ld.bfd and therefore not in use in the general mingw ecosystem, it might be ok to limit it to this case for now, for use with sanitizers?
https://reviews.llvm.org/D53017
Files:
COFF/Driver.cpp
test/COFF/libname-mingw.test
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
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53017.168872.patch
Type: text/x-patch
Size: 1226 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181009/9041658b/attachment.bin>
More information about the llvm-commits
mailing list