diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/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) { diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst --- a/lld/docs/ReleaseNotes.rst +++ b/lld/docs/ReleaseNotes.rst @@ -37,6 +37,8 @@ COFF Improvements ----------------- +* lld-link can now find libraries with relative search paths. + MinGW Improvements ------------------ diff --git a/lld/test/COFF/relative_search_paths.test b/lld/test/COFF/relative_search_paths.test new file mode 100644 --- /dev/null +++ b/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