Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Brendan Jackman <jackmanb@google.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	 Brendan Jackman <jackmanb@google.com>
Subject: [PATCH 2/2] kbuild: Add option to fail build on vmlinux objtool issues
Date: Fri, 13 Dec 2024 11:31:31 +0000	[thread overview]
Message-ID: <20241213-objtool-strict-v1-2-fd388f9d971f@google.com> (raw)
In-Reply-To: <20241213-objtool-strict-v1-0-fd388f9d971f@google.com>

NOINSTR_VALIDATION is pretty helpful for detecting bugs, I would like
my build to fail when those bugs arise.

If we wanted to we could enable this for individual warnings, it seems
unlikely there's a use-case for that though. So for now I've just added
a global setting for vmlinux.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 lib/Kconfig.debug          | 11 +++++++++++
 scripts/Makefile.vmlinux_o |  1 +
 2 files changed, 12 insertions(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f3d72370587936fa373129cc9b246f15dac907be..b1f0f8c83b050d4112428e0d8dece059ebf8dcd2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -563,6 +563,17 @@ config NOINSTR_VALIDATION
 	select OBJTOOL
 	default y
 
+config VMLINUX_OBJTOOL_STRICT
+	bool "Strict objtool on vmlinux"
+	default n
+	# Conditions when we run objtool on vmlinux
+	depends on NOINSTR_VALIDATION || LTO_CLANG || X86_KERNEL_IBT
+	help
+	  Fail the build when objtool produces warnings on vmlinux.
+
+	  By default, objtool just prints warnings to the terminal without
+	  causing a build failure. This config changes that for vmlinux.
+
 config VMLINUX_MAP
 	bool "Generate vmlinux.map file when linking"
 	depends on EXPERT
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 0b6e2ebf60dc1bb69d9651d5b7858ccd296e92dd..97b6b262d482e0bac1a4d74f9a2e7b1867b6ee00 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -39,6 +39,7 @@ vmlinux-objtool-args-$(delay-objtool)			+= $(objtool-args-y)
 vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL)		+= --no-unreachable
 vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION)	+= --noinstr \
 							   $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret)
+vmlinux-objtool-args-$(CONFIG_VMLINUX_OBJTOOL_STRICT)	+= --fail-on-warn
 
 objtool-args = $(vmlinux-objtool-args-y) --link
 

-- 
2.47.1.613.gc27f4b7a9f-goog


  parent reply	other threads:[~2024-12-13 11:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 11:31 [PATCH 0/2] objtool: Add option to fail build on vmlinux warnings Brendan Jackman
2024-12-13 11:31 ` [PATCH 1/2] objtool: Add --fail-on-warn Brendan Jackman
2024-12-14  0:36   ` Josh Poimboeuf
2024-12-16  9:55     ` Brendan Jackman
2024-12-13 11:31 ` Brendan Jackman [this message]
2024-12-14  0:52   ` [PATCH 2/2] kbuild: Add option to fail build on vmlinux objtool issues Josh Poimboeuf
2024-12-16 10:00     ` Brendan Jackman
2024-12-18  9:08       ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241213-objtool-strict-v1-2-fd388f9d971f@google.com \
    --to=jackmanb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox