Re: [RFC PATCH 1/2] kbuild: add CONFIG_LD_IS_BINUTILS

From: Fangrui Song
Date: Fri Apr 24 2020 - 01:18:42 EST


On 2020-04-24, Masahiro Yamada wrote:
On Fri, Apr 24, 2020 at 3:44 AM Nick Desaulniers
<ndesaulniers@xxxxxxxxxx> wrote:

On Sun, Apr 19, 2020 at 6:19 AM Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>
> This patch is currently not mandatory but a prerequisites for the second one.
>
> Folks from ClangBuiltLinux project like the combination of Clang compiler
> and LLD linker from LLVM project to build their Linux kernels.
>
> Sami Tolvanen <samitolvanen@xxxxxxxxxx> has a patch for using LD_IS_LLD (see [1]).
>
> Documentation/process/changes.rst says and uses "binutils" that's why I called
> it LD_IS_BINUTILS (see [2] and [3]).
>
> The second patch will rename existing LD_VERSION to BINUTILS_VERSION to have
> a consistent naming convention like:
>
> 1. CC_IS_GCC and GCC_VERSION
> 2. CC_IS_CLANG and CLANG_VERSION
> 3. LD_IS_BINUTILS and BINUTILS_VERSION
>
> [1] https://github.com/samitolvanen/linux/commit/61889e01f0ed4f07a9d631f163bba6c6637bfa46
> [2] https://git.kernel.org/linus/tree/Documentation/process/changes.rst#n34
> [3] https://git.kernel.org/linus/tree/Documentation/process/changes.rst#n76
>
> Signed-off-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>

Just some background on Sami's patch. Originally we were using
ld.gold (for LTO for Pixel 3) before moving to ld.lld (for LTO for
Pixel 4 and later). Not sure if Kconfig would be a better place to
check if gold is used, then warn? I kind of prefer the distinction
that binutils contains two different linkers, though if no one is
supporting ld.gold, and it doesn't work for the kernel, then maybe
that preference is moot?


I prefer LD_IS_BFD, like this patch:
https://lore.kernel.org/patchwork/patch/1039719/

We do not need LD_IS_GOLD, though.

--
Best Regards
Masahiro Yamada

+1 for CONFIG_LD_IS_BFD

Usually GNU ld is also installed as ld.bfd and can be referred to by -fuse-ld=bfd (GCC >= 9, or clang)

The repository binutils-gdb includes two linkers: GNU ld and GNU gold, so CONFIG_LD_IS_BINUTILS would be ambiguous.