Skip to contentSkip to conversation

tools/build: Use SYSTEM_BPFTOOL for system bpftool

PATCH Applied Tomas Glozar 5 participants 5 messages Mar 26, 2025 – Mar 30, 2025

Subsystems (3)
lore
Share & tools
lore

Tomas Glozar

author maintainer
#0 lore raw

PATCH 1/1 tools/build: Use SYSTEM_BPFTOOL for system bpftool

The feature test for system bpftool uses BPFTOOL as the variable to set its path, defaulting to just "bpftool" if not set by the user.

This conflicts with selftests and a few other utilities, which expect BPFTOOL to be set to the in-tree bpftool path by default. For example, bpftool selftests fail to build:

$ make -C tools/testing/selftests/bpf/
make: Entering directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

make: *** No rule to make target 'bpftool', needed by '/home/tglozar/dev/linux/tools/testing/selftests/bpf/tools/include/vmlinux.h'. Stop.
make: Leaving directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

Fix the problem by renaming the variable used for system bpftool from BPFTOOL to SYSTEM_BPFTOOL, so that the new usage does not conflict with the existing one of BPFTOOL.

Fixes 8a635c3856dd ("tools/build: Add bpftool-skeletons feature test")
---
 tools/build/feature/Makefile   | 2 +-
 tools/scripts/Makefile.include | 2 +-
 tools/tracing/rtla/Makefile    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/build/feature/Makefile +1 -1
index 4f9c1d950f5d..b8b5fb183dd4 100644
@@ -419,7 +419,7 @@ $(OUTPUT)test-libpfm4.bin:
 	$(BUILD) -lpfm
 
 $(OUTPUT)test-bpftool-skeletons.bin:
-	$(BPFTOOL) version | grep '^features:.*skeletons' \
+	$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
 		> $(@:.bin=.make.output) 2>&1
 ###############################
 
tools/scripts/Makefile.include +1 -1
index 6268534309aa..5158250988ce 100644
@@ -92,7 +92,7 @@ LLVM_OBJCOPY	?= llvm-objcopy
 LLVM_STRIP	?= llvm-strip
 
 # Some tools require bpftool
-BPFTOOL		?= bpftool
+SYSTEM_BPFTOOL	?= bpftool
 
 ifeq ($(CC_NO_CLANG), 1)
 EXTRA_WARNINGS += -Wstrict-aliasing=3
tools/tracing/rtla/Makefile +1 -1
index 4cc3017dccaa..746ccf2f5808 100644
@@ -72,7 +72,7 @@ src/timerlat.bpf.o: src/timerlat.bpf.c
 	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
 
 src/timerlat.skel.h: src/timerlat.bpf.o
-	$(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
+	$(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@
 else
 src/timerlat.skel.h:
 	$(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h
Signature · 1 line
2.48.1
Acked-by on v1 1/1
#1 lore raw

2025-03-26 01:40 UTC+0100 ~ Tomas Glozar <[email protected]>

Quoted 13 lines

The feature test for system bpftool uses BPFTOOL as the variable to set its path, defaulting to just "bpftool" if not set by the user.

This conflicts with selftests and a few other utilities, which expect BPFTOOL to be set to the in-tree bpftool path by default. For example, bpftool selftests fail to build:

$ make -C tools/testing/selftests/bpf/
make: Entering directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

make: *** No rule to make target 'bpftool', needed by '/home/tglozar/dev/linux/tools/testing/selftests/bpf/tools/include/vmlinux.h'. Stop.
make: Leaving directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

Quoted 7 lines

Fix the problem by renaming the variable used for system bpftool from BPFTOOL to SYSTEM_BPFTOOL, so that the new usage does not conflict with the existing one of BPFTOOL.

Let's use <[email protected]> if possible, please.

Quoted 2 lines
Fixes 8a635c3856dd ("tools/build: Add bpftool-skeletons feature test")

Looks good, thanks a lot!

maintainer
#2 lore raw
Quoted 6 lines · On Wed, 26 Mar 2025 09:59:12 +0000 Quentin Monnet <[email protected]> wrote:
Quoted 3 lines

Let's use <[email protected]> if possible, please.

Updated.

Quoted 8 lines
Quoted 4 lines
Fixes 8a635c3856dd ("tools/build: Add bpftool-skeletons feature test")

Looks good, thanks a lot!

I added this to my queue.

Thanks everyone.

-- Steve

Tested-by on v1 1/1
#3 lore raw
In reply to Tomas Glozar
Quoted 59 lines · Tomas Glozar

The feature test for system bpftool uses BPFTOOL as the variable to set its path, defaulting to just "bpftool" if not set by the user.

This conflicts with selftests and a few other utilities, which expect BPFTOOL to be set to the in-tree bpftool path by default. For example, bpftool selftests fail to build:

$ make -C tools/testing/selftests/bpf/
make: Entering directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

make: *** No rule to make target 'bpftool', needed by '/home/tglozar/dev/linux/tools/testing/selftests/bpf/tools/include/vmlinux.h'. Stop.
make: Leaving directory '/home/tglozar/dev/linux/tools/testing/selftests/bpf'

Fix the problem by renaming the variable used for system bpftool from BPFTOOL to SYSTEM_BPFTOOL, so that the new usage does not conflict with the existing one of BPFTOOL.

Fixes 8a635c3856dd ("tools/build: Add bpftool-skeletons feature test")
---
  tools/build/feature/Makefile   | 2 +-
  tools/scripts/Makefile.include | 2 +-
  tools/tracing/rtla/Makefile    | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
tools/build/feature/Makefile +1 -1
index 4f9c1d950f5d..b8b5fb183dd4 100644
@@ -419,7 +419,7 @@ $(OUTPUT)test-libpfm4.bin:
  	$(BUILD) -lpfm
 
  $(OUTPUT)test-bpftool-skeletons.bin:
-	$(BPFTOOL) version | grep '^features:.*skeletons' \
+	$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
  		> $(@:.bin=.make.output) 2>&1
  ###############################
 
tools/scripts/Makefile.include +1 -1
index 6268534309aa..5158250988ce 100644
@@ -92,7 +92,7 @@ LLVM_OBJCOPY	?= llvm-objcopy
  LLVM_STRIP	?= llvm-strip
 
  # Some tools require bpftool
-BPFTOOL		?= bpftool
+SYSTEM_BPFTOOL	?= bpftool
 
  ifeq ($(CC_NO_CLANG), 1)
  EXTRA_WARNINGS += -Wstrict-aliasing=3
tools/tracing/rtla/Makefile +0 -0
index 4cc3017dccaa..746ccf2f5808 100644

tools/tracing/rtla/Makefile src/timerlat.bpf.o: src/timerlat.bpf.c · line 78

Quoted 8 lines
tools/tracing/rtla/Makefile +1 -1
@@ -72,7 +72,7 @@ src/timerlat.bpf.o: src/timerlat.bpf.c
  	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
 
  src/timerlat.skel.h: src/timerlat.bpf.o
-	$(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@
+	$(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@
  else
  src/timerlat.skel.h:
  	$(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h

Tested this patch by applying on linux-next20250326 and this patch fixes the reported issue.

Please add below tag.

Regards,

Venkat.

#4 lore raw
In reply to Tomas Glozar
This patch was applied to bpf/bpf-next.git (master) by Steven Rostedt (Google) <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Steven Rostedt (Google) <[email protected]>:

Quoted 8 lines · On Wed, 26 Mar 2025 01:40:18 +0100 you wrote:

The feature test for system bpftool uses BPFTOOL as the variable to set its path, defaulting to just "bpftool" if not set by the user.

This conflicts with selftests and a few other utilities, which expect BPFTOOL to be set to the in-tree bpftool path by default. For example, bpftool selftests fail to build:

[...]

Here is the summary with links:
- tools/build: Use SYSTEM_BPFTOOL for system bpftool

    https://git.kernel.org/bpf/bpf-next/c/814d051ebed4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html