Re: [PATCH v3 1/2] objtool: Add --Werror

Josh Poimboeuf
2025-01-14T18:17:34Z

On Tue, Jan 14, 2025 at 10:24:29AM -0700, Nathan Chancellor wrote:
>
> It might be a good idea to print a message here about why the build is
> failing, in lieu of turning all "objtool: warning:" messages into
> "objtool: error:" messages ala -Werror for C compilers, which does not
> seem simple on quick glance. Otherwise, I am not entirely sure it will
> be obvious to people why a build like allmodconfig may start failing if
> this configuration gets turned on.
>
> https://lore.kernel.org/Z4X8j%2FqJj7ib0vkh@rli9-mobl/

Yeah, makes sense. I'll add this:

From: Josh Poimboeuf <jpoimboe@kernel.org>
Subject: [PATCH] objtool: Change "warning:" to "error:" for CONFIG_OBJTOOL_WERROR

This matches GCC's behavior and makes it more obvious why the build
failed.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
tools/objtool/include/objtool/warn.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index ac04d3fe4dd9..78f602b5daed 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -43,8 +43,10 @@ static inline char *offstr(struct section *sec, unsigned long offset)

#define WARN(format, ...) \
fprintf(stderr, \
- "%s: warning: objtool: " format "\n", \
- objname, ##__VA_ARGS__)
+ "%s: %s: objtool: " format "\n", \
+ objname, \
+ opts.werror ? "error" : "warning", \
+ ##__VA_ARGS__)

#define WARN_FUNC(format, sec, offset, ...) \
({ \
--
2.47.1