[PATCH v1] kbuild: Add KBUILD_VMLINUX_LIBS_PRELINK

Josh Poimboeuf jpoimboe at kernel.org
Fri Nov 21 10:42:47 PST 2025


On Fri, Nov 21, 2025 at 12:01:40AM -0700, Nathan Chancellor wrote:
> > @@ -1199,6 +1199,7 @@ 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_LIBS_PRELINK
> 
> This variable name is a little confusing to me since they do get added
> to vmlinux during linking, not before. I am not sure of a better one
> though, maybe KBUILD_VMLINUX_LIBS_FINAL?

I think that name was my idea.  Not sure what I was thinking, I guess
"prelink" was somehow meant to imply after the vmlinux.o whole-archive
link but before the "final" link.

"final" is indeed better.

> It may also make sense to
> introduce similar syntax to the existing libs-y syntax, maybe
> 
>   final-libs-y
> 
> or something like that?

Yeah, I suppose that would mirror how KBUILD_VMLINUX_LIBS is wired up.

> Also, since these objects are no longer in KBUILD_VMLINUX_LIBS, does
> this new variable need to be added to any of the other places in the
> build system that use KBUILD_VMLINUX_LIBS for things such as build
> dependencies?

Not sure about that one.  drivers/firmware/efi/libstub/lib.a is getting
built regardless so there must already be an implicit dependency?

-- 
Josh



More information about the linux-riscv mailing list