Re: [PATCH v5 1/2] kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a
From: Rong Xu
Date: Mon Mar 16 2026 - 17:31:52 EST
I sent the following updated patch:
https://lore.kernel.org/all/20260316212930.120438-1-xur@xxxxxxxxxx/T/#t
-Rong
On Mon, Mar 16, 2026 at 8:53 PM Rong Xu <xur@xxxxxxxxxx> wrote:
>
> Sorry that my previous email may have caused some confusion.
> What I really meant was to keep -T (not change to '--thin').
>
> I think Masahiro's change targeted llvm-ar (<= 14), where it uses -T
> for "truncate", rather '--thin'. So he used ''--thin" explicitly. But
> this "--thin" was not implemented for some old ar.
>
> Since we the minimal llvm is now 15. The '-T' flag in legacy llvm-ar
> is no longer a problem. We should keep '-T'.
>
> -Rong
>
>
> On Mon, Mar 16, 2026 at 8:43 PM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
> >
> > 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@xxxxxxxxx/
> >
> > Cheers,
> > Nathan