Re: [PATCH] kbuild: distributed build support for Clang ThinLTO

From: Nathan Chancellor
Date: Wed Apr 30 2025 - 21:20:33 EST


Hi Rong,

On Tue, Apr 29, 2025 at 01:34:00PM -0700, Rong Xu wrote:
> Just wanted to gently follow up on this patch that I sent previously.
>
> From a toolchain and compiler perspective, I genuinely believe that
> kernel ThinLTO builds should use this. I really want to get some feedback
> and reviews on this patch.

My apologies for some radio silence, other regressions and issues have
been higher priority until now. I will try to take a closer look at this
soon but I do have one comment based on your comment above and the
Kconfig help text...

> On Sat, Apr 19, 2025 at 6:02 PM <xur@xxxxxxxxxx> wrote:
...
> > diff --git a/arch/Kconfig b/arch/Kconfig
> > index b0adb665041f1..cbeeeb9b076d8 100644
> > --- a/arch/Kconfig
> > +++ b/arch/Kconfig
> > @@ -810,6 +810,18 @@ config LTO_CLANG_THIN
> > https://clang.llvm.org/docs/ThinLTO.html
> >
> > If unsure, say Y.
> > +
> > +config LTO_CLANG_THIN_DIST
> > + bool "Clang ThinLTO in distributed mode (EXPERIMENTAL)"
> > + depends on HAS_LTO_CLANG && ARCH_SUPPORTS_LTO_CLANG_THIN
> > + select LTO_CLANG
> > + help
> > + This option enables Clang's ThinLTO in distributed build mode.
> > + In this mode, the linker performs the thin-link, generating
> > + ThinLTO index files. Subsequently, the build system explicitly
> > + invokes ThinLTO backend compilation using these index files
> > + and pre-linked IR objects. The resulting final object files
> > + are with the .final_o suffix.
> > endchoice

This says what the option does but it does not really say why the user
would want to use this over CONFIG_LTO_CLANG_THIN_DIST; even as someone
relatively familiar with these technologies, I am not sure what this
means for the build or resulting kernel. Is there any reason why a user
would want to use in-process ThinLTO instead of distributed? You seem to
make the case above and in Discourse that the kernel would benefit from
this, so should we just wholesale replace in-process ThinLTO with the
distributed one?

Cheers,
Nathan