[PATCH v2 07/12] kbuild: Only run objtool if there is at least one command

Josh Poimboeuf jpoimboe at kernel.org
Wed Mar 18 17:49:27 PDT 2026


On Wed, Mar 18, 2026 at 08:54:31PM +0100, Nicolas Schier wrote:
> On Tue, Mar 17, 2026 at 03:51:07PM -0700, Josh Poimboeuf wrote:
> > Split the objtool args into commands and options, such that if no
> > commands have been enabled, objtool doesn't run.
> > 
> > This is in preparation in enabling objtool and klp-build for arm64.
> > 
> > Reviewed-by: Nathan Chancellor <nathan at kernel.org>
> > Tested-by: Nathan Chancellor <nathan at kernel.org>
> > Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
> > ---
> >  arch/x86/boot/startup/Makefile |  2 +-
> >  scripts/Makefile.build         |  4 +--
> >  scripts/Makefile.lib           | 46 ++++++++++++++++++----------------
> >  scripts/Makefile.vmlinux_o     | 15 ++++-------
> >  4 files changed, 33 insertions(+), 34 deletions(-)
> > 
> [...]
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 3652b85be545..8a1bdfdb2fdb 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -277,7 +277,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
> >  is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object))
> >  
> >  ifdef CONFIG_OBJTOOL
> > -$(obj)/%.o: private objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
> > +$(obj)/%.o: private objtool-enabled = $(if $(is-standard-object),$(if $(objtool-cmds-y),$(if $(delay-objtool),$(is-single-obj-m),y)))
> 
> Please use $(and a,b,c) instead of multiple nested $(if $(a),$(if
> $(b),$(c)); as the last variable (is-single-obj-m) is 'y' or empty, the final 'y' can be
> left-out:
> 
> $(obj)/%.o: private objtool-enabled = $(and $(is-standard-object),$(objtool-cmds-y),$(delay-objtool),$(is-single-obj-m))

I believe that would break the !delay-objtool case.  The logic needs to
be something like:

if (is-standard-object && objtool-cmds-y) {
	if (delay-objtool) {
		// for delay-objtool, only enable objtool for single-object modules
		$(is-single-obj-m)
	} else {
		// for !delay-objtool, always enable objtool
		y
	}
}

so maybe something like this?

$(obj)/%.o: private objtool-enabled = $(and $(is-standard-object),$(objtool-cmds-y),$(if $(delay-objtool),$(is-single-obj-m),y))

-- 
Josh



More information about the linux-arm-kernel mailing list