Re: [PATCH v5 1/2] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a

Nathan Chancellor
2026-03-16T20:43:17Z

On Mon, Mar 16, 2026 at 11:16:41AM -0700, Rong Xu wrote:
> If that's the case, we can just remove flag "--thin". Can we verify if
> that works?

I think we can only remove it from the second llvm-ar invocation. I
tested

diff --git a/Makefile b/Makefile
index 2b15f0b4a0cb..fb001e02cc0f 100644
--- a/Makefile
+++ b/Makefile
@@ -1260,12 +1260,11 @@ 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)
+ $(AR) mPi $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)

targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
--

on 7.0-rc4, which showed no issues. This is basically a revert of my
suggested workaround for the original issue:

https://lore.kernel.org/YyjjT5gQ2hGMH0ni@dev-arch.thelio-3990X/

You could add this as a prerequisite patch, I don't think it should be
squashed into the move change, especially since that appears to be why
we are in this situation. Why are we converting from the 'T' modifier to
'--thin' in the move patch? I know the documentation of llvm-ar and GNU
ar says that 'T' is deprecated in favor of '--thin' because it may do
different things on various ar implementations but the kernel only
supports these two implementations. I think we should just copy the
commands as they are and address the deprecation separately, perhaps
with an ar-option like Nicolas suggested upthread.

How about a v3 that looks like:

Patch 1: The diff above because all supported llvm-ar versions do the
same thing as GNU ar.

Patch 2: The move patch without changing 'T' into '--thin'.

Patch 3: The same as before, perhaps without '--thin' as well.

You'll need to base on kbuild-next-unstable [1] to address the conflict
with Yonghong's "kbuild: Reduce the number of compiler-generated
suffixes for clang thin-lto build" [2].

[1]: https://git.kernel.org/kbuild/l/kbuild-next-unstable
[2]: https://lore.kernel.org/20260307050250.3767489-1-yonghong.song@linux.dev/

Cheers,
Nathan