Skip to content

Commit bb62243

Browse files
jpoimboePeter Zijlstra
authored andcommitted
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
1 parent 5a40603 commit bb62243

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
@@ -101,6 +101,7 @@ static const struct option check_options[] = {
101101
OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
102102
OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
103103
OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"),
104+
OPT_BOOLEAN(0, "Werror", &opts.werror, "return error on warnings"),
104105

105106
OPT_END(),
106107
};

tools/objtool/check.c

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

47574757
out:
47584758
/*
4759-
* For now, don't fail the kernel build on fatal warnings. These
4760-
* errors are still fairly common due to the growing matrix of
4761-
* supported toolchains and their recent pace of change.
4759+
* CONFIG_OBJTOOL_WERROR upgrades all warnings (and errors) to actual
4760+
* errors.
4761+
*
4762+
* Note that even "fatal" type errors don't actually return an error
4763+
* without CONFIG_OBJTOOL_WERROR. That probably needs improved at some
4764+
* point.
47624765
*/
4766+
if (opts.werror && (ret || warnings)) {
4767+
if (warnings)
4768+
WARN("%d warning(s) upgraded to errors", warnings);
4769+
return 1;
4770+
}
4771+
47634772
return 0;
47644773
}

tools/objtool/include/objtool/builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct opts {
3939
bool sec_address;
4040
bool stats;
4141
bool verbose;
42+
bool werror;
4243
};
4344

4445
extern struct opts opts;

0 commit comments

Comments
 (0)