[PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO

xur@google.com posted 2 patches 1 month, 2 weeks ago
.gitignore                 |  2 +
Makefile                   | 25 +++++-------
arch/Kconfig               | 19 +++++++++
scripts/Makefile.lib       |  7 ++++
scripts/Makefile.thinlto   | 40 ++++++++++++++++++
scripts/Makefile.vmlinux_a | 83 ++++++++++++++++++++++++++++++++++++++
scripts/mod/modpost.c      | 15 +++++--
7 files changed, 174 insertions(+), 17 deletions(-)
create mode 100644 scripts/Makefile.thinlto
create mode 100644 scripts/Makefile.vmlinux_a
[PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO
Posted by xur@google.com 1 month, 2 weeks ago
From: Rong Xu <xur@google.com>

ChangeLog:

V5: Handle single quote escaping in echo _c_flags to fix
    Piotr Gorski's reported error.

V4: This is based on the reimplementation provided by Masahiro Yamada
on May 26. The difference is that this version now saves the compiler
flags (_c_flags) from the Front-End (FE) compilation and re-uses them
for the subsequent Back-End (BE) compilation.
 
Rong Xu (2):
  kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
  kbuild: distributed build support for Clang ThinLTO

 .gitignore                 |  2 +
 Makefile                   | 25 +++++-------
 arch/Kconfig               | 19 +++++++++
 scripts/Makefile.lib       |  7 ++++
 scripts/Makefile.thinlto   | 40 ++++++++++++++++++
 scripts/Makefile.vmlinux_a | 83 ++++++++++++++++++++++++++++++++++++++
 scripts/mod/modpost.c      | 15 +++++--
 7 files changed, 174 insertions(+), 17 deletions(-)
 create mode 100644 scripts/Makefile.thinlto
 create mode 100644 scripts/Makefile.vmlinux_a


base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
-- 
2.51.1.851.g4ebd6896fd-goog
Re: [PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO
Posted by Nathan Chancellor 1 week, 2 days ago
Hi Rong,

On Tue, Oct 28, 2025 at 06:28:20PM +0000, xur@google.com wrote:

First of all, my apologies for taking so long to get to testing and
reviewing this patchset.

> Rong Xu (2):
>   kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
>   kbuild: distributed build support for Clang ThinLTO
> 
>  .gitignore                 |  2 +
>  Makefile                   | 25 +++++-------
>  arch/Kconfig               | 19 +++++++++
>  scripts/Makefile.lib       |  7 ++++
>  scripts/Makefile.thinlto   | 40 ++++++++++++++++++
>  scripts/Makefile.vmlinux_a | 83 ++++++++++++++++++++++++++++++++++++++
>  scripts/mod/modpost.c      | 15 +++++--
>  7 files changed, 174 insertions(+), 17 deletions(-)
>  create mode 100644 scripts/Makefile.thinlto
>  create mode 100644 scripts/Makefile.vmlinux_a

Overall, this seems reasonable from a high level perspective. I have
been testing it with my arm64 and x86_64 distribution configurations for
the past couple of days and I have not noticed any issues.

Did you take a look at the robot report from patch 2?

  https://lore.kernel.org/202511052257.Bb85ptQG-lkp@intel.com/

It seems like it could be caused by different optimizations?

I plan to take a more in-depth look at the implementation after I am
back home from Plumbers in a couple of weeks (just to make sure I
understand it from a maintainer's perspective). Based on that, I will
either apply it to kbuild-next for 6.20/7.0 or ask for further
interations, while still aiming to get it into that release.

Cheers,
Natha
Re: [PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO
Posted by Rong Xu 1 week, 2 days ago
Thanks Nathan for testing and reviewing the patch!

On Thu, Dec 4, 2025 at 9:50 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Rong,
>
> On Tue, Oct 28, 2025 at 06:28:20PM +0000, xur@google.com wrote:
>
> First of all, my apologies for taking so long to get to testing and
> reviewing this patchset.
>
> > Rong Xu (2):
> >   kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
> >   kbuild: distributed build support for Clang ThinLTO
> >
> >  .gitignore                 |  2 +
> >  Makefile                   | 25 +++++-------
> >  arch/Kconfig               | 19 +++++++++
> >  scripts/Makefile.lib       |  7 ++++
> >  scripts/Makefile.thinlto   | 40 ++++++++++++++++++
> >  scripts/Makefile.vmlinux_a | 83 ++++++++++++++++++++++++++++++++++++++
> >  scripts/mod/modpost.c      | 15 +++++--
> >  7 files changed, 174 insertions(+), 17 deletions(-)
> >  create mode 100644 scripts/Makefile.thinlto
> >  create mode 100644 scripts/Makefile.vmlinux_a
>
> Overall, this seems reasonable from a high level perspective. I have
> been testing it with my arm64 and x86_64 distribution configurations for
> the past couple of days and I have not noticed any issues.
>
> Did you take a look at the robot report from patch 2?
>
>   https://lore.kernel.org/202511052257.Bb85ptQG-lkp@intel.com/
>
> It seems like it could be caused by different optimizations?

I haven't tried to reproduce the issue in this report. However, based
on the warning messages, it looks fine to me: Distributed build mode
will have different optimizations from current in-process ThinLTO
build. This is mainly due to the fact that distributed build mode has
more precise option control. For a more detailed explanation, please
refer to my LLVM Discourse post:
https://discourse.llvm.org/t/rfc-distributed-thinlto-build-for-kernel/85934

Additionally, I will be presenting a talk on distributed ThinLTO
builds at the LPC next week and would be happy to discuss this topic
further with interested individuals in person.

Thanks,

-Rong

>
> I plan to take a more in-depth look at the implementation after I am
> back home from Plumbers in a couple of weeks (just to make sure I
> understand it from a maintainer's perspective). Based on that, I will
> either apply it to kbuild-next for 6.20/7.0 or ask for further
> interations, while still aiming to get it into that release.
>
> Cheers,
> Natha
Re: [PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO
Posted by Piotr Gorski 1 month, 2 weeks ago
Built and booted without any problems.

lucjan at cachyos ~ 20:19:27
❯ zgrep -i THIN_DIST /proc/config.gz
CONFIG_LTO_CLANG_THIN_DIST=y
lucjan at cachyos ~ 20:19:45
❯ cat /proc/version
Linux version 6.17.5-1.3-cachyos (linux-cachyos@cachyos) (clang version 
21.1.3, LLD 21.1.4) #1 SMP PREEMPT_DYNAMIC Tue, 28 Oct 2025 18:39:23 +0000

Thanks!

W dniu 28.10.2025 o 19:28, xur@google.com pisze:
> From: Rong Xu <xur@google.com>
>
> ChangeLog:
>
> V5: Handle single quote escaping in echo _c_flags to fix
>      Piotr Gorski's reported error.
>
> V4: This is based on the reimplementation provided by Masahiro Yamada
> on May 26. The difference is that this version now saves the compiler
> flags (_c_flags) from the Front-End (FE) compilation and re-uses them
> for the subsequent Back-End (BE) compilation.
>   
> Rong Xu (2):
>    kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
>    kbuild: distributed build support for Clang ThinLTO
>
>   .gitignore                 |  2 +
>   Makefile                   | 25 +++++-------
>   arch/Kconfig               | 19 +++++++++
>   scripts/Makefile.lib       |  7 ++++
>   scripts/Makefile.thinlto   | 40 ++++++++++++++++++
>   scripts/Makefile.vmlinux_a | 83 ++++++++++++++++++++++++++++++++++++++
>   scripts/mod/modpost.c      | 15 +++++--
>   7 files changed, 174 insertions(+), 17 deletions(-)
>   create mode 100644 scripts/Makefile.thinlto
>   create mode 100644 scripts/Makefile.vmlinux_a
>
>
> base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa