blob: f37e18b3aeb1971d3b180dcd71d42ef272680041 [file] [log] [blame] [view]
Nico Weber22d0d662020-12-07 23:35:061# LLD for Mac builds
2
Nico Weber9d31eda2023-06-05 17:54:063Like on other platforms, Chromium uses the LLD linker on iOS and macOS.
Nico Weber22d0d662020-12-07 23:35:064
5## Background
6
Nico Weber44f066e2022-09-05 02:36:137Chromium uses [LLD](https://lld.llvm.org/) as linker on all platforms.
8LLD is faster than other ELF linkers (ELF
Nico Weber22d0d662020-12-07 23:35:069is the executable file format used on most OSs, including Linux, Android,
10Chrome OS, Fuchsia), and it's faster than other COFF linkers (the executable
11file format on Windows).
12
Nico Weber9d31eda2023-06-05 17:54:0613LLD is currently twice as fast as ld64, the macOS system linker, at linking
Nico Weber2fe545742021-07-09 19:44:3614Chromium Framework in symbol\_level=0 release builds, despite ld64 being already
Nico Weber9d31eda2023-06-05 17:54:0615fast. (Before Xcode 14.1, LLD was 6x as fast as ld64.)
Nico Weber22d0d662020-12-07 23:35:0616
Nico Weber588d3d532021-07-09 11:22:4317LLD has advantages unrelated to speed, too:
Nico Weber22d0d662020-12-07 23:35:0618
Nico Weber588d3d532021-07-09 11:22:4319- It's developed in the LLVM repository, and we ship it in our clang package.
20 We can fix issues upstream and quickly deploy fixed versions, instead of
21 having to wait for Xcode releases (which is where ld64 ships).
Nico Weber22d0d662020-12-07 23:35:0622
23- For the same reason, it has a much simpler LTO setup: Clang and LLD both link
24 in the same LLVM libraries that are built at the same revision, and compiler
25 and linker bitcodes are interopable for that reason. With ld64, the LTO code
26 has to be built as a plugin that's loaded by the linker.
27
28- LLD/Mach-O supports "LLVM-y" features that the ELF and COFF LLDs support as
Nico Weber413f1222020-12-22 17:58:3029 well, such as thin archives, colored diagnostics, and response files
30 (ld64 supports this too as of Xcode 12, but we had to wait many years for it,
31 and it's currently [too crashy](https://crbug.com/1147968) to be usable).
Nico Weber22d0d662020-12-07 23:35:0632
Nico Weber588d3d532021-07-09 11:22:4333- While LLD for ELF, LLD for COFF, and LLD for MachO are mostly independent
34 codebases, they all use LLVM libraries. That gives them similar behavior.
35 Using LLD unifies the build across platforms somewhat.
Nico Weber22d0d662020-12-07 23:35:0636
Nico Weber9710c122021-10-05 22:50:5437For that reason, we moved to LLD for iOS and macOS builds.
Nico Weber22d0d662020-12-07 23:35:0638
39Just like the LLD ELF port tries to be commandline-compatible with other ELF
40linkers and the LLD COFF port tries to be commandline-compatible with the
41Visual Studio linker link.exe, the LLD Mach-O port tries to be
42commandline-compatible with ld64. This means LLD accepts different flags on
43different platforms.
44
Nico Weber44c615f2021-01-05 20:22:3645## Current status and known issues
Nico Weber22d0d662020-12-07 23:35:0646
Nico Weber9d31eda2023-06-05 17:54:0647LLD is used by default in all build configurations.
48All tests on all bots are passing, both Intel and Arm.
49Most things even work.
Nico Weber22d0d662020-12-07 23:35:0650
Nico Weber588d3d532021-07-09 11:22:4351## Hacking on LLD
Nico Weber22d0d662020-12-07 23:35:0652
Johann48fbca92021-07-16 18:29:4153If you want to work on LLD, follow [this paragraph](clang.md#Using-a-custom-clang-binary).
Nico Weber22d0d662020-12-07 23:35:0654
Nico Weber44c615f2021-01-05 20:22:3655## Creating stand-alone repros for bugs
56
57For simple cases, LLD's `--reproduce=foo.tar` flag / `LLD_REPRODUCE=foo.tar`
58env var is sufficient.
59
60See "Note to self:" [here](https://bugs.llvm.org/show_bug.cgi?id=48657#c0) for
Johann48fbca92021-07-16 18:29:4161making a repro file that involved the full app and framework bundles.