Two fixes for make kselftest TARGETS=bpf
Subsystems (4)
cover Two fixes for make kselftest TARGETS=bpf
While the primary documented way to run BPF tests is by invoking make in tools/testing/selftests/bpf, kselftest documentation implies that make kselftest TARGETS=bpf from the top directory should work as well. This patch series contains two fixes that were neccesary to make it run:
- Patch 1: $(COMPILE.c) -> $(CC) $(CFLAGS) -c
- Patch 2: Add CXX=$(CROSS_COMPILE)g++ default value
Ilya Leoshkevich (2):
tools/bpf: Don't use $(COMPILE.c)
selftests/bpf: Add a default $(CXX) value
tools/bpf/Makefile | 6 +++--- tools/bpf/bpftool/Makefile | 8 ++++---- tools/testing/selftests/bpf/Makefile | 1 + 3 files changed, 8 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.4
PATCH 1/2 tools/bpf: Don't use $(COMPILE.c)
When using make kselftest TARGETS=bpf, tools/bpf is built with MAKEFLAGS=rR, which causes $(COMPILE.c) to be undefined, which in turn causes the build to fail with
CC kselftest/bpf/tools/build/bpftool/map_perf_ring.o/bin/sh: 1: -MMD: not found
Fix by using $(CC) $(CFLAGS) -c instead of $(COMPILE.c).
--- tools/bpf/Makefile | 6 +++--- tools/bpf/bpftool/Makefile | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
tools/bpf/Makefile +3 -3
@@ -64,12 +64,12 @@ $(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l $(QUIET_FLEX)$(LEX) -o $@ $< $(OUTPUT)%.o: $(srctree)/tools/bpf/%.c - $(QUIET_CC)$(COMPILE.c) -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< $(OUTPUT)%.yacc.o: $(OUTPUT)%.yacc.c - $(QUIET_CC)$(COMPILE.c) -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< $(OUTPUT)%.lex.o: $(OUTPUT)%.lex.c - $(QUIET_CC)$(COMPILE.c) -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< PROGS = $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm
tools/bpf/bpftool/Makefile +4 -4
@@ -121,7 +121,7 @@ else endif $(OUTPUT)_prog.o: prog.c - $(QUIET_CC)$(COMPILE.c) -MMD -DBPFTOOL_WITHOUT_SKELETONS -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -DBPFTOOL_WITHOUT_SKELETONS -o $@ $< $(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF) $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
@@ -136,10 +136,10 @@ profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o $(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@ $(OUTPUT)prog.o: prog.c profiler.skel.h - $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c - $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< $(OUTPUT)feature.o: | zdep
@@ -147,7 +147,7 @@ $(OUTPUT)bpftool: $(__OBJS) $(LIBBPF) $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(__OBJS) $(LIBS) $(OUTPUT)%.o: %.c - $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $< + $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< clean: $(LIBBPF)-clean $(call QUIET_CLEAN, bpftool)
Signature · 1 line
2.25.4
PATCH 2/2 selftests/bpf: Add a default $(CXX) value
In reply to Ilya LeoshkevichWhen using make kselftest TARGETS=bpf, tools/bpf is built with MAKEFLAGS=rR, which causes $(CXX) to be undefined, which in turn causes the build to fail with
CXX test_cpp/bin/sh: 2: g: not found
Fix by adding a default $(CXX) value, like tools/build/feature/Makefile already does.
--- tools/testing/selftests/bpf/Makefile | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/Makefile +1 -0
@@ -2,6 +2,7 @@ include ../../../../scripts/Kbuild.include include ../../../scripts/Makefile.arch +CXX ?= $(CROSS_COMPILE)g++ CURDIR := $(abspath .) TOOLSDIR := $(abspath ../../..) LIBDIR := $(TOOLSDIR)/lib
Signature · 1 line
2.25.4
Daniel Borkmann
maintainerQuoted 8 lines · Ilya Leoshkevich
While the primary documented way to run BPF tests is by invoking make in
tools/testing/selftests/bpf, kselftest documentation implies that make kselftest TARGETS=bpf from the top directory should work as well. This patch series contains two fixes that were neccesary to make it run:- Patch 1: $(COMPILE.c) -> $(CC) $(CFLAGS) -c
- Patch 2: Add CXX=$(CROSS_COMPILE)g++ default value
Quoted 8 lines
Ilya Leoshkevich (2):
tools/bpf: Don't use $(COMPILE.c) selftests/bpf: Add a default $(CXX) valuetools/bpf/Makefile | 6 +++--- tools/bpf/bpftool/Makefile | 8 ++++---- tools/testing/selftests/bpf/Makefile | 1 + 3 files changed, 8 insertions(+), 7 deletions(-)
I've tested on x86-64 and arm64 as well, applied, thanks!