[lld] [lld] resolve dylib paths before caching (PR #137649)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 08:28:12 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-macho
@llvm/pr-subscribers-lld
Author: Richard Howell (rmaz)
<details>
<summary>Changes</summary>
When loading frameworks it is possible to have load commands for the same framework through symlinks and the real path. To avoid loading these multiple times find the real path before checking the dylib cache.
---
Full diff: https://github.com/llvm/llvm-project/pull/137649.diff
1 Files Affected:
- (modified) lld/MachO/DriverUtils.cpp (+5-1)
``````````diff
diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 69d023c23b3c7..7f3ffa83c0cf0 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -229,7 +229,11 @@ 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;
+ fs::real_path(mbref.getBufferIdentifier(), realPath);
+ CachedHashStringRef path(uniqueSaver().save(StringRef(realPath)));
DylibFile *&file = loadedDylibs[path];
if (file) {
if (explicitlyLinked)
``````````
</details>
https://github.com/llvm/llvm-project/pull/137649
More information about the llvm-commits
mailing list