[all-commits] [llvm/llvm-project] 2ae3fa: [lld-macho] Sort LC_LINKER_OPTIONS before processi...
Nuri Amari via All-commits
all-commits at lists.llvm.org
Tue Jun 9 07:57:57 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2ae3fa77da6c393c5b47ced09b6d91551d178b57
https://github.com/llvm/llvm-project/commit/2ae3fa77da6c393c5b47ced09b6d91551d178b57
Author: Nuri Amari <nuri.amari99 at gmail.com>
Date: 2026-06-09 (Tue, 09 Jun 2026)
Changed paths:
M lld/MachO/Driver.cpp
M lld/docs/ReleaseNotes.rst
R lld/test/MachO/lc-linker-option-order.ll
A lld/test/MachO/lc-linker-option-postprocess.ll
A lld/test/MachO/lc-linker-option-sort.ll
Log Message:
-----------
[lld-macho] Sort LC_LINKER_OPTIONS before processing (#201604)
Previously https://reviews.llvm.org/D157716 brought handling of
LC_LINKER_OPTIONS closer to Apple linker behavior by processing the
options at the end after all object files have been added.
This corrects another difference in behavior, processing frameworks
before regular libraries (linked with -lFoo), and processing each group
in sorted order.
Processing a LC_LINKER_OPTIONS can trigger loads of more object files
which in turn may have more LC_LINKER_OPTIONS. We iterate this to a
fixed point, walking this graph in BFS order, processing each "level" of
the graph in the order described above. This graph traversal order
hasn't changed in this commit, only the sorting has.
The diff of the linker map produced for the included test before and
after:
```
23,28c23,28
< 0x000003D0 0x00000001 [ 4] _zlib
< 0x000003E0 0x00000001 [ 5] _zed_framework
< 0x000003F0 0x00000001 [ 6] _mlib
< 0x00000400 0x00000001 [ 7] _alpha_framework
< 0x00000410 0x00000001 [ 8] _alib
< 0x00000420 0x00000001 [ 9] _mid_framework
---
> 0x000003D0 0x00000001 [ 4] _alpha_framework
> 0x000003E0 0x00000001 [ 5] _mid_framework
> 0x000003F0 0x00000001 [ 6] _zed_framework
> 0x00000400 0x00000001 [ 7] _alib
> 0x00000410 0x00000001 [ 8] _mlib
> 0x00000420 0x00000001 [ 9] _zlib
```
Apple's linker produces the same order as after.
---------
Co-authored-by: Nuri Amari <nuriamari at fb.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list