Skip to contentSkip to conversation

perf build: Update error message for BUILD_NONDISTRO=1

PATCH Superseded Namhyung Kim 3 participants 5 messages Apr 8 – Apr 10

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/2 perf build: Update error message for BUILD_NONDISTRO=1

It should say binutils-dev(el) instead of plain binutils package as it's mostly installed already and can confuse people like me. :)

---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
index e6686641761fd0bf..ad5401eb720e9e78 100644
@@ -923,7 +923,7 @@ ifdef BUILD_NONDISTRO
   $(call feature_check,libbfd-liberty-z)
 
   ifneq ($(feature-libbfd-threadsafe), 1)
-    $(error binutils 2.42 or later is required for non-distro builds)
+    $(error binutils-dev(el) 2.42 or later is required for non-distro builds)
   endif
 
   # we may be on a system that requires -liberty and (maybe) -lz
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 2/2 perf build: Add -Wno-missing-declarations for GEN_VMLINUX_H=1

On my system, make GEN_VMLINUX_H=1 fails with a lot of error messages like below:

./util/bpf_skel/vmlinux.h:134488:4: error: declaration does not declare anything [-Werror,-Wmissing-declarations]

   134488 |                         struct freelist_counters;
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~

make[2]: *** [Makefile.perf:1249: linux/tools/perf/util/bpf_skel/.tmp/lock_contention.bpf.o] Error 1

It seems clang doesn't like forward declarations in the current setting. Let's suppress the warning by adding the no warning flags.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index cee19c923c0607d2..a41e0dd34d8df660 100644
@@ -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 $@
 
 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
 	$(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 2/2] perf build: Add -Wno-missing-declarations for GEN_VMLINUX_H=1

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…

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.

tools/perf/Makefile.perf $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h · line 1252

Quoted 9 lines
tools/perf/Makefile.perf +1 -1
@@ -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?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#3 lore raw

Re: [PATCH 2/2] perf build: Add -Wno-missing-declarations for GEN_VMLINUX_H=1

Hi Sashiko! ;-)

Quoted 36 lines · 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.

tools/perf/Makefile.perf $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h · line 1252

Quoted 9 lines
tools/perf/Makefile.perf +1 -1
@@ -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.

Quoted 3 lines

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

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
reviewer Reviewed-by on v1 1/2
#4 lore raw
In reply to Namhyung Kim
Quoted 5 lines · Namhyung Kim

It should say binutils-dev(el) instead of plain binutils package as it's mostly installed already and can confuse people like me. :)

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -2
index e6686641761fd0bf..ad5401eb720e9e78 100644
@@ -923,7 +923,7 @@ ifdef BUILD_NONDISTRO
   $(call feature_check,libbfd-liberty-z)
 
   ifneq ($(feature-libbfd-threadsafe), 1)
-    $(error binutils 2.42 or later is required for non-distro builds)
+    $(error binutils-dev(el) 2.42 or later is required for non-distro builds)
   endif
 
   # we may be on a system that requires -liberty and (maybe) -lz
--

2.53.0