[llvm-dev] [cfe-dev] LLD to be the default linker in Clang (original) (raw)
Peter Smith via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 30 01:40:35 PDT 2016
- Previous message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Next message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Renato,
Thanks very much for raising the topic. I've not got much to add to what has already been said.
If I understand correctly there are two use cases that we would want to consider separately:
- Using lld by default when clang is used on a platform such as linux if it is installed.
- Using lld by default in build-bots and the llvm test-suite when it is installed.
For the former, personally I think that clang should follow the conventions of the platform wherever possible, i.e. on Linux ld is a symlink to ld.XXX which may be ld.lld. I agree with Sean that some documentation on how to set up and use lld would be very helpful and would be a relatively cheap first step. Some status information about how complete each target is would also be useful.
For the latter, I think it would at first be good to have a simple option, or document options that would use lld. When all targets that have an lld port can reliably run in the build and test environment we can consider making it the default if it has been intentionally installed. I don't have a strong opinion on how to set this up.
Peter
On 30 October 2016 at 01:43, Sean Silva <chisophugis at gmail.com> 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?) The magic of open source package systems means we can do a large amount of the bug finding where we might otherwise rely on users; we should take maximum advantage of that since it is not only easier than getting user bug reports, but also helps avoid giving users a bad experience.
Since it's not available by default in most of them, its existence means intention. But what is their intention? To suddenly use LLD for all their builds that use Clang? Maybe they have a particular project that happens to have an annoyingly long final link, and they are only interested in using LLD for just that project. This same data point ("existence means intention") could be used to justify that the user is already intending to use LLD, so they will just manually add
-fuse-ld=lldto their link command lines. The suggested change, when viewed through the assumption that LLD's "existence means intention", is really just meant to save the user from adding-fuse-ld=lldto their LDFLAGS; and it does so in an arguably somewhat uncontrolled fashion (e.g. installing an LLD package can cause Clang to change linker in the middle of an already-running build; or in an already-generated Ninja build dir for a CMake project). In the same vein as Richard's comment, we don't do that for e.g. libc++. Realistically, I think that the best course of action for getting more people using LLD/ELF right now is: 1. make getting LLD as easy as possible (e.g. make sure it is available in the main Linux package repos) 2. write a documentation page "how to try out LLD/ELF" that centralizes various pieces of information, such as how to get LLD/ELF, the use of -fuse-ld=lld, how to report bugs (e.g. explaining the use of --reproduce), etc. Once it becomes available, having it means you should really use it. Looks like a no-brainer to me. Am I missing something? We currently have both the FreeBSD and the PlayStation effort underway for making LLD/ELF a default production system linker. IMO, we should wait for at least one of those efforts to stabilize before contemplating "flipping the switch" globally in the way you described. Also, ideally we'll be happy with the results of some sort of Linux-specific testing such as building Debian or Gentoo. -- Sean Silvacheers, --renato
cfe-dev mailing list cfe-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
- Previous message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Next message: [llvm-dev] [cfe-dev] LLD to be the default linker in Clang
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]