Skip to content

Commit 9f6332f

Browse files
committed
[lld] resolve dylib paths before caching
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.
1 parent 258e143 commit 9f6332f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lld/MachO/DriverUtils.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ static DenseMap<CachedHashStringRef, DylibFile *> loadedDylibs;
229229

230230
DylibFile *macho::loadDylib(MemoryBufferRef mbref, DylibFile *umbrella,
231231
bool isBundleLoader, bool explicitlyLinked) {
232-
CachedHashStringRef path(mbref.getBufferIdentifier());
232+
// Frameworks can be found from different symlink paths, so resolve
233+
// symlinks before looking up in the dylib cache.
234+
SmallString<128> realPath;
235+
fs::real_path(mbref.getBufferIdentifier(), realPath);
236+
CachedHashStringRef path(uniqueSaver().save(StringRef(realPath)));
233237
DylibFile *&file = loadedDylibs[path];
234238
if (file) {
235239
if (explicitlyLinked)

0 commit comments

Comments
 (0)