Message ID | 20241218-objtool-strict-v2-2-a5297c961434@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | objtool: Add option to fail build on vmlinux warnings | expand |
On Wed, Dec 18, 2024 at 02:58:56PM +0000, Brendan Jackman wrote: > NOINSTR_VALIDATION is pretty helpful for detecting bugs, it would be > helpful for the build to fail when those bugs arise. > > If necessary it would be possible to enable this for individual > warnings, it seems unlikely there's a use-case for that though. So > for now just add a global setting. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> The patch looks good to me, though the subject and commit log still need to be updated. It's no longer specific to vmlinux or NOINSTR_VALIDATION. And the justification is similar to what I mentioned before: objtool warnings (even seemingly "harmless" ones) often indicate serious bugs which can break the kernel.
On Wed, 18 Dec 2024 at 20:04, Josh Poimboeuf <jpoimboe@kernel.org> wrote: > The patch looks good to me, though the subject and commit log still need > to be updated. Agh, sorry. I'll wait a couple of days before posting the update to avoid spamming in case anyone wants to weigh in on the discussion.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index f3d72370587936fa373129cc9b246f15dac907be..3ee92da4733a3a504991d5dbb4d0cee84f519d64 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -545,6 +545,16 @@ config FRAME_POINTER config OBJTOOL bool +config OBJTOOL_WERROR + bool "Run objtool with warnings as errors" + default n + depends on OBJTOOL + help + Fail the build when objtool produces warnings. + + By default, objtool just prints warnings to the terminal without + causing a build failure. This config changes that. + config STACK_VALIDATION bool "Compile-time stack metadata validation" depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7395200538da89a2f6e6d21f8959f3f60d291d79..a53e052ae0532e886fcb2019025cf7216e484bd2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -277,6 +277,7 @@ objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES) +objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror objtool-args = $(objtool-args-y) \ $(if $(delay-objtool), --link) \
NOINSTR_VALIDATION is pretty helpful for detecting bugs, it would be helpful for the build to fail when those bugs arise. If necessary it would be possible to enable this for individual warnings, it seems unlikely there's a use-case for that though. So for now just add a global setting. Signed-off-by: Brendan Jackman <jackmanb@google.com> --- lib/Kconfig.debug | 10 ++++++++++ scripts/Makefile.lib | 1 + 2 files changed, 11 insertions(+)