Re: [PATCH 2/2] perf build: Add -Wno-missing-declarations for GEN_VMLINUX_H=1
Namhyung Kim <[email protected]>
| Newsgroups | dev.linux.lists.sashiko,org.kernel.vger.linux-perf-users |
|---|---|
| Message-ID | <[email protected]> |
Hi Sashiko! ;-) On Wed, Apr 08, 2026 at 06:00:17AM +0000, [email protected] wrote: > Sashiko AI review found 1 potential issue(s): > - [Medium] Suppressing the missing-declarations warning instead of enabling Microsoft extensions causes Clang to silently drop anonymous fields from structures in `vmlinux.h`. > -- > > commit 93aff8b1d8d6d53f0451d4c78852fef0b06314df > Author: Namhyung Kim <[email protected]> > > perf build: Add -Wno-missing-declarations for GEN_VMLINUX_H=1 > > This commit suppresses the missing-declarations warning by adding > -Wno-missing-declarations when compiling BPF skeletons in perf. > > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > > --- a/tools/perf/Makefile.perf > > +++ b/tools/perf/Makefile.perf > > @@ -1249,7 +1249,7 @@ $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h > > $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \ > > $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ > > -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \ > > - -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ > > + -Wno-missing-declarations -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ > > Does suppressing this warning instead of enabling Microsoft extensions cause > Clang to silently drop anonymous fields from structures in vmlinux.h? > > bpftool generates anonymous structs in vmlinux.h using a Microsoft extension. > Without -fms-extensions, standard C treats these as empty forward declarations. > Clang ignores them, effectively removing them from the struct layout and > altering the structure's size and offsets. > > By passing -Wno-missing-declarations instead of enabling the extension, could > this hide the layout corruption? Any perf BPF programs relying on the size of > such structs or performing non-CO-RE offset calculations might compute > incorrect values, leading to verifier rejections or incorrect tracing > statistics. > > Would it be better to pass -fms-extensions and -Wno-microsoft-anon-tag to > properly support this in Clang, mirroring the fix applied to BPF selftests in > commit 835a50753579a? Oh, it's good to know that there is a fix for that. For some reason, I cannot reproduce it anynmore. But it'd be fine to have this fix anyway. Thanhks, Namhyung > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2