mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
41757dcb0c
The current selftests Makefile construct result in cgroup_helpers.c gets compiled together with all the TEST_GEN_PROGS. And it also result in invoking the libbpf Makefile two times (tools/lib/bpf). These issues were introduced in commit9d1f159419
("bpf: move cgroup_helpers from samples/bpf/ to tools/testing/selftesting/bpf/"). The only test program that requires the cgroup helpers is 'test_dev_cgroup'. Thus, create a make target $(OUTPUT)/test_dev_cgroup that extend[1] the 'prerequisite' for the 'stem' %-style pattern in ../lib.mk, for this particular test program. Reviewers notice the make-rules in tools/testing/selftests/lib.mk differ from the normal kernel kbuild rules, and it is practical to use 'make -p' to follow how these 'Implicit/static pattern stem' gets expanded. [1] https://www.gnu.org/software/make/manual/html_node/Static-Usage.html Fixes:9d1f159419
("bpf: move cgroup_helpers from samples/bpf/ to tools/testing/selftesting/bpf/") Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
77 lines
2.1 KiB
Makefile
77 lines
2.1 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
LIBDIR := ../../../lib
|
|
BPFDIR := $(LIBDIR)/bpf
|
|
APIDIR := ../../../include/uapi
|
|
GENDIR := ../../../../include/generated
|
|
GENHDR := $(GENDIR)/autoconf.h
|
|
|
|
ifneq ($(wildcard $(GENHDR)),)
|
|
GENFLAGS := -DHAVE_GENHDR
|
|
endif
|
|
|
|
CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
|
|
LDLIBS += -lcap -lelf -lrt -lpthread
|
|
|
|
# Order correspond to 'make run_tests' order
|
|
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
|
|
test_align test_verifier_log test_dev_cgroup test_tcpbpf_user
|
|
|
|
TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \
|
|
test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \
|
|
sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o test_tracepoint.o \
|
|
test_l4lb_noinline.o test_xdp_noinline.o test_stacktrace_map.o \
|
|
sample_map_ret0.o test_tcpbpf_kern.o
|
|
|
|
# Order correspond to 'make run_tests' order
|
|
TEST_PROGS := test_kmod.sh \
|
|
test_libbpf.sh \
|
|
test_xdp_redirect.sh \
|
|
test_xdp_meta.sh \
|
|
test_offload.py
|
|
|
|
# Compile but not part of 'make run_tests'
|
|
TEST_GEN_PROGS_EXTENDED = test_libbpf_open
|
|
|
|
include ../lib.mk
|
|
|
|
BPFOBJ := $(OUTPUT)/libbpf.a
|
|
|
|
$(TEST_GEN_PROGS): $(BPFOBJ)
|
|
|
|
$(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/libbpf.a
|
|
|
|
$(OUTPUT)/test_dev_cgroup: cgroup_helpers.c
|
|
|
|
.PHONY: force
|
|
|
|
# force a rebuild of BPFOBJ when its dependencies are updated
|
|
force:
|
|
|
|
$(BPFOBJ): force
|
|
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
|
|
|
|
CLANG ?= clang
|
|
LLC ?= llc
|
|
|
|
PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
|
|
|
|
# Let newer LLVM versions transparently probe the kernel for availability
|
|
# of full BPF instruction set.
|
|
ifeq ($(PROBE),)
|
|
CPU ?= probe
|
|
else
|
|
CPU ?= generic
|
|
endif
|
|
|
|
CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
|
|
-Wno-compare-distinct-pointer-types
|
|
|
|
$(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline
|
|
$(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline
|
|
|
|
$(OUTPUT)/%.o: %.c
|
|
$(CLANG) $(CLANG_FLAGS) \
|
|
-O2 -target bpf -emit-llvm -c $< -o - | \
|
|
$(LLC) -march=bpf -mcpu=$(CPU) -filetype=obj -o $@
|