/ Comments off

Also, as soon as Bug 1 is fixed, it will be necessary to check if Bug 2 is not reproduced with CMAKEINSTALLPREFIX (note: with standard way, without any customization, CMAKEINSTALLPREFIX is correctly processed by CMake). CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.

LLD is a linker from the LLVM project that is a drop-in replacementfor system linkers and runs much faster than them. It also providesfeatures that are useful for toolchain developers.

The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS) andWebAssembly in descending order of completeness. Internally, LLD consists ofseveral different linkers. The ELF port is the one that will be described inthis document. The PE/COFF port is complete, includingWindows debug info (PDB) support. The WebAssembly port is still a work inprogress (See WebAssembly lld port). The Mach-O port is built based on adifferent architecture than the others. For the details about Mach-O, pleaseread ATOM-based lld.

  1. It may be useful to add cmake flag -DCMAKEINSTALLPREFIX= and pip3 flag -user or -prefix= to install to a user location. See detailed instructions for DOLFIN and mshr. Update DOLFIN documentation for latest release, including updates for building Python interface with pybind11, and provide a link to documentation of.
  2. CMAKEINSTALLPREFIX: Specifies the install directory to target when running the install action of the build files. LLVMTARGETSTOBUILD: A semicolon delimited list controlling which targets will be built and linked into llvm. The default list is defined as LLVMALLTARGETS, and can be set to.
  3. In Visual Studio 2019 and later, you can add configurations and customize their settings by using the CMake settings editor.The editor is intended to be a simpler alternative to manually editing the CMakeSettings.json file, but if you prefer to edit the file directly, you can click the Edit JSON link in the upper right of the editor. To open the editor, click on the Configuration drop-down in.


  • LLD is a drop-in replacement for the GNU linkers that accepts thesame command line arguments and linker scripts as GNU.

    We are currently working closely with the FreeBSD project to makeLLD default system linker in future versions of the operatingsystem, so we are serious about addressing compatibility issues. Asof February 2017, LLD is able to link the entire FreeBSD/amd64 basesystem including the kernel. With a few work-in-progress patches itcan link approximately 95% of the ports collection on AMD64. For thedetails, see FreeBSD quarterly status report.

  • LLD is very fast. When you link a large program on a multicoremachine, you can expect that LLD runs more than twice as fast as the GNUgold linker. Your mileage may vary, though.

  • It supports various CPUs/ABIs including AArch64, AMDGPU, ARM, Hexagon, MIPS32/64 big/little-endian, PowerPC, PowerPC64, RISC-V, SPARC V9, x86-32 andx86-64. Among these, AArch64, ARM (>= v6), PowerPC, PowerPC64, x86-32 andx86-64 have production quality. MIPS seems decent too.

  • It is always a cross-linker, meaning that it always supports all theabove targets however it was built. In fact, we don’t provide abuild-time option to enable/disable each target. This should make iteasy to use our linker as part of a cross-compile toolchain.

  • You can embed LLD in your program to eliminate dependencies onexternal linkers. All you have to do is to construct object filesand command line arguments just like you would do to invoke anexternal linker and then call the linker’s main function,lld::elf::linkAdobe audition non destructive editing free. , from your code.

  • It is small. We are using LLVM libObject library to read from objectfiles, so it is not a completely fair comparison, but as of February2017, LLD/ELF consists only of 21k lines of C++ code while GNU goldconsists of 198k lines of C++ code.

  • Link-time optimization (LTO) is supported by default. Essentially,all you have to do to do LTO is to pass the -flto option to clang.Then clang creates object files not in the native object file formatbut in LLVM bitcode format. LLD reads bitcode object files, compilethem using LLVM and emit an output file. Because in this way LLD cansee the entire program, it can do the whole program optimization.

  • Some very old features for ancient Unix systems (pre-90s or evenbefore that) have been removed. Some default settings have beentuned for the 21st century. For example, the stack is marked asnon-executable by default to tighten security.


This is a link time comparison on a 2-socket 20-core 40-thread XeonE5-2680 2.80 GHz machine with an SSD drive. We ran gold and lld withor without multi-threading support. To disable multi-threading, weadded -no-threads to the command lines.

ProgramOutput sizeGNU ldGNU gold w/o threadsGNU gold w/threadslld w/o threadslld w/threads
ffmpeg dbg92 MiB1.72s1.16s1.01s0.60s0.35s
mysqld dbg154 MiB8.50s2.96s2.68s1.06s0.68s
clang dbg1.67 GiB104.03s34.18s23.49s14.82s5.28s
chromium dbg1.14 GiB209.05s [1]64.70s60.82s27.60s16.70s

As you can see, lld is significantly faster than GNU linkers.Note that this is just a benchmark result of our environment.Depending on number of available cores, available amount of memory ordisk latency/throughput, your results may vary.

Cmake Install Command

[1]Since GNU ld doesn’t support the -icf=all and-gdb-index options, we removed them from the command linefor GNU ld. GNU ld would have been slower than this if it hadthese options.

Cmake_install_prefix Opencv


If you have already checked out LLVM using SVN, you can check out LLDunder tools directory just like you probably did for clang. For thedetails, see Getting Started with the LLVM System.

If you haven’t checked out LLVM, the easiest way to build LLD is tocheck out the entire LLVM projects/sub-projects from a git mirror andbuild that tree. You need cmake and of course a C++ compiler.

Using LLD¶

LLD is installed as ld.lld. On Unix, linkers are invoked bycompiler drivers, so you are not expected to use that commanddirectly. There are a few ways to tell compiler drivers to use ld.lldinstead of the default linker.

The easiest way to do that is to overwrite the default linker. Afterinstalling LLD to somewhere on your disk, you can create a symboliclink by doing ln-s/path/to/ld.lld/usr/bin/ld so that/usr/bin/ld is resolved to LLD.

If you don’t want to change the system setting, you can use clang’s-fuse-ld option. In this way, you want to set -fuse-ld=lld toLDFLAGS when building your programs.

LLD leaves its name and version number to a .comment section in anoutput. If you are in doubt whether you are successfully using LLD ornot, run readelf--string-dump.comment<output-file> and examine theoutput. If the string “Linker: LLD” is included in the output, you areusing LLD.


Here is a brief project history of the ELF and COFF ports.

  • May 2015: We decided to rewrite the COFF linker and did that.Noticed that the new linker is much faster than the MSVC linker.
  • July 2015: The new ELF port was developed based on the COFF linkerarchitecture.
  • September 2015: The first patches to support MIPS and AArch64 landed.
  • October 2015: Succeeded to self-host the ELF port. We have noticedthat the linker was faster than the GNU linkers, but we weren’t sureat the time if we would be able to keep the gap as we would add morefeatures to the linker.
  • July 2016: Started working on improving the linker script support.
  • December 2016: Succeeded to build the entire FreeBSD base systemincluding the kernel. We had widen the performance gap against theGNU linkers.

Cmake_install_prefix Windows



For the internals of the linker, please read The ELF, COFF and Wasm Linkers. It is a bitoutdated but the fundamental concepts remain valid. We’ll update thedocument soon.