[lld] [lld] resolve dylib paths before caching (PR #137649)

Daniel Rodríguez Troitiño via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 28 16:54:53 PDT 2025


================
@@ -229,7 +230,13 @@ static DenseMap<CachedHashStringRef, DylibFile *> loadedDylibs;
 
 DylibFile *macho::loadDylib(MemoryBufferRef mbref, DylibFile *umbrella,
                             bool isBundleLoader, bool explicitlyLinked) {
-  CachedHashStringRef path(mbref.getBufferIdentifier());
+  // Frameworks can be found from different symlink paths, so resolve
+  // symlinks before looking up in the dylib cache.
+  SmallString<128> realPath;
+  std::error_code err = fs::real_path(mbref.getBufferIdentifier(), realPath);
+  CachedHashStringRef path(err.value() == 0
+                               ? uniqueSaver().save(StringRef(realPath))
+                               : mbref.getBufferIdentifier());
----------------
drodriguez wrote:

```
CachedHashStringRef path(!err
                               ? uniqueSaver().save(StringRef(realPath))
                               : mbref.getBufferIdentifier());
```

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


More information about the llvm-commits mailing list