[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 03:10:01 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6c2f100c23b: [lld][COFF] Find libraries with relative paths. (authored by thieta).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155268/new/

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,12 @@
 COFF Improvements
 -----------------
 
+* lld-link can now find libraries with relative paths that are relative to
+  `/libpath`. Before it would only be able to find libraries relative to the
+  current directory.
+  I.e. ``lld-link /libpath:c:\relative\root relative\path\my.lib`` where before
+  we would have to do ``lld-link /libpath:c:\relative\root\relative\path my.lib``
+
 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.540343.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230714/7b33b172/attachment.bin>


More information about the llvm-commits mailing list