Skip to content

Commit eab9629

Browse files
committed
objtool: Add --Werror option
JIRA: https://issues.redhat.com/browse/RHEL-85302 Conflicts: tools/objtool/builtin-check.c tools/objtool/include/objtool/builtin.h - Diff context deltas from various missing commits. commit bb62243 Author: Josh Poimboeuf <jpoimboe@kernel.org> Date: Fri Mar 14 12:29:08 2025 -0700 objtool: Add --Werror option Any objtool warning has the potential of reflecting (or triggering) a major bug in the kernel or compiler which could result in crashing the kernel or breaking the livepatch consistency model. In preparation for failing the build on objtool errors/warnings, add a new --Werror option. [ jpoimboe: commit log, comments, error out on fatal errors too ] Co-developed-by: Brendan Jackman <jackmanb@google.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/e423ea4ec297f510a108aa6c78b52b9fe30fa8c1.1741975349.git.jpoimboe@kernel.org Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
1 parent 47d25c8 commit eab9629

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

tools/objtool/builtin-check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const struct option check_options[] = {
9999
OPT_STRING('o', "output", &opts.output, "file", "output file name"),
100100
OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
101101
OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
102+
OPT_BOOLEAN(0, "Werror", &opts.werror, "return error on warnings"),
102103

103104
OPT_END(),
104105
};

tools/objtool/check.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,9 +4641,18 @@ int check(struct objtool_file *file)
46414641

46424642
out:
46434643
/*
4644-
* For now, don't fail the kernel build on fatal warnings. These
4645-
* errors are still fairly common due to the growing matrix of
4646-
* supported toolchains and their recent pace of change.
4644+
* CONFIG_OBJTOOL_WERROR upgrades all warnings (and errors) to actual
4645+
* errors.
4646+
*
4647+
* Note that even "fatal" type errors don't actually return an error
4648+
* without CONFIG_OBJTOOL_WERROR. That probably needs improved at some
4649+
* point.
46474650
*/
4651+
if (opts.werror && (ret || warnings)) {
4652+
if (warnings)
4653+
WARN("%d warning(s) upgraded to errors", warnings);
4654+
return 1;
4655+
}
4656+
46484657
return 0;
46494658
}

tools/objtool/include/objtool/builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct opts {
3838
const char *output;
3939
bool sec_address;
4040
bool stats;
41+
bool werror;
4142
};
4243

4344
extern struct opts opts;

0 commit comments

Comments
 (0)