diff --git a/lld/docs/MachO/index.rst b/lld/docs/MachO/index.rst --- a/lld/docs/MachO/index.rst +++ b/lld/docs/MachO/index.rst @@ -13,7 +13,8 @@ same command line arguments. - LLD is very fast. When you link a large program on a multicore - machine, you can expect that LLD runs more than twice as fast as the ld64 linker. + machine, you can expect that LLD runs more than twice as fast as the ld64 + linker. Download -------- @@ -29,7 +30,7 @@ The easiest way to build LLD is to check out the entire LLVM projects/sub-projects from a git mirror and -build that tree. You need `cmake` and of course a C++ compiler. +build that tree. You need ``cmake`` and of course a C++ compiler. .. code-block:: console @@ -49,13 +50,16 @@ LLD can be used by adding ``-fuse-ld=/path/to/ld64.lld`` to the linker flags. For Xcode, this can be done by adding it to "Other linker flags" in the build settings. For Bazel, this can be done with ``--linkopt`` or with -[rules_apple_linker](https://github.com/keith/rules_apple_linker). +`rules_apple_linker `_. The user may also need to add ``-Wl,--deduplicate-literals`` in order to match Apple's linker behavior more closely (otherwise problems -can occur, for instance, in unit tests). For more info on -the differences between the two, see "LD64 vs LLD-MACHO", mentioned below. +can occur, for instance, in unit tests). + +.. seealso:: + + :doc:`ld64-vs-lld` has more info on the differences between the two linkers. .. toctree:: - :maxdepth: 1 + :hidden: ld64-vs-lld diff --git a/lld/docs/MachO/ld64-vs-lld.rst b/lld/docs/MachO/ld64-vs-lld.rst --- a/lld/docs/MachO/ld64-vs-lld.rst +++ b/lld/docs/MachO/ld64-vs-lld.rst @@ -1,37 +1,39 @@ -================== -LD64 vs LLD-MACHO -================== +================= +ld64 vs LLD-MachO +================= -This doc lists all significant deliberate differences in behavior between LD64 and LLD-MachO. +This doc lists all significant deliberate differences in behavior between ld64 +and LLD-MachO. String Literal Deduplication **************************** -LD64 always deduplicates string literals. LLD only does it when the ``--icf=`` +ld64 always deduplicates string literals. LLD only does it when the ``--icf=`` or the ``--deduplicate-literals`` flag is passed. Omitting deduplication by default ensures that our link is as fast as possible. However, it may also break some programs which have (incorrectly) relied on string deduplication always occurring. In particular, programs which compare string literals via pointer equality must be fixed to use value equality instead. -String Alignment -**************** -LLD is slightly less conservative about aligning cstrings, allowing it to pack -them more compactly. This should not result in any meaningful semantic -difference. - ``-no_deduplicate`` Flag ************************ -- LD64: - * This turns off ICF (deduplication pass) in the linker. -- LLD - * This turns off ICF and string merging in the linker. +- ld64: This turns off ICF (deduplication pass) in the linker. +- LLD: This turns off ICF and string merging in the linker. + +String Alignment +**************** +LLD is `slightly less conservative about aligning cstrings +`_, allowing it to pack them more compactly. +This should not result in any meaningful semantic difference. ObjC Symbols Treatment ********************** -There are differences in how LLD and LD64 handle ObjC symbols loaded from archives. +There are differences in how LLD and ld64 handle ObjC symbols loaded from +archives. -- LD64: - * Duplicate ObjC symbols from the same archives will not raise an error. LD64 will pick the first one. - * Duplicate ObjC symbols from different archives will raise a "duplicate symbol" error. -- LLD: - * Duplicate symbols, regardless of which archives they are from, will raise errors. +- ld64: + 1. Duplicate ObjC symbols from the same archives will not raise an error. + ld64 will pick the first one. + 2. Duplicate ObjC symbols from different archives will raise a "duplicate + symbol" error. +- LLD: Duplicate symbols, regardless of which archives they are from, will + raise errors.