Skip to content

Commit 639f58a

Browse files
qmonnetAlexei Starovoitov
authored andcommitted
bpftool: Fix build warnings due to MS extensions
The kernel is now built with -fms-extensions. Anonymous structs or unions permitted by these extensions have been used in several places, and can end up in the generated vmlinux.h file, for example: struct ns_tree { [...] }; [...] struct ns_common { [...] union { struct ns_tree; struct callback_head ns_rcu; }; }; Trying to include this header for compiling a tool may result in build warnings, if the compiler does not expect these extensions. This is the case, for example, with bpftool: In file included from skeleton/pid_iter.bpf.c:3: .../tools/testing/selftests/bpf/tools/build/bpftool/vmlinux.h:64057:3: warning: declaration does not declare anything [-Wmissing-declarations] 64057 | struct ns_tree; | ^~~~~~~~~~~~~~ Fix these build warnings in bpftool by turning on Microsoft extensions when compiling the two BPF programs that rely on vmlinux.h. Reported-by: Alexei Starovoitov <[email protected]> Closes: https://lore.kernel.org/bpf/CAADnVQK9ZkPC7+R5VXKHVdtj8tumpMXm7BTp0u9CoiFLz_aPTg@mail.gmail.com/ Signed-off-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 861111b commit 639f58a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/bpf/bpftool/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ endif
224224

225225
$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
226226
$(QUIET_CLANG)$(CLANG) \
227+
-Wno-microsoft-anon-tag \
228+
-fms-extensions \
227229
-I$(or $(OUTPUT),.) \
228230
-I$(srctree)/tools/include/uapi/ \
229231
-I$(LIBBPF_BOOTSTRAP_INCLUDE) \

0 commit comments

Comments
 (0)