Skip to contentSkip to conversation

perf build: Always disable stack protection for BPF skeleton objects

PATCH Applied Federico Pellegrin 2 participants 2 messages Jul 18, 2025 – Jul 23, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf build: Always disable stack protection for BPF skeleton objects

When the clang toolchain has stack protection enabled, the bpf skeletons build fails with:

error: A call to built-in function '__stack_chk_fail' is not supported.

Since stack-protector makes no sense for the BPF bits, just unconditionally disable it.

See also similar case at 878625e1c7a10dfbb1fdaaaae2c4d2a58fbce627

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index d4c7031b01a7..ca7dc65a3182 100644
@@ -1251,7 +1251,7 @@ else
 endif
 
 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
-	$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
+	$(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
 	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
 
 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw

Hello,

Quoted 11 lines · Federico Pellegrin

When the clang toolchain has stack protection enabled, the bpf skeletons build fails with:

error: A call to built-in function '__stack_chk_fail' is not supported.

Since stack-protector makes no sense for the BPF bits, just unconditionally disable it.

See also similar case at 878625e1c7a10dfbb1fdaaaae2c4d2a58fbce627

Applied to perf-tools-next with minor updates.

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index d4c7031b01a7..ca7dc65a3182 100644
@@ -1251,7 +1251,7 @@ else
 endif
 
 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
-	$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
+	$(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
 	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
 
 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
Signature · 1 line
2.50.1