This is an archive of the discontinued LLVM Phabricator instance.

[clang][PowerPC] Set lld as clang's default linker for PowerPC Linux
Needs ReviewPublic

Authored by quinnp on Jul 15 2022, 7:11 AM.

Details

Reviewers
nemanjai
kamaub
lei
Group Reviewers
Restricted Project
Summary

This patch changes the default linker for clang on PowerPC Linux to lld.
Here is a summary of the expected behaviour before and after this patch:

To use lld as the linker before this patch:

  • build with lld in LLVM_ENABLE_PROJECTS
  • build with -DCLANG_DEFAULT_LINKER=lld

To use lld as the linker after this patch:

  • build with lld in LLVM_ENABLE_PROJECTS

To use ld as the linker before this patch:

  • default behaviour

To use ld as the linker after this patch:

  • build with -DCLANG_DEFAULT_LINKER=<PATH_TO_LD>

Note: After this patch, if you build clang for PowerPC Linux and lld is not
included in LLVM_ENABLE_PROJECTS, the built compiler will report an error
during linking because it will not be able to find ld.lld. Therefore, anyone
using the default behaviour before this patch will need to modify their build
configuration to either:

  • include -DCLANG_DEFAULT_LINKER=<PATH_TO_LD> to continue using ld or
  • include lld in LLVM_ENABLE_PROJECTS to switch to lld.

Diff Detail

Event Timeline

quinnp created this revision.Jul 15 2022, 7:11 AM
quinnp requested review of this revision.Jul 15 2022, 7:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2022, 7:11 AM
quinnp added reviewers: nemanjai, kamaub, lei, Restricted Project.Jul 15 2022, 7:12 AM
quinnp edited the summary of this revision. (Show Details)Jul 15 2022, 7:16 AM
quinnp edited the summary of this revision. (Show Details)
MaskRay added a comment.EditedJul 16 2022, 12:22 AM

This is not right as using ld.lld as the default linker isn't the majority case. If you want to change the default for your distribution, set -DCLANG_DEFAULT_LINKER=lld.
(Alternatively, you can have a ld symlink pointing to lld.)

This is not right as using ld.lld as the default linker isn't the majority case. If you want to change the default for your distribution, set -DCLANG_DEFAULT_LINKER=lld.
(Alternatively, you can have a ld symlink pointing to lld.)

Hi @MaskRay! Do you mean I should abandon this change or find a way to set the CMake variable CLANG_DEFAULT_LINKER to lld as default when building for PowerPC Linux? I wasn't able to find any examples of people setting CMake variables for specific distributions.

Thanks!

This is not right as using ld.lld as the default linker isn't the majority case. If you want to change the default for your distribution, set -DCLANG_DEFAULT_LINKER=lld.
(Alternatively, you can have a ld symlink pointing to lld.)

Hi @MaskRay! Do you mean I should abandon this change or find a way to set the CMake variable CLANG_DEFAULT_LINKER to lld as default when building for PowerPC Linux? I wasn't able to find any examples of people setting CMake variables for specific distributions.

Thanks!

You can customize CLANG_DEFAULT_LINKER in your clang distribution. I don't find convincing argument to change the default for PPCLinuxToolChain and diverge from Linux.

This is not right as using ld.lld as the default linker isn't the majority case. If you want to change the default for your distribution, set -DCLANG_DEFAULT_LINKER=lld.
(Alternatively, you can have a ld symlink pointing to lld.)

Hi @MaskRay! Do you mean I should abandon this change or find a way to set the CMake variable CLANG_DEFAULT_LINKER to lld as default when building for PowerPC Linux? I wasn't able to find any examples of people setting CMake variables for specific distributions.

Thanks!

You can customize CLANG_DEFAULT_LINKER in your clang distribution. I don't find convincing argument to change the default for PPCLinuxToolChain and diverge from Linux.

The reason we would like the default linker to be ld.lld for most/default builds on PPC is because using LTO without the GPL-licensed Gold plugin requires LLD. The idea is that a typical user can pull the source and build it with minimal CMake macros and get a working LTO without having to build the Gold plugin.

Of course, this may not be the way to accomplish this (i.e. this will make it diverge from the value specified in CLANG_DEFAULT_LINKER in $LLVM_BUILD/tools/clang/include/clang/Config/config.h). So I would prefer that we handle this in the CMake files if @MaskRay doesn't object.

Hi @MaskRay, could you please take a look at @nemanjai's suggestion?

...
So I would prefer that we handle this in the CMake files if @MaskRay doesn't object.

Thanks!