bpf: Disable -Wsuggest-attribute=format
PATCH 1/1 bpf: Disable -Wsuggest-attribute=format
The printing functions in BPF code are using printf() type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
1069 | err = bstr_printf(str, str_size, fmt, data.bin_args);
| ^~~kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args);
| ^~~kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
| ^~~kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
| ^~~kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
475 | seq_bprintf(m, fmt, data.bin_args);
| ^~~~~~~~~~~Fix the compilation errors by disabling that warning since the code is generated and warning is not so useful in this case — it can't check the parameters for now.
--- kernel/bpf/Makefile | 11 +++++++++-- kernel/trace/Makefile | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
kernel/bpf/Makefile +9 -2
@@ -6,7 +6,14 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse endif CFLAGS_core.o += -Wno-override-init $(cflags-nogcse-yy) -obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o token.o liveness.o +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o tnum.o log.o token.o liveness.o + +obj-$(CONFIG_BPF_SYSCALL) += helpers.o stream.o +# The ____bpf_snprintf() uses the format string that triggers a compiler warning. +CFLAGS_helpers.o += -Wno-suggest-attribute=format +# The bpf_stream_vprintk_impl() uses the format string that triggers a compiler warning. +CFLAGS_stream.o += -Wno-suggest-attribute=format + obj-$(CONFIG_BPF_SYSCALL) += bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o bpf_insn_array.o
@@ -14,7 +21,7 @@ obj-$(CONFIG_BPF_SYSCALL) += bpf_local_storage.o bpf_task_storage.o obj-${CONFIG_BPF_LSM} += bpf_inode_storage.o obj-$(CONFIG_BPF_SYSCALL) += disasm.o mprog.o obj-$(CONFIG_BPF_JIT) += trampoline.o -obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o stream.o +obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o ifeq ($(CONFIG_MMU)$(CONFIG_64BIT),yy) obj-$(CONFIG_BPF_SYSCALL) += arena.o range_tree.o endif
kernel/trace/Makefile +6 -0
@@ -104,7 +104,13 @@ obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_USER_EVENTS) += trace_events_user.o + obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o +# The BPF printing functions use the format string that triggers a compiler warning. +# Since the code is generated and warning is not so useful in this case (it can't +# check the parameters for now) disable the warning. +CFLAGS_bpf_trace.o += -Wno-suggest-attribute=format + obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o
Signature · 1 line
2.50.1
Quoted 16 lines · Andy Shevchenko
The printing functions in BPF code are using
printf()type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]1069 | err = bstr_printf(str, str_size, fmt, data.bin_args); | ^~~
kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
Quoted 8 lines
kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]475 | seq_bprintf(m, fmt, data.bin_args); | ^~~~~~~~~~~
I just want to point out that the compiler suggestion is wrong here and these functions do not follow printf semantics. Yes, they have printf format string argument, but arguments themselves are passed using a special convention that the compiler won't know how to verify properly. So now, these are not candidates for gnu_printf, and it would be nice to have some way to shut up GCC for individual function instead of blanket -Wno-suggest-attribute for the entire file.
Similarly, I see you marked bstr_printf() with __printf() earlier. That also seems wrong, so you might want to fix that mistake as well, while at it.
Maybe the pragma push/pop approach would be a bit better and more explicit in the code?
Quoted 70 lines
Fix the compilation errors by disabling that warning since the code is generated and warning is not so useful in this case — it can't check the parameters for now.
Reported-by kernel test robot <[email protected]>Fixes 5ab154f1463a ("bpf: Introduce BPF standard streams")Fixes 10aceb629e19 ("bpf: Add bpf_trace_vprintk helper")Fixes 7b15523a989b ("bpf: Add a bpf_snprintf helper")Fixes 492e639f0c22 ("bpf: Add bpf_seq_printf and bpf_seq_write helpers")Fixes f3694e001238 ("bpf: add BPF_CALL_x macros for declaring helpers")Suggested-by Alexei Starovoitov <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- kernel/bpf/Makefile | 11 +++++++++-- kernel/trace/Makefile | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-)kernel/bpf/Makefile +9
-2@@ -6,7 +6,14 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse endif CFLAGS_core.o += -Wno-override-init $(cflags-nogcse-yy) -obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o token.o liveness.o +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o tnum.o log.o token.o liveness.o + +obj-$(CONFIG_BPF_SYSCALL) += helpers.o stream.o +# The ____bpf_snprintf() uses the format string that triggers a compiler warning. +CFLAGS_helpers.o += -Wno-suggest-attribute=format +# The bpf_stream_vprintk_impl() uses the format string that triggers a compiler warning. +CFLAGS_stream.o += -Wno-suggest-attribute=format + obj-$(CONFIG_BPF_SYSCALL) += bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o bpf_insn_array.o@@ -14,7 +21,7 @@ obj-$(CONFIG_BPF_SYSCALL) += bpf_local_storage.o bpf_task_storage.o obj-${CONFIG_BPF_LSM} += bpf_inode_storage.o obj-$(CONFIG_BPF_SYSCALL) += disasm.o mprog.o obj-$(CONFIG_BPF_JIT) += trampoline.o -obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o stream.o +obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o ifeq ($(CONFIG_MMU)$(CONFIG_64BIT),yy) obj-$(CONFIG_BPF_SYSCALL) += arena.o range_tree.o endifkernel/trace/Makefile +6
-1@@ -104,7 +104,13 @@ obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_USER_EVENTS) += trace_events_user.o + obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o +# The BPF printing functions use the format string that triggers a compiler warning. +# Since the code is generated and warning is not so useful in this case (it can't +# check the parameters for now) disable the warning. +CFLAGS_bpf_trace.o += -Wno-suggest-attribute=format + obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o --2.50.1
Quoted 36 lines · Andrii Nakryiko
Quoted 16 lines · Andy Shevchenko
The printing functions in BPF code are using
printf()type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]1069 | err = bstr_printf(str, str_size, fmt, data.bin_args); | ^~~
kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~Quoted 8 lines
kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]475 | seq_bprintf(m, fmt, data.bin_args); | ^~~~~~~~~~~I just want to point out that the compiler suggestion is wrong here and these functions do not follow printf semantics. Yes, they have printf format string argument, but arguments themselves are passed using a special convention that the compiler won't know how to verify properly. So now, these are not candidates for
gnu_printf, and it would be nice to have some way to shut up GCC for individual function instead of blanket -Wno-suggest-attribute for the entire file.
Quoted 6 lines
Similarly, I see you marked
bstr_printf()with__printf()earlier. That also seems wrong, so you might want to fix that mistake as well, while at it.Maybe the pragma push/pop approach would be a bit better and more explicit in the code?
I suggested using makefile and file level disable to avoid polluting the code. Even when attr-print applies it doesn't help definitions. The attribute is only useful in declaration and in our case it's not going to be in vmlinux.h or in bpf_helpers.h
So having it right or wrong in .c is misleading.
Quoted 43 lines · Alexei Starovoitov
Quoted 40 lines · Andrii Nakryiko
Quoted 16 lines · Andy Shevchenko
The printing functions in BPF code are using
printf()type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]1069 | err = bstr_printf(str, str_size, fmt, data.bin_args); | ^~~
kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~Quoted 8 lines
kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]475 | seq_bprintf(m, fmt, data.bin_args); | ^~~~~~~~~~~I just want to point out that the compiler suggestion is wrong here and these functions do not follow printf semantics. Yes, they have printf format string argument, but arguments themselves are passed using a special convention that the compiler won't know how to verify properly. So now, these are not candidates for
gnu_printf, and it would be nice to have some way to shut up GCC for individual function instead of blanket -Wno-suggest-attribute for the entire file.Similarly, I see you marked
bstr_printf()with__printf()earlier. That also seems wrong, so you might want to fix that mistake as well, while at it.
Quoted 8 lines
Quoted 2 lines
Maybe the pragma push/pop approach would be a bit better and more explicit in the code?
I suggested using makefile and file level disable to avoid polluting the code. Even when attr-print applies it doesn't help definitions. The attribute is only useful in declaration and in our case it's not going to be in
vmlinux.hor inbpf_helpers.h
So having it right or wrong in .c is misleading.
Makefile is fine, even if it's a big hammer, I don't mind or care.
But I think instead of Makefile changes we should fix the root cause here. And that seems to be just wrong __printf annotations for seq_bprintf and bstr_printf. They are not printf-like, they should not be marked as such, and then the compiler won't be wrongly suggesting bpf_stream_vprintk_impl (and others that make use of either bstr_printf or seq_bprintf) to be marked with __printf.
Quoted 49 lines · Andrii Nakryiko
Quoted 46 lines · Alexei Starovoitov
Quoted 42 lines · Andrii Nakryiko
Quoted 16 lines · Andy Shevchenko
The printing functions in BPF code are using
printf()type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]1069 | err = bstr_printf(str, str_size, fmt, data.bin_args); | ^~~
kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~Quoted 8 lines
kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]475 | seq_bprintf(m, fmt, data.bin_args); | ^~~~~~~~~~~I just want to point out that the compiler suggestion is wrong here and these functions do not follow printf semantics. Yes, they have printf format string argument, but arguments themselves are passed using a special convention that the compiler won't know how to verify properly. So now, these are not candidates for
gnu_printf, and it would be nice to have some way to shut up GCC for individual function instead of blanket -Wno-suggest-attribute for the entire file.Similarly, I see you marked
bstr_printf()with__printf()earlier. That also seems wrong, so you might want to fix that mistake as well, while at it.Maybe the pragma push/pop approach would be a bit better and more explicit in the code?
Quoted 7 lines
Quoted 5 lines
I suggested using makefile and file level disable to avoid polluting the code. Even when attr-print applies it doesn't help definitions. The attribute is only useful in declaration and in our case it's not going to be in
vmlinux.hor inbpf_helpers.h
So having it right or wrong in .c is misleading.
Makefileis fine, even if it's a big hammer, I don't mind or care.
I rewrote the patch, commit log and pushed:
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=ba34388912b5326aac591508c953a0be67a15d5a
Quoted 6 lines
But I think instead of
Makefilechanges we should fix the root cause here. And that seems to be just wrong__printfannotations forseq_bprintfandbstr_printf. They are not printf-like, they should not be marked as such, and then the compiler won't be wrongly suggestingbpf_stream_vprintk_impl(and others that make use of eitherbstr_printforseq_bprintf) to be marked with__printf.
yeah. commit 7bf819aa992f ("vsnprintf: Mark binary printing functions with __printf() attribute")
should be reverted,
but that somebody else problem and the revert would need to silence that incorrect warning in lib/vsprintf.c too.
Steven Rostedt
maintainerQuoted 7 lines · On Mon, 15 Dec 2025 10:40:16 -0800 Alexei Starovoitov…
Quoted 6 lines
But I think instead of
Makefilechanges we should fix the root cause here. And that seems to be just wrong__printfannotations forseq_bprintfandbstr_printf. They are not printf-like, they should not be marked as such, and then the compiler won't be wrongly suggestingbpf_stream_vprintk_impl(and others that make use of eitherbstr_printforseq_bprintf) to be marked with__printf.
Quoted 5 lines
yeah. commit
7bf819aa992f("vsnprintf: Mark binary printing functions with__printf()attribute")
should be reverted,
but that somebody else problem and the revert would need to silence that incorrect warning inlib/vsprintf.ctoo.
From what I understand, the __printf(X, 0) simply quiets the warning, which is why those two are:
__printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); __printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
Hence, it's not a big deal to have that. Actually, it does document that the printf format is different than a normal printf, and that the arguments are not the same as a normal printf.
I complained about this at first too (and never gave an acked-by), but because it does quiet a warning, I also didn't nack it.
-- Steve
Ihor Solodrai
reviewerQuoted 49 lines · Andy Shevchenko
The printing functions in BPF code are using
printf()type of format, and compiler is not happy about them as is:
kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]1069 | err = bstr_printf(str, str_size, fmt, data.bin_args); | ^~~
kernel/bpf/stream.c:241:9: error: function ‘bpf_stream_vprintk_impl’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]241 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt__str, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args); | ^~~
kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]475 | seq_bprintf(m, fmt, data.bin_args); | ^~~~~~~~~~~Fix the compilation errors by disabling that warning since the code is generated and warning is not so useful in this case — it can't check the parameters for now.
Reported-by kernel test robot <[email protected]>Fixes 5ab154f1463a ("bpf: Introduce BPF standard streams")Fixes 10aceb629e19 ("bpf: Add bpf_trace_vprintk helper")Fixes 7b15523a989b ("bpf: Add a bpf_snprintf helper")Fixes 492e639f0c22 ("bpf: Add bpf_seq_printf and bpf_seq_write helpers")Fixes f3694e001238 ("bpf: add BPF_CALL_x macros for declaring helpers")Suggested-by Alexei Starovoitov <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- kernel/bpf/Makefile | 11 +++++++++-- kernel/trace/Makefile | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-)kernel/bpf/Makefile +0
-0@@ -6,7 +6,14 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse endif
kernel/bpf/Makefile cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse · line 15
Quoted 10 lines
kernel/bpf/Makefile +7
-1CFLAGS_core.o += -Wno-override-init $(cflags-nogcse-yy) -obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o token.o liveness.o +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o tnum.o log.o token.o liveness.o + +obj-$(CONFIG_BPF_SYSCALL) += helpers.o stream.o +# The ____bpf_snprintf() uses the format string that triggers a compiler warning. +CFLAGS_helpers.o += -Wno-suggest-attribute=format +# The bpf_stream_vprintk_impl() uses the format string that triggers a compiler warning. +CFLAGS_stream.o += -Wno-suggest-attribute=format
Hi Andy,
This flag does not exist in clang:
$ LLVM=1 make -j$(nproc) [...] $ LLVM=1 make CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers DESCEND bpf/resolve_btfids INSTALL libsubcmd_headers CC kernel/trace/bpf_trace.o error: unknown warning option '-Wno-suggest-attribute=format'; did you mean '-Wno-property-attribute-mismatch'? [-Werror,-Wunknown-warning-option] make[4]: *** [scripts/Makefile.build:287: kernel/trace/bpf_trace.o] Error 1 make[3]: *** [scripts/Makefile.build:556: kernel/trace] Error 2 make[2]: *** [scripts/Makefile.build:556: kernel] Error 2 make[1]: *** [/home/isolodrai/kernels/bpf-next/Makefile:2030: .] Error 2 make: *** [Makefile:248: __sub-make] Error 2
We should probably conditionalize the flag addition in the makefile.
Or better yet, address the root cause as suggested in the thread.
BPF CI is red on bpf branch at the moment:
https://github.com/kernel-patches/bpf/actions/runs/20243520506/job/58144348281
Quoted 31 lines
kernel/bpf/Makefile +2
-1+ obj-$(CONFIG_BPF_SYSCALL) += bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o bpf_insn_array.o@@ -14,7 +21,7 @@ obj-$(CONFIG_BPF_SYSCALL) += bpf_local_storage.o bpf_task_storage.o obj-${CONFIG_BPF_LSM} += bpf_inode_storage.o obj-$(CONFIG_BPF_SYSCALL) += disasm.o mprog.o obj-$(CONFIG_BPF_JIT) += trampoline.o -obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o stream.o +obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o ifeq ($(CONFIG_MMU)$(CONFIG_64BIT),yy) obj-$(CONFIG_BPF_SYSCALL) += arena.o range_tree.o endifkernel/trace/Makefile +6
-0@@ -104,7 +104,13 @@ obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_USER_EVENTS) += trace_events_user.o + obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o +# The BPF printing functions use the format string that triggers a compiler warning. +# Since the code is generated and warning is not so useful in this case (it can't +# check the parameters for now) disable the warning. +CFLAGS_bpf_trace.o += -Wno-suggest-attribute=format + obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o
Ihor Solodrai
reviewerQuoted 31 lines · Ihor Solodrai
Review
Quoted 9 lines · Andy Shevchenko
[...]
(quoted diff) +7
-1-obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o log.o token.o liveness.o +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o tnum.o log.o token.o liveness.o + +obj-$(CONFIG_BPF_SYSCALL) += helpers.o stream.o +# The ____bpf_snprintf() uses the format string that triggers a compiler warning. +CFLAGS_helpers.o += -Wno-suggest-attribute=format +# The bpf_stream_vprintk_impl() uses the format string that triggers a compiler warning. +CFLAGS_stream.o += -Wno-suggest-attribute=formatHi Andy,
This flag does not exist in clang:
$ LLVM=1 make -j$(nproc) [...] $ LLVM=1 make CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers DESCEND bpf/resolve_btfids INSTALL libsubcmd_headers CC kernel/trace/bpf_trace.o error: unknown warning option '-Wno-suggest-attribute=format'; did you mean '-Wno-property-attribute-mismatch'? [-Werror,-Wunknown-warning-option] make[4]: *** [scripts/Makefile.build:287: kernel/trace/bpf_trace.o] Error 1 make[3]: *** [scripts/Makefile.build:556: kernel/trace] Error 2 make[2]: *** [scripts/Makefile.build:556: kernel] Error 2 make[1]: *** [/home/isolodrai/kernels/bpf-next/Makefile:2030: .] Error 2 make: *** [Makefile:248: __sub-make] Error 2
Quoted 1 line
We should probably conditionalize the flag addition in the makefile.
Just confirmed that the patch below fixes LLVM=1 build:
From 842b31ff3384df65bb6f13763464daa03ba4f025 Mon Sep 17 00:00:00 2001
From: Ihor Solodrai <[email protected]>
Date: Mon, 15 Dec 2025 16:45:19 -0800
Subject: [PATCH] bpf: Ensure CC is set to GCC for
-Wno-suggest-attribute=format
LLVM=1 kernel build got broken because clang does not have -Wno-suggest-attribute=format option.
Check for CONFIG_CC_IS_GCC before setting this option.
--- kernel/bpf/Makefile | 2 ++ kernel/trace/Makefile | 2 ++ 2 files changed, 4 insertions(+)
kernel/bpf/Makefile +2 -0
@@ -17,8 +17,10 @@ obj-$(CONFIG_BPF_JIT) += trampoline.o obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o stream.o # Disable incorrect warning. bpf printf-like helpers cannot use # gnu_printf attribute. +ifeq ($(CONFIG_CC_IS_GCC),y) CFLAGS_helpers.o += -Wno-suggest-attribute=format CFLAGS_stream.o += -Wno-suggest-attribute=format +endif ifeq ($(CONFIG_MMU)$(CONFIG_64BIT),yy) obj-$(CONFIG_BPF_SYSCALL) += arena.o range_tree.o endif
kernel/trace/Makefile +2 -0
@@ -90,7 +90,9 @@ obj-$(CONFIG_USER_EVENTS) += trace_events_user.o obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o # Disable incorrect warning. bpf printf-like helpers cannot use # gnu_printf attribute. +ifeq ($(CONFIG_CC_IS_GCC),y) CFLAGS_bpf_trace.o += -Wno-suggest-attribute=format +endif obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o
Signature · 1 line
2.47.3
Quoted 9 lines
Or better yet, address the root cause as suggested in the thread.
BPF CI is red on bpf branch at the moment:
https://github.com/kernel-patches/bpf/actions/runs/20243520506/job/58144348281Quoted 2 lines
[...]