Commit f41aa387 authored by Alexei Starovoitov's avatar Alexei Starovoitov

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: default avatarAlexei Starovoitov <ast@kernel.org>
parents 492ab020 965b9fee
...@@ -273,10 +273,11 @@ config-clean: ...@@ -273,10 +273,11 @@ config-clean:
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
clean: clean:
$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \ $(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \
*.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \ *~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \
*.pc LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \ $(SHARED_OBJDIR) $(STATIC_OBJDIR) \
$(SHARED_OBJDIR) $(STATIC_OBJDIR) $(addprefix $(OUTPUT), \
*.o *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) *.pc)
$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ifndef __BPF_HELPERS__ #ifndef __BPF_HELPERS__
#define __BPF_HELPERS__ #define __BPF_HELPERS__
#include "bpf_helper_defs.h" #include <bpf_helper_defs.h>
#define __uint(name, val) int (*name)[val] #define __uint(name, val) int (*name)[val]
#define __type(name, val) typeof(val) *name #define __type(name, val) typeof(val) *name
......
...@@ -22,11 +22,9 @@ get_cgroup_id_user ...@@ -22,11 +22,9 @@ get_cgroup_id_user
test_skb_cgroup_id_user test_skb_cgroup_id_user
test_socket_cookie test_socket_cookie
test_cgroup_storage test_cgroup_storage
test_select_reuseport
test_flow_dissector test_flow_dissector
flow_dissector_load flow_dissector_load
test_netcnt test_netcnt
test_section_names
test_tcpnotify_user test_tcpnotify_user
test_libbpf test_libbpf
test_tcp_check_syncookie_user test_tcp_check_syncookie_user
......
...@@ -20,8 +20,8 @@ CLANG ?= clang ...@@ -20,8 +20,8 @@ CLANG ?= clang
LLC ?= llc LLC ?= llc
LLVM_OBJCOPY ?= llvm-objcopy LLVM_OBJCOPY ?= llvm-objcopy
BPF_GCC ?= $(shell command -v bpf-gcc;) BPF_GCC ?= $(shell command -v bpf-gcc;)
CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(CURDIR) -I$(APIDIR) -I$(LIBDIR) \
-I$(GENDIR) -I$(TOOLSINCDIR) -I$(CURDIR) \ -I$(BPFDIR) -I$(GENDIR) -I$(TOOLSINCDIR) \
-Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_prog_load=bpf_prog_test_load \
-Dbpf_load_program=bpf_test_load_program -Dbpf_load_program=bpf_test_load_program
LDLIBS += -lcap -lelf -lz -lrt -lpthread LDLIBS += -lcap -lelf -lz -lrt -lpthread
...@@ -83,9 +83,12 @@ TEST_CUSTOM_PROGS = urandom_read ...@@ -83,9 +83,12 @@ TEST_CUSTOM_PROGS = urandom_read
# $3 - target (assumed to be file); only file name will be emitted; # $3 - target (assumed to be file); only file name will be emitted;
# $4 - optional extra arg, emitted as-is, if provided. # $4 - optional extra arg, emitted as-is, if provided.
ifeq ($(V),1) ifeq ($(V),1)
Q =
msg = msg =
else else
Q = @
msg = @$(info $(1)$(if $(2), [$(2)]) $(notdir $(3)))$(if $(4), $(4)) msg = @$(info $(1)$(if $(2), [$(2)]) $(notdir $(3)))$(if $(4), $(4))
MAKEFLAGS += --no-print-directory
endif endif
# override lib.mk's default rules # override lib.mk's default rules
...@@ -93,6 +96,7 @@ OVERRIDE_TARGETS := 1 ...@@ -93,6 +96,7 @@ OVERRIDE_TARGETS := 1
override define CLEAN override define CLEAN
$(call msg, CLEAN) $(call msg, CLEAN)
$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN) $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ clean
endef endef
include ../lib.mk include ../lib.mk
...@@ -146,14 +150,14 @@ DEFAULT_BPFTOOL := $(OUTPUT)/tools/usr/local/sbin/bpftool ...@@ -146,14 +150,14 @@ DEFAULT_BPFTOOL := $(OUTPUT)/tools/usr/local/sbin/bpftool
BPFTOOL ?= $(DEFAULT_BPFTOOL) BPFTOOL ?= $(DEFAULT_BPFTOOL)
$(DEFAULT_BPFTOOL): force $(DEFAULT_BPFTOOL): force
$(MAKE) -C $(BPFTOOLDIR) DESTDIR=$(OUTPUT)/tools install $(Q)$(MAKE) -C $(BPFTOOLDIR) DESTDIR=$(OUTPUT)/tools install
$(BPFOBJ): force $(BPFOBJ): force
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(Q)$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h) BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h)
$(OUTPUT)/bpf_helper_defs.h: $(OUTPUT)/bpf_helper_defs.h: $(BPFOBJ)
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h $(Q)$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h
# Get Clang's default includes on this system, as opposed to those seen by # Get Clang's default includes on this system, as opposed to those seen by
# '-target bpf'. This fixes "missing" files on some architectures/distros, # '-target bpf'. This fixes "missing" files on some architectures/distros,
...@@ -173,8 +177,8 @@ MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian) ...@@ -173,8 +177,8 @@ MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG)) CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \
-I. -I./include/uapi -I$(APIDIR) \ -I$(OUTPUT) -I$(CURDIR) -I$(CURDIR)/include/uapi \
-I$(BPFDIR) -I$(abspath $(OUTPUT)/../usr/include) -I$(APIDIR) -I$(BPFDIR) -I$(abspath $(OUTPUT)/../usr/include)
CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \ CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
-Wno-compare-distinct-pointer-types -Wno-compare-distinct-pointer-types
...@@ -252,6 +256,7 @@ define DEFINE_TEST_RUNNER_RULES ...@@ -252,6 +256,7 @@ define DEFINE_TEST_RUNNER_RULES
ifeq ($($(TRUNNER_OUTPUT)-dir),) ifeq ($($(TRUNNER_OUTPUT)-dir),)
$(TRUNNER_OUTPUT)-dir := y $(TRUNNER_OUTPUT)-dir := y
$(TRUNNER_OUTPUT): $(TRUNNER_OUTPUT):
$$(call msg, MKDIR,,$$@)
mkdir -p $$@ mkdir -p $$@
endif endif
...@@ -328,7 +333,7 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \ ...@@ -328,7 +333,7 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \
TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \ TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \
$(wildcard progs/btf_dump_test_case_*.c) $(wildcard progs/btf_dump_test_case_*.c)
TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
TRUNNER_BPF_CFLAGS := -I. -I$(OUTPUT) $(BPF_CFLAGS) $(CLANG_CFLAGS) TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
TRUNNER_BPF_LDFLAGS := -mattr=+alu32 TRUNNER_BPF_LDFLAGS := -mattr=+alu32
$(eval $(call DEFINE_TEST_RUNNER,test_progs)) $(eval $(call DEFINE_TEST_RUNNER,test_progs))
...@@ -377,5 +382,5 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ) ...@@ -377,5 +382,5 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) \ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) \
prog_tests/tests.h map_tests/tests.h verifier/tests.h \ prog_tests/tests.h map_tests/tests.h verifier/tests.h \
feature $(OUTPUT)/*.o $(OUTPUT)/no_alu32 $(OUTPUT)/bpf_gcc \ feature \
tools *.skel.h $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc tools)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment