[PATCH] D155268: [lld][COFF] Find libraries with relative paths. r=hans,maskray,mstorsjo,phosek,rnk

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 00:43:47 PDT 2023


thieta created this revision.
thieta added reviewers: hans, MaskRay, mstorsjo, phosek, rnk.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is spun out of https://reviews.llvm.org/D151188
and makes it possible for lld-link to find libraries with
relative paths. This will be used later to implement the
changes to autolinking runtimes explained in #63827


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155268

Files:
  lld/COFF/Driver.cpp
  lld/docs/ReleaseNotes.rst
  lld/test/COFF/relative_search_paths.test


Index: lld/test/COFF/relative_search_paths.test
===================================================================
--- /dev/null
+++ lld/test/COFF/relative_search_paths.test
@@ -0,0 +1,4 @@
+We should be able to find libraries with relative search paths.
+# RUN: mkdir -p %t.dir/relative/path
+# RUN: cp %p/Inputs/std64.lib %t.dir/relative/path
+# RUN: lld-link %p/Inputs/hello64.obj /libpath:%t.dir relative/path/std64.lib /entry:main
Index: lld/docs/ReleaseNotes.rst
===================================================================
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -37,6 +37,8 @@
 COFF Improvements
 -----------------
 
+* lld-link can now find libraries with relative search paths.
+
 MinGW Improvements
 ------------------
 
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -483,8 +483,7 @@
     return filename;
   };
 
-  bool hasPathSep = (filename.find_first_of("/\\") != StringRef::npos);
-  if (hasPathSep)
+  if (sys::path::is_absolute(filename))
     return getFilename(filename);
   bool hasExt = filename.contains('.');
   for (StringRef dir : searchPaths) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155268.540298.patch
Type: text/x-patch
Size: 1204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230714/4bb8e49b/attachment.bin>


More information about the llvm-commits mailing list