[llvm-dev] [cfe-dev] LLD to be the default linker in Clang (original) (raw)
Davide Italiano via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 31 11:23:04 PDT 2016
- Previous message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Next message: [llvm-dev] RFC: Removing the DataStreamer and MemoryObject interfaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Oct 29, 2016 at 5:43 PM, Sean Silva via llvm-dev <llvm-dev at lists.llvm.org> wrote:
On Fri, Oct 28, 2016 at 9:17 AM, Renato Golin via cfe-dev <cfe-dev at lists.llvm.org> wrote:
Folks, I'm creating a bootstrap buildbot on AArch64 with LLD and I just realised the "accepted" way to make clang call lld is to "symlink lld -> ld". I understand that's how every Linux system "chooses" the linker, but that makes deployment and validation quite cumbersome on GNU systems. I'd like to suggest a change in behaviour: // Some flag like --linker=<full path / bin on path> if (LinkerFlag) { linker = Flag (linker); // triple != host } else if (CROSSCOMPILE) { if (LLDSupports(triple)) linker = Find (LLD); if (!linker) linker = Find (triple-ld); if (!linker) ERROR; // NOT the system linker! // triple = host } else { linker = Find (LLD); if (!linker) linker = Find (SYSLD); // OS-specific if (!linker) ERROR; // We tried! }
Rationale My reason is that, if you just build Clang, with or without LLD, everything works out of the box as you expect: Former uses LLD, latter uses the system's linker. If LLD is able to cross-compile to the target triple, and it's available, try that. Cross compilers should never use the system linker, as that's just silly. However, if you didn't build Clang or LLD and still want to force the linker (cross when clang gets it wrong, lld installed somewhere else, some non-sysroot alternative, ld when you have built lld), you'll need a flag. It doesn't really matter if GCC will ever use LLD, but it would be good to have Clang be able to specify which linker to use. We already have library flags, and we don't need an assembler flag, so the linker seems like the last option missing. Use Case For example, it's perfectly reasonable to have GCC and Clang on the same system and to have LD and LLD installed / accessible. It's also perfectly reasonable to have GCC using LD and Clang using LLD on the same system. Today, that's not possible without changing the path for Clang and not GCC (cumbersome, to say the least). The environment above is exactly that of any buildbot trying to bootstrap Clang+LLD using GCC+LD. Iwant to have at least one for AArch64 and one for ARM, but it would be good to have the same thing for x8664, too at the very least. I don't know much about FreeBSD, but they're moving LLD as the official linker in multiple platforms and they still have GCC/LD in ports. There will probably be corner cases... Conclusion I think LLD is mature enough to be preferred over LD on the platforms it support, if available. Has anyone done a Debian or Gentoo stress test? If that hasn't been done, I expect there to be a long tail of bugs that it would be good to squash a significant part of before risking exposing our users to them. Also, what is the current status of FreeBSD Poudriere? (Ed, Davide?)
Last I tried to build all the FreeBSD package port collection (~25k packages ranging from glib to gnome etc..) about 50% of them were linked successfully, about 10% were failing and the rest were skipped because dependent on something not linked correctly. This was at the end of may, back then we didn't have linker scripts and version scripts support, so, a bunch failures were due to missing features. I think we're in good shape to try another run, I'll try to do it this week (hopefully before the devsummit). Once we get results, that should give us another view of the maturity of lld as a project. Also, FWIW, Gentoo had a (successfully) completed project to build using clang/llvm, and in my single interaction with the student he said he tried lld but encountered some issues. I think it's worth a shot. Similarly, when I spoke with Saleem, he mentioned that something similar can be done on Exherbo. As a final note, something not very visible (for obvious reasons), we link PS4 codebase(s) internally and we consider lld stable enough for our purposes.
About the gcc patch to get -fuse-ld=lld to work I submitted , I think
that could be re-worked to make -fuse-ld a generic facility as it is
in llvm (i.e. you can pass an arbitrary absolute paths to
/my/shiny/linker), instead of hardcoding and matching on =ld.bfd and
=ld.gold as it's currently done. That should leave aside all the
non-technical concerns.
-- Davide
- Previous message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Next message: [llvm-dev] RFC: Removing the DataStreamer and MemoryObject interfaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]