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

Richard Howell via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 07:02:18 PDT 2025


================
@@ -253,6 +265,7 @@ DylibFile *macho::loadDylib(MemoryBufferRef mbref, DylibFile *umbrella,
     }
     file =
         make<DylibFile>(**result, umbrella, isBundleLoader, explicitlyLinked);
+    realfile = file;
----------------
rmaz wrote:

That would mean that we would never cache symlinks, only their resolved paths, which is the unhappy path. That would be a significant regression as a large number of load commands are symlinks (eg `Foundation.framework/Foundation` -> `Foundation.framework/Versions/A/Foundation`). 

I also disagree with the idea of regressing the performance to reduce the amount of code by 2 lines.

The only alternative I can see is to do have realfile default to a nullptr and have the two setters change to:
```
if (realfile)
  realfile = file;
```
Can't say I prefer it though.

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


More information about the llvm-commits mailing list