Skip to content

Commit ecdf68e

Browse files
author
Alexei Starovoitov
committed
Merge branch 'bpf-prog-build'
Jiong Wang says: ==================== This set improves bpf object file related rules in selftests Makefile. - tell git to ignore the build dir "alu32". - extend sub-register mode compilation to all bpf object files to give LLVM compiler bpf back-end more exercise. - auto-generate bpf kernel object file list. - relax sub-register mode compilation criteria. v1 -> v2: - rename "kern_progs" to "progs". (Alexei) - spin a new patch to remove build server kernel requirement for sub-register mode compilation (Alexei) - rebase on top of KaFai’s latest "test_sock_fields" patch set. ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents d105fa9 + 64e39ee commit ecdf68e

51 files changed

Lines changed: 12 additions & 34 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tools/testing/selftests/bpf/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ test_netcnt
2929
test_section_names
3030
test_tcpnotify_user
3131
test_libbpf
32+
alu32

‎tools/testing/selftests/bpf/Makefile‎

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,17 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
2525
test_socket_cookie test_cgroup_storage test_select_reuseport test_section_names \
2626
test_netcnt test_tcpnotify_user test_sock_fields
2727

28-
BPF_OBJ_FILES = \
29-
test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \
30-
sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o \
31-
test_tcpnotify_kern.o sample_map_ret0.o test_tcpbpf_kern.o \
32-
sockmap_tcp_msg_prog.o connect4_prog.o connect6_prog.o \
33-
test_btf_haskv.o test_btf_nokv.o test_sockmap_kern.o \
34-
test_tunnel_kern.o test_sockhash_kern.o test_lwt_seg6local.o \
35-
sendmsg4_prog.o sendmsg6_prog.o test_lirc_mode2_kern.o \
36-
get_cgroup_id_kern.o socket_cookie_prog.o test_select_reuseport_kern.o \
37-
test_skb_cgroup_id_kern.o bpf_flow.o netcnt_prog.o test_xdp_vlan.o \
38-
xdp_dummy.o test_map_in_map.o test_spin_lock.o test_map_lock.o \
39-
test_sock_fields_kern.o
40-
41-
# Objects are built with default compilation flags and with sub-register
42-
# code-gen enabled.
43-
BPF_OBJ_FILES_DUAL_COMPILE = \
44-
test_pkt_access.o test_pkt_access.o test_xdp.o test_adjust_tail.o \
45-
test_l4lb.o test_l4lb_noinline.o test_xdp_noinline.o test_tcp_estats.o \
46-
test_obj_id.o test_pkt_md_access.o test_tracepoint.o \
47-
test_stacktrace_map.o test_stacktrace_map.o test_stacktrace_build_id.o \
48-
test_stacktrace_build_id.o test_get_stack_rawtp.o \
49-
test_get_stack_rawtp.o test_tracepoint.o test_sk_lookup_kern.o \
50-
test_queue_map.o test_stack_map.o
51-
52-
TEST_GEN_FILES = $(BPF_OBJ_FILES) $(BPF_OBJ_FILES_DUAL_COMPILE)
53-
54-
# Also test sub-register code-gen if LLVM + kernel both has eBPF v3 processor
55-
# support which is the first version to contain both ALU32 and JMP32
56-
# instructions.
28+
BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
29+
TEST_GEN_FILES = $(BPF_OBJ_FILES)
30+
31+
# Also test sub-register code-gen if LLVM has eBPF v3 processor support which
32+
# contains both ALU32 and JMP32 instructions.
5733
SUBREG_CODEGEN := $(shell echo "int cal(int a) { return a > 0; }" | \
5834
$(CLANG) -target bpf -O2 -emit-llvm -S -x c - -o - | \
59-
$(LLC) -mattr=+alu32 -mcpu=probe 2>&1 | \
35+
$(LLC) -mattr=+alu32 -mcpu=v3 2>&1 | \
6036
grep 'if w')
6137
ifneq ($(SUBREG_CODEGEN),)
62-
TEST_GEN_FILES += $(patsubst %.o,alu32/%.o, $(BPF_OBJ_FILES_DUAL_COMPILE))
38+
TEST_GEN_FILES += $(patsubst %.o,alu32/%.o, $(BPF_OBJ_FILES))
6339
endif
6440

6541
# Order correspond to 'make run_tests' order
@@ -190,7 +166,8 @@ $(ALU32_BUILD_DIR)/test_progs_32: test_progs.c $(ALU32_BUILD_DIR) \
190166
$(CC) $(CFLAGS) -o $(ALU32_BUILD_DIR)/test_progs_32 $< \
191167
trace_helpers.c $(OUTPUT)/libbpf.a $(LDLIBS)
192168

193-
$(ALU32_BUILD_DIR)/%.o: %.c $(ALU32_BUILD_DIR) $(ALU32_BUILD_DIR)/test_progs_32
169+
$(ALU32_BUILD_DIR)/%.o: progs/%.c $(ALU32_BUILD_DIR) \
170+
$(ALU32_BUILD_DIR)/test_progs_32
194171
$(CLANG) $(CLANG_FLAGS) \
195172
-O2 -target bpf -emit-llvm -c $< -o - | \
196173
$(LLC) -march=bpf -mattr=+alu32 -mcpu=$(CPU) $(LLC_FLAGS) \
@@ -202,15 +179,15 @@ endif
202179

203180
# Have one program compiled without "-target bpf" to test whether libbpf loads
204181
# it successfully
205-
$(OUTPUT)/test_xdp.o: test_xdp.c
182+
$(OUTPUT)/test_xdp.o: progs/test_xdp.c
206183
$(CLANG) $(CLANG_FLAGS) \
207184
-O2 -emit-llvm -c $< -o - | \
208185
$(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
209186
ifeq ($(DWARF2BTF),y)
210187
$(BTF_PAHOLE) -J $@
211188
endif
212189

213-
$(OUTPUT)/%.o: %.c
190+
$(OUTPUT)/%.o: progs/%.c
214191
$(CLANG) $(CLANG_FLAGS) \
215192
-O2 -target bpf -emit-llvm -c $< -o - | \
216193
$(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)