From 12aa64bbce1247d24f410843e2b71dbc8316e3e7 Mon Sep 17 00:00:00 2001 From: Eva Kurchatova Date: Fri, 25 Sep 2026 18:49:19 +0300 Subject: [PATCH] samples/bpf: Build the BPF programs with -fms-extensions Commit 835a50753579 ("selftests/bpf: Add -fms-extensions to bpf build flags") gave the selftests the flag because the kernel is built with it, and the generated vmlinux.h carries anonymous members declared by tag: struct slab { ... struct freelist_counters; }; samples/bpf did not get it. clang without the flag reads such a line as a declaration that declares nothing, one warning per line for every sample that includes vmlinux.h: ./vmlinux.h:34528:3: warning: declaration does not declare anything [-Wmissing-declarations] and lays the struct out without the member, so the BTF of the object describes a struct the kernel does not have, and a program that touches the member does not build at all. Add the flag, and -Wno-microsoft-anon-tag with it, the way the selftests do. Signed-off-by: Eva Kurchatova Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20260925154937.3677406-1-eva.kurchatova@virtuozzo.com --- samples/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 95a4fa1f1e44..c28e65046986 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -342,6 +342,7 @@ $(obj)/xdp_router_ipv4.bpf.o: $(obj)/xdp_sample.bpf.o $(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/xdp_sample_shared.h @echo " CLANG-BPF " $@ $(Q)$(CLANG) -g -O2 --target=bpf -D__TARGET_ARCH_$(SRCARCH) \ + -fms-extensions -Wno-microsoft-anon-tag \ -Wno-compare-distinct-pointer-types -I$(srctree)/include \ -I$(srctree)/samples/bpf -I$(srctree)/tools/include \ -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \