[Devel] [PATCH vz10 1/2] samples/bpf: fix -Wduplicate-decl-specifier and -Wmissing-declarations

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 12 15:26:39 MSK 2026


On 5/7/26 17:58, Eva Kurchatova wrote:
> BPF programs include arch-specific headers, which use address space
> qualifiers for percpu variables via __seg_gs / __seg_fs, however those
> are meaningless for BPF compiler and will raise a warning

Dot is missing.

> 
> Fix this by redefining __seg_gs and __seg_fs to a no-op attribute

Dot is missing.

> 
> Additionally, enable ms-extensions, as generated vmlinux.h uses these
> for structure layout inheritance, an acceptable practice in upstream

Dot i missing.

> 
> https://virtuozzo.atlassian.net/browse/VSTOR-127585
> feature: fix kselftests
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
> ---
>   samples/bpf/Makefile | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 7afe040cf43b..fa92d2494b96 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -363,9 +363,11 @@ CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
>   
>   $(obj)/xdp_router_ipv4.bpf.o: $(obj)/xdp_sample.bpf.o
>   
> +# Generated vmlinux.h uses ms-extensions to inherit struct layout
>   $(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 \

1. ms does not have "-fms-extensions". Why it's not needed there? May be they went another way to fix 
that?
2. Why do we need "-Wno-microsoft-anon-tag" here?
    Does "-fms-extensions" enabled those warnings? If yes, please describe that.
    If no - why to disabled those warnings?


>   		-Wno-compare-distinct-pointer-types -I$(srctree)/include \
>   		-I$(srctree)/samples/bpf -I$(srctree)/tools/include \
>   		-I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \
> @@ -396,11 +398,13 @@ $(BPF_SKELS_LINKED): $(BPF_OBJS_LINKED) $(BPFTOOL)
>   # with native target, e.g., x64, arm64, etc. 'opt' does bpf CORE IR builtin
>   # processing (llvm12) and IR optimizations. 'llvm-dis' converts
>   # 'opt' output to IR, and finally 'llc' generates bpf byte code.
> +# Additionally, __seg_gs and __seg_fs are ignored in BPF code
>   $(obj)/%.o: $(src)/%.c
>   	@echo "  CLANG-bpf " $@
>   	$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
>   		-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
>   		-I$(LIBBPF_INCLUDE) \
> +		-U__seg_gs -D__seg_gs= -U__seg_fs -D__seg_fs= \

Why ms is missing this patch?

>   		-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
>   		-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
>   		-Wno-gnu-variable-sized-type-not-at-end \

AFAIS here we have 2 completely unrelated changes, so please, split the patch into 2 parts.
Or explain why those changes should go together.

In general i would say - let's push such patches to mainstream first and backport them to our kernel 
after they are accepted in mainstream.


More information about the Devel mailing list