Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Reduce CONFIG_OBJTOOL_WERROR verbosity

Remove the following from CONFIG_OBJTOOL_WERROR:

* backtrace

* "upgraded warnings to errors" message

* cmdline args

This makes the default output less cluttered and makes it easier to spot
the actual warnings. Note the above options are still are available
with --verbose or OBJTOOL_VERBOSE=1.

Also, do the cmdline arg printing on all warnings, regardless of werror.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/d61df69f64b396fa6b2a1335588aad7a34ea9e71.1742852846.git.jpoimboe@kernel.org

authored by

Josh Poimboeuf and committed by
Ingo Molnar
d39f82a0 c5995abe

+73 -71
+1 -1
scripts/Makefile.lib
··· 277 277 objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess 278 278 objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable 279 279 objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES) 280 - objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror --backtrace 280 + objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror 281 281 282 282 objtool-args = $(objtool-args-y) \ 283 283 $(if $(delay-objtool), --link) \
+55 -58
tools/objtool/builtin-check.c
··· 15 15 #include <objtool/objtool.h> 16 16 #include <objtool/warn.h> 17 17 18 - const char *objname; 18 + #define ORIG_SUFFIX ".orig" 19 19 20 + int orig_argc; 21 + static char **orig_argv; 22 + const char *objname; 20 23 struct opts opts; 21 24 22 25 static const char * const check_usage[] = { ··· 227 224 return 0; 228 225 } 229 226 230 - static char **save_argv(int argc, const char **argv) 227 + static void save_argv(int argc, const char **argv) 231 228 { 232 - char **orig_argv; 233 - 234 229 orig_argv = calloc(argc, sizeof(char *)); 235 230 if (!orig_argv) { 236 231 WARN_GLIBC("calloc"); 237 - return NULL; 232 + exit(1); 238 233 } 239 234 240 235 for (int i = 0; i < argc; i++) { 241 236 orig_argv[i] = strdup(argv[i]); 242 237 if (!orig_argv[i]) { 243 238 WARN_GLIBC("strdup(%s)", orig_argv[i]); 244 - return NULL; 239 + exit(1); 245 240 } 246 241 }; 247 - 248 - return orig_argv; 249 242 } 250 243 251 - #define ORIG_SUFFIX ".orig" 244 + void print_args(void) 245 + { 246 + char *backup = NULL; 247 + 248 + if (opts.output || opts.dryrun) 249 + goto print; 250 + 251 + /* 252 + * Make a backup before kbuild deletes the file so the error 253 + * can be recreated without recompiling or relinking. 254 + */ 255 + backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1); 256 + if (!backup) { 257 + WARN_GLIBC("malloc"); 258 + goto print; 259 + } 260 + 261 + strcpy(backup, objname); 262 + strcat(backup, ORIG_SUFFIX); 263 + if (copy_file(objname, backup)) { 264 + backup = NULL; 265 + goto print; 266 + } 267 + 268 + print: 269 + /* 270 + * Print the cmdline args to make it easier to recreate. If '--output' 271 + * wasn't used, add it to the printed args with the backup as input. 272 + */ 273 + fprintf(stderr, "%s", orig_argv[0]); 274 + 275 + for (int i = 1; i < orig_argc; i++) { 276 + char *arg = orig_argv[i]; 277 + 278 + if (backup && !strcmp(arg, objname)) 279 + fprintf(stderr, " %s -o %s", backup, objname); 280 + else 281 + fprintf(stderr, " %s", arg); 282 + } 283 + 284 + fprintf(stderr, "\n"); 285 + } 252 286 253 287 int objtool_run(int argc, const char **argv) 254 288 { 255 289 struct objtool_file *file; 256 - char *backup = NULL; 257 - char **orig_argv; 258 290 int ret = 0; 259 291 260 - orig_argv = save_argv(argc, argv); 261 - if (!orig_argv) 262 - return 1; 292 + orig_argc = argc; 293 + save_argv(argc, argv); 263 294 264 295 cmd_parse_options(argc, argv, check_usage); 265 296 ··· 316 279 317 280 file = objtool_open_read(objname); 318 281 if (!file) 319 - goto err; 282 + return 1; 320 283 321 284 if (!opts.link && has_multiple_files(file->elf)) { 322 285 WARN("Linked object requires --link"); 323 - goto err; 286 + return 1; 324 287 } 325 288 326 289 ret = check(file); 327 290 if (ret) 328 - goto err; 291 + return ret; 329 292 330 293 if (!opts.dryrun && file->elf->changed && elf_write(file->elf)) 331 - goto err; 294 + return 1; 332 295 333 296 return 0; 334 - 335 - err: 336 - if (opts.dryrun) 337 - goto err_msg; 338 - 339 - if (opts.output) { 340 - unlink(opts.output); 341 - goto err_msg; 342 - } 343 - 344 - /* 345 - * Make a backup before kbuild deletes the file so the error 346 - * can be recreated without recompiling or relinking. 347 - */ 348 - backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1); 349 - if (!backup) { 350 - WARN_GLIBC("malloc"); 351 - return 1; 352 - } 353 - 354 - strcpy(backup, objname); 355 - strcat(backup, ORIG_SUFFIX); 356 - if (copy_file(objname, backup)) 357 - return 1; 358 - 359 - err_msg: 360 - fprintf(stderr, "%s", orig_argv[0]); 361 - 362 - for (int i = 1; i < argc; i++) { 363 - char *arg = orig_argv[i]; 364 - 365 - if (backup && !strcmp(arg, objname)) 366 - fprintf(stderr, " %s -o %s", backup, objname); 367 - else 368 - fprintf(stderr, " %s", arg); 369 - } 370 - 371 - fprintf(stderr, "\n"); 372 - 373 - return 1; 374 297 }
+13 -10
tools/objtool/check.c
··· 4732 4732 4733 4733 free_insns(file); 4734 4734 4735 - if (opts.verbose) 4736 - disas_warned_funcs(file); 4737 - 4738 4735 if (opts.stats) { 4739 4736 printf("nr_insns_visited: %ld\n", nr_insns_visited); 4740 4737 printf("nr_cfi: %ld\n", nr_cfi); ··· 4740 4743 } 4741 4744 4742 4745 out: 4746 + if (!ret && !warnings) 4747 + return 0; 4748 + 4749 + if (opts.verbose) { 4750 + if (opts.werror && warnings) 4751 + WARN("%d warning(s) upgraded to errors", warnings); 4752 + print_args(); 4753 + disas_warned_funcs(file); 4754 + } 4755 + 4743 4756 /* 4744 4757 * CONFIG_OBJTOOL_WERROR upgrades all warnings (and errors) to actual 4745 4758 * errors. 4746 4759 * 4747 - * Note that even "fatal" type errors don't actually return an error 4748 - * without CONFIG_OBJTOOL_WERROR. That probably needs improved at some 4749 - * point. 4760 + * Note that even fatal errors don't yet actually return an error 4761 + * without CONFIG_OBJTOOL_WERROR. That will be fixed soon-ish. 4750 4762 */ 4751 - if (opts.werror && (ret || warnings)) { 4752 - if (warnings) 4753 - WARN("%d warning(s) upgraded to errors", warnings); 4763 + if (opts.werror) 4754 4764 return 1; 4755 - } 4756 4765 4757 4766 return 0; 4758 4767 }
+4 -2
tools/objtool/include/objtool/builtin.h
··· 43 43 44 44 extern struct opts opts; 45 45 46 - extern int cmd_parse_options(int argc, const char **argv, const char * const usage[]); 46 + int cmd_parse_options(int argc, const char **argv, const char * const usage[]); 47 47 48 - extern int objtool_run(int argc, const char **argv); 48 + int objtool_run(int argc, const char **argv); 49 + 50 + void print_args(void); 49 51 50 52 #endif /* _BUILTIN_H */