[PATCH] D103990: [lld/mac] When handling @loader_path, use realpath() of symlinks

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 9 17:25:11 PDT 2021


int3 accepted this revision.
int3 added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lld/MachO/InputFiles.cpp:794
   } else if (path.consume_front("@loader_path/")) {
-    path::append(newPath, sys::path::parent_path(umbrella->getName()), path);
+    fs::real_path(umbrella->getName(), newPath);
+    path::remove_filename(newPath);
----------------
thakis wrote:
> int3 wrote:
> > Would it make sense to call `realPath` before constructing MemoryBuffers in `readFile`, so that `getName()` always returns a canonicalized path? Or would that mess up other things?
> I think that'd be good. It'd also make us not load libSystem twice when doing `-lSystem -lpthreads`. I'm a bit scared of changing that though (for no good reason), so I'd like to land the smaller change (and the test) here first if that's ok. I hereby pledge to send you a follow-up that tries moving this call earlier :)
> 
> (ld64 has the realpath call in its code corresponding to the code here -- but parts of ld64 are all over the place so that doesn't necessarily mean much.)
Fair enough :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103990/new/

https://reviews.llvm.org/D103990



More information about the llvm-commits mailing list