From nobody Tue Apr 7 00:43:17 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BE0C3F8DF1; Tue, 17 Mar 2026 22:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787896; cv=none; b=lqSDbxR4JbP1u5Gtnm64LwOQD9aJVRLZHZqgXYuALc3kdRz0BLNAl9+kIKlCfl3FK1lT7xNKLu3tC9l8YREFLUvbklqsex8tX4aD0TxzFBcak0OCISOBeJGxra1A1bnzq8crDh4zbs4LhlcoWczax5JhQxx+/v8r/jP8HqmHkBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787896; c=relaxed/simple; bh=K2EF4WTRfHeASh1z8JUpsoYkCrO4xOH9SpbOyLu8+CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eeqOglc2JJVGgakzTKElfnJFQ2zoDqPxglIPo2F+8oBgak7nlGt2gKgTKhEdcCqhlL00vgJy10Qn8AvXcNXLGYNNV0MsLW64ehYDQuVMGwwWqP8BYoED5eNtWoVsp0WuMeGpMWUNDeQ9aVogZYEPZCzuLcFWs3Pb5ZJ4CFhAe0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M1i67/Mo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M1i67/Mo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6691C4AF09; Tue, 17 Mar 2026 22:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787896; bh=K2EF4WTRfHeASh1z8JUpsoYkCrO4xOH9SpbOyLu8+CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1i67/Mov8XDpflXD5q0rfdgzON3t0UT4lemySE51+WujWg/iCL4b9vZVF+4vic+A 740ymHe1YmgUmrVDCwLDb5BOwxzgS/myW2+v81rajqq1rcTrjh9+Sq1cupUoBz6Heg bhxVbtfQryBda/0svJrQxrRJSoKR8Ikct6hzUCPLtTjpqwUq595Bjf0tkeSJ6P81/t RnShf8zyZ8h/WMq4+DVtR5eQyPAuD5PVVgPOXjaZ/r9q0Ty+yZrBeF5xhDeJP2MBpe Cw6/vq8j9Y2iA3lnotGKezTD1nZO/+dLN3tXhBHxOp3TSdKZEWwTYQrr6BHGuk4T7q gz4iBTfUEohWQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 07/12] kbuild: Only run objtool if there is at least one command Date: Tue, 17 Mar 2026 15:51:07 -0700 Message-ID: <42418c5fa73a8876e91b3dfb38fa3f263e39f1c1.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Tested-by: Nathan Chancellor Signed-off-by: Josh Poimboeuf Reviewed-by: Nicolas Schier --- 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/arch/x86/boot/startup/Makefile b/arch/x86/boot/startup/Makefile index 5e499cfb29b5..a08297829fc6 100644 --- a/arch/x86/boot/startup/Makefile +++ b/arch/x86/boot/startup/Makefile @@ -36,7 +36,7 @@ $(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STA= NDARD :=3D y # relocations, even if other objtool actions are being deferred. # $(pi-objs): objtool-enabled =3D 1 -$(pi-objs): objtool-args =3D $(if $(delay-objtool),--dry-run,$(objtool-arg= s-y)) --noabs +$(pi-objs): objtool-args =3D $(if $(delay-objtool),--dry-run,$(objtool-cmd= s-y) $(objtool-opts-y)) --noabs =20 # # Confine the startup code by prefixing all symbols with __pi_ (for positi= on 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 =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object)) =20 ifdef CONFIG_OBJTOOL -$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= delay-objtool),$(is-single-obj-m),y)) +$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= objtool-cmds-y),$(if $(delay-objtool),$(is-single-obj-m),y))) endif =20 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) @@ -501,7 +501,7 @@ define rule_ld_multi_m $(call cmd,gen_objtooldep) endef =20 -$(multi-obj-m): private objtool-enabled :=3D $(delay-objtool) +$(multi-obj-m): private objtool-enabled :=3D $(if $(objtool-cmds-y),$(dela= y-objtool)) $(multi-obj-m): private part-of-module :=3D y $(multi-obj-m): %.o: %.mod FORCE $(call if_changed_rule,ld_multi_m) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0718e39cedda..40a462581666 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -183,27 +183,31 @@ ifdef CONFIG_OBJTOOL =20 objtool :=3D $(objtree)/tools/objtool/objtool =20 -objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) +=3D --hacks=3Djump_label -objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) +=3D --hacks=3Dnoinstr -objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) +=3D --hacks=3Dskyla= ke -objtool-args-$(CONFIG_X86_KERNEL_IBT) +=3D --ibt -objtool-args-$(CONFIG_FINEIBT) +=3D --cfi -objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) +=3D --mcount -ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL -objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) +=3D --mnop -endif -objtool-args-$(CONFIG_UNWINDER_ORC) +=3D --orc -objtool-args-$(CONFIG_MITIGATION_RETPOLINE) +=3D --retpoline -objtool-args-$(CONFIG_MITIGATION_RETHUNK) +=3D --rethunk -objtool-args-$(CONFIG_MITIGATION_SLS) +=3D --sls -objtool-args-$(CONFIG_STACK_VALIDATION) +=3D --stackval -objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D --static-call -objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) +=3D --uaccess -objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) +=3D --no-unreacha= ble -objtool-args-$(CONFIG_PREFIX_SYMBOLS) +=3D --prefix=3D$(CONFIG_FUNCTION_= PADDING_BYTES) -objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror +# objtool commands +objtool-cmds-$(CONFIG_HAVE_JUMP_LABEL_HACK) +=3D --hacks=3Djump_label +objtool-cmds-$(CONFIG_HAVE_NOINSTR_HACK) +=3D --hacks=3Dnoinstr +objtool-cmds-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) +=3D --hacks=3Dskyla= ke +objtool-cmds-$(CONFIG_X86_KERNEL_IBT) +=3D --ibt +objtool-cmds-$(CONFIG_FINEIBT) +=3D --cfi +objtool-cmds-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) +=3D --mcount +objtool-cmds-$(CONFIG_UNWINDER_ORC) +=3D --orc +objtool-cmds-$(CONFIG_MITIGATION_RETPOLINE) +=3D --retpoline +objtool-cmds-$(CONFIG_MITIGATION_RETHUNK) +=3D --rethunk +objtool-cmds-$(CONFIG_MITIGATION_SLS) +=3D --sls +objtool-cmds-$(CONFIG_STACK_VALIDATION) +=3D --stackval +objtool-cmds-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D --static-call +objtool-cmds-$(CONFIG_HAVE_UACCESS_VALIDATION) +=3D --uaccess +objtool-cmds-$(CONFIG_PREFIX_SYMBOLS) +=3D --prefix=3D$(CONFIG_FUNCTION_= PADDING_BYTES) +objtool-cmds-y +=3D $(OBJTOOL_ARGS) =20 -objtool-args =3D $(objtool-args-y) \ +# objtool options +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL +objtool-opts-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) +=3D --mnop +endif +objtool-opts-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) +=3D --no-unreacha= ble +objtool-opts-$(CONFIG_OBJTOOL_WERROR) +=3D --werror + +objtool-args =3D $(objtool-cmds-y) $(objtool-opts-y) \ $(if $(delay-objtool), --link) \ $(if $(part-of-module), --module) =20 @@ -212,7 +216,7 @@ delay-objtool :=3D $(or $(CONFIG_LTO_CLANG),$(CONFIG_X8= 6_KERNEL_IBT),$(CONFIG_KLP_ cmd_objtool =3D $(if $(objtool-enabled), ; $(objtool) $(objtool-args) $@) cmd_gen_objtooldep =3D $(if $(objtool-enabled), { echo ; echo '$@: $$(wild= card $(objtool))' ; } >> $(dot-target).cmd) =20 -objtool-enabled :=3D y +objtool-enabled =3D $(if $(objtool-cmds-y),y) =20 endif # CONFIG_OBJTOOL =20 diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 527352c222ff..09af33203bd8 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -36,18 +36,13 @@ endif # For !delay-objtool + CONFIG_NOINSTR_VALIDATION, it runs on both translat= ion # units and vmlinux.o, with the latter only used for noinstr/unret validat= ion. =20 -objtool-enabled :=3D $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) - -ifeq ($(delay-objtool),y) -vmlinux-objtool-args-y +=3D $(objtool-args-y) -else -vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror +ifneq ($(delay-objtool),y) +objtool-cmds-y =3D +objtool-opts-y +=3D --link endif =20 -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ - $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_S= RSO)), --unret) - -objtool-args =3D $(vmlinux-objtool-args-y) --link +objtool-cmds-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ + $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SR= SO)), --unret) =20 # Link of vmlinux.o used for section mismatch analysis # ------------------------------------------------------------------------= --- --=20 2.53.0