From: Nicolas Schier <nsc@kernel.org>
To: xur@google.com
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Miguel Ojeda <ojeda@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Alice Ryhl <aliceryhl@google.com>,
Sami Tolvanen <samitolvanen@google.com>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Rafael Aquini <aquini@redhat.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Stafford Horne <shorne@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Piotr Gorski <piotrgorski@cachyos.org>,
Teresa Johnson <tejohnson@google.com>,
linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH v5 1/2] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
Date: Mon, 16 Mar 2026 14:33:17 +0100 [thread overview]
Message-ID: <abgGnfO5ZrpOUza7@levanger> (raw)
In-Reply-To: <20251028182822.3210436-2-xur@google.com>
[-- Attachment #1: Type: text/plain, Size: 4006 bytes --]
On Tue, Oct 28, 2025 at 06:28:21PM +0000, xur@google.com wrote:
> From: Rong Xu <xur@google.com>
>
> From: Masahiro Yamada <masahiroy@kernel.org>
>
> Move the build rule for vmlinux.a to a separate file in preparation
> for supporting distributed builds with Clang ThinLTO.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Tested-by: Rong Xu <xur@google.com>
> ---
> Makefile | 16 +++++--------
> scripts/Makefile.vmlinux_a | 46 ++++++++++++++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+), 10 deletions(-)
> create mode 100644 scripts/Makefile.vmlinux_a
>
> diff --git a/Makefile b/Makefile
> index b34a1f4c03967..89a25bac2bbab 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1198,7 +1198,7 @@ export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
> KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
> KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
>
> -export KBUILD_VMLINUX_LIBS
> +export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
> export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
>
> ifdef CONFIG_TRIM_UNUSED_KSYMS
> @@ -1207,16 +1207,12 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS
> KBUILD_MODULES := y
> endif
>
> -# '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
> -quiet_cmd_ar_vmlinux.a = AR $@
> - cmd_ar_vmlinux.a = \
> - rm -f $@; \
> - $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
> - $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
> +PHONY += vmlinux_a
> +vmlinux_a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
> + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_a
>
> -targets += vmlinux.a
> -vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
> - $(call if_changed,ar_vmlinux.a)
> +vmlinux.a: vmlinux_a
> + @:
>
> PHONY += vmlinux_o
> vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS)
> diff --git a/scripts/Makefile.vmlinux_a b/scripts/Makefile.vmlinux_a
> new file mode 100644
> index 0000000000000..9774f02b43b2f
> --- /dev/null
> +++ b/scripts/Makefile.vmlinux_a
> @@ -0,0 +1,46 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +PHONY := __default
> +__default: vmlinux.a
> +
> +include include/config/auto.conf
> +include $(srctree)/scripts/Kbuild.include
> +include $(srctree)/scripts/Makefile.lib
> +
> +# Link of built-in-fixup.a
> +# ---------------------------------------------------------------------------
> +
> +# '$(AR) mPi' needs --thin to workaround the bug of llvm-ar <= 14
> +quiet_cmd_ar_builtin_fixup = AR $@
> + cmd_ar_builtin_fixup = \
> + rm -f $@; \
> + $(AR) cDPrS --thin $@ $(KBUILD_VMLINUX_OBJS); \
> + $(AR) mPi --thin $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
Venkat Rao Bagalkote <venkat88@linux.ibm.com> reported [1] that this
breaks builds on system with binutils < 2.38.
Documentation/process/changes.rst state binutils 2.30 as build
dependency; binutils 2.38 has been released in 02/2022.
I removed the patch set from kbuild-next-unstable and kbuild-for-next
for now.
The simpliest solution would be to declare binutils 2.38 as build
dependency; but I am afraid that it is still "too new", right now.
Can someone elaborate a bit on the comment about --thin and "the bug of
llvm-ar <= 14'?
May it be an option to introduce $(ar-option) macro?
Something like this? (untested)
ar-option = $(call try-run, \
( trap 'rm -f $(tmp-target).ar-option' EXIT INT HUP QUIT; \
$(AR) cr $(1) $(tmp-target).ar-option ),$(1),$(2) )
AR_THIN = $(call ar-option, --thin)
...
$(AR) cDPrS $(AR_THIN) $@ $(KBUILD_VMLINUX_OBJS); \
$(AR) mPi $(AR_THIN) $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
Kind regards,
Nicolas
[1]: https://lore.kernel.org/linux-next/476507c9-a371-4864-9e87-572c1ecae82d@linux.ibm.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-03-16 13:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 18:28 [PATCH v5 0/2] kbuild: distributed build support for Clang ThinLTO xur
2025-10-28 18:28 ` [PATCH v5 1/2] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a xur
2026-03-16 13:33 ` Nicolas Schier [this message]
2026-03-16 13:59 ` Miguel Ojeda
2026-03-16 17:27 ` Rong Xu
2026-03-16 17:52 ` Nicolas Schier
2026-03-16 17:59 ` Nathan Chancellor
2026-03-16 18:16 ` Rong Xu
2026-03-16 20:43 ` Nathan Chancellor
2026-03-16 20:53 ` Rong Xu
2026-03-16 21:31 ` Rong Xu
2025-10-28 18:28 ` [PATCH v5 2/2] kbuild: distributed build support for Clang ThinLTO xur
2025-10-28 19:22 ` [PATCH v5 0/2] " Piotr Gorski
2025-12-04 17:49 ` Nathan Chancellor
2025-12-04 18:36 ` Rong Xu
2026-03-12 8:25 ` Nathan Chancellor
2026-03-12 11:45 ` Nicolas Schier
2026-03-12 17:50 ` Rong Xu
2026-03-13 14:50 ` Nicolas Schier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abgGnfO5ZrpOUza7@levanger \
--to=nsc@kernel.org \
--cc=aliceryhl@google.com \
--cc=aquini@redhat.com \
--cc=christophe.leroy@csgroup.eu \
--cc=justinstitt@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=morbo@google.com \
--cc=mpe@ellerman.id.au \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=ojeda@kernel.org \
--cc=piotrgorski@cachyos.org \
--cc=rppt@kernel.org \
--cc=samitolvanen@google.com \
--cc=shorne@gmail.com \
--cc=tejohnson@google.com \
--cc=tglx@linutronix.de \
--cc=xur@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox