Skip to content

Commit f41aa38

Browse files
author
Alexei Starovoitov
committed
Merge branch 'selftest-makefile-cleanup'
Andrii Nakryiko says: ==================== Fix issues with bpf_helper_defs.h usage in selftests/bpf. As part of that, fix the way clean up is performed for libbpf and selftests/bpf. Some for Makefile output clean ups as well. ==================== Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents 492ab02 + 965b9fe commit f41aa38

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

tools/lib/bpf/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@ config-clean:
273273
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
274274

275275
clean:
276-
$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \
277-
*.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \
278-
*.pc LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \
279-
$(SHARED_OBJDIR) $(STATIC_OBJDIR)
276+
$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \
277+
*~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \
278+
$(SHARED_OBJDIR) $(STATIC_OBJDIR) \
279+
$(addprefix $(OUTPUT), \
280+
*.o *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) *.pc)
280281
$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
281282

282283

tools/lib/bpf/bpf_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef __BPF_HELPERS__
33
#define __BPF_HELPERS__
44

5-
#include "bpf_helper_defs.h"
5+
#include <bpf_helper_defs.h>
66

77
#define __uint(name, val) int (*name)[val]
88
#define __type(name, val) typeof(val) *name

tools/testing/selftests/bpf/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ get_cgroup_id_user
2222
test_skb_cgroup_id_user
2323
test_socket_cookie
2424
test_cgroup_storage
25-
test_select_reuseport
2625
test_flow_dissector
2726
flow_dissector_load
2827
test_netcnt
29-
test_section_names
3028
test_tcpnotify_user
3129
test_libbpf
3230
test_tcp_check_syncookie_user

tools/testing/selftests/bpf/Makefile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ CLANG ?= clang
2020
LLC ?= llc
2121
LLVM_OBJCOPY ?= llvm-objcopy
2222
BPF_GCC ?= $(shell command -v bpf-gcc;)
23-
CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \
24-
-I$(GENDIR) -I$(TOOLSINCDIR) -I$(CURDIR) \
23+
CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(CURDIR) -I$(APIDIR) -I$(LIBDIR) \
24+
-I$(BPFDIR) -I$(GENDIR) -I$(TOOLSINCDIR) \
2525
-Dbpf_prog_load=bpf_prog_test_load \
2626
-Dbpf_load_program=bpf_test_load_program
2727
LDLIBS += -lcap -lelf -lz -lrt -lpthread
@@ -83,16 +83,20 @@ TEST_CUSTOM_PROGS = urandom_read
8383
# $3 - target (assumed to be file); only file name will be emitted;
8484
# $4 - optional extra arg, emitted as-is, if provided.
8585
ifeq ($(V),1)
86+
Q =
8687
msg =
8788
else
89+
Q = @
8890
msg = @$(info $(1)$(if $(2), [$(2)]) $(notdir $(3)))$(if $(4), $(4))
91+
MAKEFLAGS += --no-print-directory
8992
endif
9093

9194
# override lib.mk's default rules
9295
OVERRIDE_TARGETS := 1
9396
override define CLEAN
9497
$(call msg, CLEAN)
9598
$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
99+
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ clean
96100
endef
97101

98102
include ../lib.mk
@@ -146,14 +150,14 @@ DEFAULT_BPFTOOL := $(OUTPUT)/tools/usr/local/sbin/bpftool
146150
BPFTOOL ?= $(DEFAULT_BPFTOOL)
147151

148152
$(DEFAULT_BPFTOOL): force
149-
$(MAKE) -C $(BPFTOOLDIR) DESTDIR=$(OUTPUT)/tools install
153+
$(Q)$(MAKE) -C $(BPFTOOLDIR) DESTDIR=$(OUTPUT)/tools install
150154

151155
$(BPFOBJ): force
152-
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
156+
$(Q)$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
153157

154158
BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h)
155-
$(OUTPUT)/bpf_helper_defs.h:
156-
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h
159+
$(OUTPUT)/bpf_helper_defs.h: $(BPFOBJ)
160+
$(Q)$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h
157161

158162
# Get Clang's default includes on this system, as opposed to those seen by
159163
# '-target bpf'. This fixes "missing" files on some architectures/distros,
@@ -173,8 +177,8 @@ MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
173177

174178
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
175179
BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \
176-
-I. -I./include/uapi -I$(APIDIR) \
177-
-I$(BPFDIR) -I$(abspath $(OUTPUT)/../usr/include)
180+
-I$(OUTPUT) -I$(CURDIR) -I$(CURDIR)/include/uapi \
181+
-I$(APIDIR) -I$(BPFDIR) -I$(abspath $(OUTPUT)/../usr/include)
178182

179183
CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
180184
-Wno-compare-distinct-pointer-types
@@ -252,6 +256,7 @@ define DEFINE_TEST_RUNNER_RULES
252256
ifeq ($($(TRUNNER_OUTPUT)-dir),)
253257
$(TRUNNER_OUTPUT)-dir := y
254258
$(TRUNNER_OUTPUT):
259+
$$(call msg, MKDIR,,$$@)
255260
mkdir -p $$@
256261
endif
257262

@@ -328,7 +333,7 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \
328333
TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \
329334
$(wildcard progs/btf_dump_test_case_*.c)
330335
TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
331-
TRUNNER_BPF_CFLAGS := -I. -I$(OUTPUT) $(BPF_CFLAGS) $(CLANG_CFLAGS)
336+
TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
332337
TRUNNER_BPF_LDFLAGS := -mattr=+alu32
333338
$(eval $(call DEFINE_TEST_RUNNER,test_progs))
334339

@@ -377,5 +382,5 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
377382

378383
EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) \
379384
prog_tests/tests.h map_tests/tests.h verifier/tests.h \
380-
feature $(OUTPUT)/*.o $(OUTPUT)/no_alu32 $(OUTPUT)/bpf_gcc \
381-
tools *.skel.h
385+
feature \
386+
$(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc tools)

0 commit comments

Comments
 (0)