Files
clang-p2996/lld/docs/MachO/index.rst
Keith Smiley 2e5989e814 [lld-macho] Flip string deduplication default
Previously by default, when not using `--ifc=`, lld would not
deduplicate string literals. This reveals reliance on undefined behavior
where string literal addresses are compared instead of using string
equality checks. While ideally you would be able to easily identify and
eliminate the reliance on this UB, this can be difficult, especially for
third party code, and increases the friction and risk of users migrating
to lld. This flips the default to deduplicate strings unless
`--no-deduplicate-strings` is passed, matching ld64's behavior.

Differential Revision: https://reviews.llvm.org/D140517
2022-12-22 15:52:46 -08:00

63 lines
2.1 KiB
ReStructuredText

Mach-O LLD Port
===============
LLD is a linker from the LLVM project that is a drop-in replacement
for system linkers and runs much faster than them. It also provides
features that are useful for toolchain developers. This document
will describe the Mach-O port.
Features
--------
- LLD is a drop-in replacement for Apple's Mach-O linker, ld64, that accepts the
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.
Download
--------
LLD is available as a pre-built binary by going to the `latest release <https://github.com/llvm/llvm-project/releases>`_,
downloading the appropriate bundle (``clang+llvm-<version>-<your architecture>-<your platform>.tar.xz``),
decompressing it, and locating the binary at ``bin/ld64.lld``. Note
that if ``ld64.lld`` is moved out of ``bin``, it must still be accompanied
by its sibling file ``lld``, as ``ld64.lld`` is technically a symlink to ``lld``.
Build
-----
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.
.. code-block:: console
$ git clone https://github.com/llvm/llvm-project llvm-project
$ mkdir build
$ cd build
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='lld' ../llvm-project/llvm
$ ninja check-lld-macho
Then you can find output binary at ``build/bin/ld64.lld``. Note
that if ``ld64.lld`` is moved out of ``bin``, it must still be accompanied
by its sibling file ``lld``, as ``ld64.lld`` is technically a symlink to ``lld``.
Using LLD
---------
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>`_.
.. seealso::
:doc:`ld64-vs-lld` has more info on the differences between the two linkers.
.. toctree::
:hidden:
ld64-vs-lld