[PATCH] D157716: [LLD][MachO] Postprocess LC Linker Option

Kyungwoo Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 07:20:17 PDT 2023


kyulee created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
kyulee requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

LLD resolves symbols regardless of LTO modes early when reading and parsing input files in order. The object files built from LTO passes are appended later.
Because LLD eagerly resolves the LC linker options while parsing a new object file (and its chain of dependent libraries), the prior decision on pending prevailing symbols (belonging to some bitcode files) can change to ones in those native libraries that are just loaded.

This patch delays processing LC linker options until all the native object files are added after LTO is done, similar to LD64. This way we preserve the decision on prevailing symbols LLD made, regardless of LTO modes.

- When parsing a new object file in `parseLinkerOptions()`, it just parses LC linker options in the header, and saves those contents to `unprocessedLCLinkerOptions`.
- After LTO is finished, `resolveLCLinkerOptions()` is called to recursively load dependent libraries, starting with initial linker options collected in `unprocessedLCLinkerOptions` (which also updates during recursions)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157716

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157716.549386.patch
Type: text/x-patch
Size: 17165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/26eb5ad8/attachment.bin>


More information about the llvm-commits mailing list