[PATCH] D140592: [lld-macho] Skip re-loading archive if already loaded

Vincent Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 17:02:48 PST 2022


thevinster created this revision.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
thevinster edited the summary of this revision.
thevinster edited the summary of this revision.
thevinster edited the summary of this revision.
thevinster edited the summary of this revision.
thevinster published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When an archive is loaded via an LC_LINKER_OPTION, loading it again will
cause duplicate symbols. This check has been added here <https://github.com/llvm/llvm-project/blob/main/lld/MachO/Driver.cpp#L303-L304>. However,
this didn't handle the case where the archive paths are different. For example,
we could be loading a framework and that same framework can be bundled
in another static library. If we are force loading those objects via ObjC, we will 
end up with duplicate symbols.

Here, add another check that hashes on the contents and skips loading an 
archive's children if the module has already been loaded. This requires making 
`seen` a global property instead of a class property so it can properly track the
different archives being loaded. This also matches ld64's behavior.

While I'm here, make the output test executables be unique so it's easier to debug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140592

Files:
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/test/MachO/lc-linker-option.ll
  lld/test/MachO/objc.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140592.484990.patch
Type: text/x-patch
Size: 9868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221223/221aa0c0/attachment.bin>


More information about the llvm-commits mailing list