Re: [PATCH 12/27] kbuild: Defer running objtool to link time for all CFG features
From: Josh Poimboeuf
Date: Fri Aug 28 2026 - 14:20:14 EST
On Fri, Aug 28, 2026 at 10:57:08AM -0700, Nathan Chancellor wrote:
> On Thu, Aug 27, 2026 at 09:51:41PM -0700, Josh Poimboeuf wrote:
> > diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
> > index 9bac917e8b819..df1e3584883e6 100644
> > --- a/scripts/Makefile.vmlinux_o
> > +++ b/scripts/Makefile.vmlinux_o
> > @@ -30,20 +30,12 @@ endif
> > # objtool for vmlinux.o
> > # ---------------------------------------------------------------------------
> > #
> > -# For CONFIG_OBJTOOL_DEFERRED (IBT or LTO), objtool doesn't run on individual
> > -# translation units. Instead it runs on vmlinux.o.
> > -#
> > -# For !CONFIG_OBJTOOL_DEFERRED + CONFIG_NOINSTR_VALIDATION, it runs on both
> > -# translation units and vmlinux.o, with the latter only used for noinstr/unret
> > -# validation.
> > +# For CONFIG_OBJTOOL_DEFERRED, objtool doesn't run on individual translation
> > +# units. Instead it runs on vmlinux.o.
> >
> > -objtool-enabled := $(or $(CONFIG_OBJTOOL_DEFERRED),$(CONFIG_NOINSTR_VALIDATION))
> > +objtool-enabled := $(CONFIG_OBJTOOL_DEFERRED)
> >
> > -ifeq ($(CONFIG_OBJTOOL_DEFERRED),y)
> > vmlinux-objtool-args-y += $(objtool-args-y)
> > -else
> > -vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) += --werror
>
> Did you mean to drop this line or did it accidentally get culled in
> cleaning up the conditional statements?
That was actually on purpose.
Before this patch, NOINSTR_VALIDATION was a weird special case, where
objtool ran on individual TUs (with all the objtool-args-y), and then
ran again on vmlinux.o (without objtool-args-y except for --werror).
This patch makes NOINSTR_VALIDATION just another OBJTOOL_DEFERRED
feature which runs deferred, and *not* on TUs, so now it gets all the
args like the others.
That was indeed non-obvious, I'll add it to the commit log for v2.
> > -endif
> >
> > vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \
> > $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret)
--
Josh