diff --git a/a.sh b/a.sh new file mode 100644 --- /dev/null +++ b/a.sh @@ -0,0 +1,21 @@ +rm -r build +mkdir build +cd build + +cmake -G Ninja ../llvm -B . \ + -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;polly;flang" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_SPHINX=ON \ + -DLLVM_BUILD_DOCS=ON \ + -DLLVM_DOXYGEN_SVG=ON \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF + +ninja -C . docs-lld-html + +cmake -G Ninja ../llvm/../runtimes -B ./runtimes-doc \ + -DLLVM_ENABLE_RUNTIMES="libcxx" \ + -DLLVM_ENABLE_SPHINX=ON \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF + +ninja -C ./runtimes-doc docs-libcxx-html + diff --git a/lld/docs/MachO/index.rst b/lld/docs/MachO/index.rst new file mode 100644 --- /dev/null +++ b/lld/docs/MachO/index.rst @@ -0,0 +1,55 @@ +LLD - The LLVM Linker +===================== + +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---.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 the output files ``build/bin/ld64.lld`` and ``build/bin/lld``. The two files +can be moved out of that directory, but must remain siblings. + +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). +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](some link). diff --git a/lld/MachO/ld64-vs-lld.rst b/lld/docs/MachO/ld64-vs-lld.rst rename from lld/MachO/ld64-vs-lld.rst rename to lld/docs/MachO/ld64-vs-lld.rst