what's the name of ubuntu package contains llvm linker lld

8,488

Solution 1

Since January 2017, the LLVM apt repository includes lld, as do the snapshot packages available in Debian (starting with 4.0 in unstable, 5.0 in experimental). Since version 5, lld packages are available in Debian (lld-5.0 in stretch-backports, lld-6.0 in stretch-backports and Debian 10, lld-7 in Debian 9 and 10, lld-8 in buster-backports, and later packages in releases currently in preparation).

To install the upstream packages on Debian or Ubuntu, follow the instructions for your distribution.

Back in February 2015 when this answer was originally written, the LLVM apt repository stated that it included LLVM, Clang, compiler-rt, polly and LLDB. lld wasn't included. Even the latest snapshot packages in Debian (which are maintained by the same team as the LLVM packages) didn't include lld.

Solution 2

By the sounds of it, lld has not matched the maturity of Clang/LLVM yet, so it isn't included in the main packages.

There is some confusion around the linkers in LLVM (I was quite confused myself). The rest of this answer (while not directly answering the original question) helps clear up the confusion to define what it is we are talking about! There are three that could be called linkers:

  1. llvm-ld - this sounds like it was both a linker for LLVM bitfiles and executable binary object files. However, the answer here (and provided links) suggest that lld was removed back in LLVM 3.2. At that point, there was no substitute linker, and the system ld linker would have to be used.
  2. llvm-link - this is the current linker for LLVM bitfiles.
  3. lld - this sounds like an actively developed replacement for ld that only links executable binary object files. This answer here suggests it was in active development in May 2014. It is listed in the main LLVM list of projects as #13. I'm guessing it can only get better over time, and mature to a point where it is viable to include in the main LLVM package as a replacement for GNU ld / gold.
Share:
8,488

Related videos on Youtube

Albert Netymk
Author by

Albert Netymk

Updated on September 18, 2022

Comments

  • Albert Netymk
    Albert Netymk over 1 year

    Would like to try this lld from LLVM. The doc on apt could be found here, but I don't know which package contains the lld executable.

    It seems the purpose of lld is to remove the system dependency, but clang doesn't have lld built-in. (Not yet?)

    Using the following example to test if lld is used. GNU-ld places some constraint on the order of archive files appear, but lld seems to be more tolerate on this (if I understand it correctly), so this example should build successfully, if lld is used. However, it fails on my box.

    # one.c
    extern int two();
    int main(int argc, char *argv[])
    {
        two();
        return 0;
    }
    
    # two.c
    void two(){}
    
    $ clang -c two.c; ar cr two.a two.o ; clang -c one.c ; clang two.a one.o
    one.o: In function `main':
    one.c:(.text+0x19): undefined reference to `two'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    If we use -v:

    $ clang -c two.c; ar cr two.a two.o ; clang -c one.c ; clang -v two.a one.o
    Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
    Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.0
    Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
    Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.2
    Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
    Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.0
    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.0
    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
    Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
     "/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/lib -L/usr/lib two.a one.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
    one.o: In function `main':
    one.c:(.text+0x19): undefined reference to `two'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    ENV

    Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4) Target: x86_64-pc-linux-gnu Thread model: posix

  • Albert Netymk
    Albert Netymk almost 9 years
    Thanks for the link. However, I get the feeling that llvm-ld, which has been superseded by llvm-link, is different from lld. The former is bitcode linker, but the later works on object files (.o and .a).
  • Albert Netymk
    Albert Netymk almost 9 years
    Quoting from their home page: lld "Reads standard Object Files (e.g. ELF, Mach-O, PE/COFF)" and "Writes standard Executable Files (e.g. ELF, Mach-O, PE)", while llvm-link " takes several LLVM bitcode files and links them together into a single LLVM bitcode file". Therefore, the two don't work on the same level. Possibly lld invokes llvm-link behind the sence.
  • Jetski S-type
    Jetski S-type almost 9 years
    This is a bit confusing to have three linkers in LLVM, and it's not easy to see what's what, except that llvm-link is current and for LLVM bitcode. llvm-ld sounds like a mix of llvm-link and lld (system linker), as I said before. We also know that in Nov 2012, there was no system linker in LLVM: stackoverflow.com/questions/13528474/… (it uses the word 'yet'). I wonder when lld came along. LLVM documentation could be improved to help clear up such confusions!
  • Jetski S-type
    Jetski S-type almost 9 years
    lld looks like an actively developed project, so it is likely to have arisen after llvm-ld got removed. This answer from May 2014 uses future tense to imply future development for lld: stackoverflow.com/questions/23657132/…
  • Jetski S-type
    Jetski S-type almost 9 years
    Additionally, this comment from ~Sept 2012 says the lld was relatively young back then: news.ycombinator.com/item?id=4454215