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

tools/resolve_btfids: Add --fatal_warnings option

Currently warnings emitted by resolve_btfids are buried in the build log
and are slipping into mainline frequently.

Add an option to elevate warnings to hard errors so the CI bots can catch
any new warnings.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20241204-resolve_btfids-v3-1-e6a279a74cfd@weissschuh.net

authored by

Thomas Weißschuh and committed by
Daniel Borkmann
b70b0739 4d33dc1b

+10 -2
+10 -2
tools/bpf/resolve_btfids/main.c
··· 141 141 }; 142 142 143 143 static int verbose; 144 + static int warnings; 144 145 145 146 static int eprintf(int level, int var, const char *fmt, ...) 146 147 { ··· 605 604 if (id->id) { 606 605 pr_info("WARN: multiple IDs found for '%s': %d, %d - using %d\n", 607 606 str, id->id, type_id, id->id); 607 + warnings++; 608 608 } else { 609 609 id->id = type_id; 610 610 (*nr)--; ··· 627 625 int i; 628 626 629 627 /* For set, set8, id->id may be 0 */ 630 - if (!id->id && !id->is_set && !id->is_set8) 628 + if (!id->id && !id->is_set && !id->is_set8) { 631 629 pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name); 630 + warnings++; 631 + } 632 632 633 633 for (i = 0; i < id->addr_cnt; i++) { 634 634 unsigned long addr = id->addr[i]; ··· 786 782 .funcs = RB_ROOT, 787 783 .sets = RB_ROOT, 788 784 }; 785 + bool fatal_warnings = false; 789 786 struct option btfid_options[] = { 790 787 OPT_INCR('v', "verbose", &verbose, 791 788 "be more verbose (show errors, etc)"), ··· 794 789 "BTF data"), 795 790 OPT_STRING('b', "btf_base", &obj.base_btf_path, "file", 796 791 "path of file providing base BTF"), 792 + OPT_BOOLEAN(0, "fatal_warnings", &fatal_warnings, 793 + "turn warnings into errors"), 797 794 OPT_END() 798 795 }; 799 796 int err = -1; ··· 830 823 if (symbols_patch(&obj)) 831 824 goto out; 832 825 833 - err = 0; 826 + if (!(fatal_warnings && warnings)) 827 + err = 0; 834 828 out: 835 829 if (obj.efile.elf) { 836 830 elf_end(obj.efile.elf);