Skip to content

Commit e07307b

Browse files
authored
[lld] resolve dylib paths before caching (#137649)
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 e0660ed commit e07307b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lld/MachO/DriverUtils.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ 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+
std::error_code err = fs::real_path(mbref.getBufferIdentifier(), realPath);
236+
CachedHashStringRef path(!err ? uniqueSaver().save(StringRef(realPath))
237+
: mbref.getBufferIdentifier());
233238
DylibFile *&file = loadedDylibs[path];
234239
if (file) {
235240
if (explicitlyLinked)

0 commit comments

Comments
 (0)