[lld] [LLD] [COFF] Don't look up relative paths to parent directories in the search paths (PR #67858)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 01:36:35 PDT 2023


================
@@ -483,7 +483,10 @@ StringRef LinkerDriver::findFile(StringRef filename) {
     return filename;
   };
 
-  if (sys::path::is_absolute(filename))
+  bool hasParentDir = filename.starts_with("../") ||
----------------
mstorsjo wrote:

Yep, that's true. The distinction between `../something-in-parent-dir` vs `dir/another/../` is kinda tricky; the former is the one that will occur practically, the second one is mostly just covering the theoretical cases. Perhaps we don't need to care about that one?

As for the backslashes, I think that would only be testable on Windows (unless we treat it as plain opaque strings...). The current test, which just expects a failure, probably would be good even with foreign backslashes, but a better version of the test (that check that it actually does find one library based on cwd, not on libpath) wouldn't.

https://github.com/llvm/llvm-project/pull/67858


More information about the llvm-commits mailing list