[lld] [lld] check cache in loadDylib before real_path (PR #143595)

Richard Howell via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 11 11:03:39 PDT 2025


================
@@ -225,21 +225,42 @@ std::optional<StringRef> macho::resolveDylibPath(StringRef dylibPath) {
 // especially if it's a commonly re-exported core library.
 static DenseMap<CachedHashStringRef, DylibFile *> loadedDylibs;
 
+static StringRef realPathIfDifferent(StringRef path) {
+  SmallString<128> realPathBuf;
+  std::error_code err = fs::real_path(path, realPathBuf);
+  if (err)
+    return StringRef();
+
+  StringRef realPath(realPathBuf);
+  if (realPath.ends_with(path))
+    return StringRef();
----------------
rmaz wrote:

The intent is to check for when the real_path output matches the input, yes. You are right that the check is insufficient, I suppose I will need to create an absolute path for the input too to compare.

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


More information about the llvm-commits mailing list