1

I've been trying to make the switch to LLVM, since I'd like to get more into the whole 'software-dev' scene, and it seems like right now, LLVM is the future. I built LLVM/Clang/LLD/compiler-rt/libcxx from source several times now, both with GNU/GCC and LLVM/Clang.

The problem appears when I try to use the newly compiled compilers. From what I can see, clang is using GNU ld rather than LLVM's lld. Is this true?

LLD seems to be a very limited program from the lld -help output, but from what I have read, it is as full featured as ld. I cannot find documentation on how to use it anywhere -- does anyone know where I can find some kind of comprehensive manual on it?

Thank you.

PyroAVR
  • 719
  • 1
  • 8
  • 19
  • What makes you think that ld is being used? Do you have some error messages or traces that you could add here? – Paul Floyd Jul 13 '17 at 12:55
  • Well, this was quite some time ago, but it was at that time in the documentation for clang that gnu ld was in use as the default linker due to limitations of lld at the time. I haven't revisited this in some time, but I do recall attempting to link objects using lld and having them not work. – PyroAVR Jul 14 '17 at 00:02

4 Answers4

4

Pass -fuse-ld=lld to clang to make it use lld for linking. By now, it's in very good shape.

You can pass -v or -### to clang to make it print which linker command it runs or would run.

thakis
  • 5,405
  • 1
  • 33
  • 33
0

There's no manual for the moment and depending on platform may work well enough for you. That said, if lld were "production ready" we'd have switched clang to using it by default for the various platforms. It's not there yet so I wouldn't suggest you use it for your day to day development.

echristo
  • 1,687
  • 10
  • 8
0

The LLVM team say that is production ready because FreeBSD can compile and link a lot of things with LLD.

The documentation on the LLD project can be found on http://lld.llvm.org/.

It's written :

LLD is a drop-in replacement for the GNU linkers.

That accepts the same command line arguments and linker scripts as GNU.

So you can use same arguments than GNU LD.

lvjp
  • 108
  • 8
0

I know this question is old, but there is a newer solution to it:

To use the ld.lld linker when building any llvm target, just pass -DLLVM_ENABLE_LLD=ON in the commandline to cmake.

//Use lld as C and C++ linker.
LLVM_ENABLE_LLD:BOOL=TRUE

For other cmake projects, pass: -DCMAKE_LINKER=/etc/bin/ld.lld

Fabian Keßler
  • 563
  • 3
  • 12