Skip to content

Commit e01a75c

Browse files
anakryikoborkmann
authored andcommitted
libbpf: Move bpf_{helpers, helper_defs, endian, tracing}.h into libbpf
Move bpf_helpers.h, bpf_tracing.h, and bpf_endian.h into libbpf. Move bpf_helper_defs.h generation into libbpf's Makefile. Ensure all those headers are installed along the other libbpf headers. Also, adjust selftests and samples include path to include libbpf now. Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 3ac4dbe commit e01a75c

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

samples/bpf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
282282
$(obj)/%.o: $(src)/%.c
283283
@echo " CLANG-bpf " $@
284284
$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
285-
-I$(srctree)/tools/testing/selftests/bpf/ \
285+
-I$(srctree)/tools/testing/selftests/bpf/ -I$(srctree)/tools/lib/bpf/ \
286286
-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
287287
-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
288288
-Wno-gnu-variable-sized-type-not-at-end \

tools/lib/bpf/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ libbpf.so.*
66
TAGS
77
tags
88
cscope.*
9+
/bpf_helper_defs.h

tools/lib/bpf/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ all: fixdep
157157

158158
all_cmd: $(CMD_TARGETS) check
159159

160-
$(BPF_IN): force elfdep bpfdep
160+
$(BPF_IN): force elfdep bpfdep bpf_helper_defs.h
161161
@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
162162
(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
163163
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
@@ -175,6 +175,10 @@ $(BPF_IN): force elfdep bpfdep
175175
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true
176176
$(Q)$(MAKE) $(build)=libbpf
177177

178+
bpf_helper_defs.h: $(srctree)/include/uapi/linux/bpf.h
179+
$(Q)$(srctree)/scripts/bpf_helpers_doc.py --header \
180+
--file $(srctree)/include/uapi/linux/bpf.h > bpf_helper_defs.h
181+
178182
$(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION)
179183

180184
$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN)
@@ -236,13 +240,17 @@ install_lib: all_cmd
236240
$(call do_install_mkdir,$(libdir_SQ)); \
237241
cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
238242

239-
install_headers:
243+
install_headers: bpf_helper_defs.h
240244
$(call QUIET_INSTALL, headers) \
241245
$(call do_install,bpf.h,$(prefix)/include/bpf,644); \
242246
$(call do_install,libbpf.h,$(prefix)/include/bpf,644); \
243247
$(call do_install,btf.h,$(prefix)/include/bpf,644); \
244248
$(call do_install,libbpf_util.h,$(prefix)/include/bpf,644); \
245-
$(call do_install,xsk.h,$(prefix)/include/bpf,644);
249+
$(call do_install,xsk.h,$(prefix)/include/bpf,644); \
250+
$(call do_install,bpf_helpers.h,$(prefix)/include/bpf,644); \
251+
$(call do_install,bpf_helper_defs.h,$(prefix)/include/bpf,644); \
252+
$(call do_install,bpf_tracing.h,$(prefix)/include/bpf,644); \
253+
$(call do_install,bpf_endian.h,$(prefix)/include/bpf,644);
246254

247255
install_pkgconfig: $(PC_FILE)
248256
$(call QUIET_INSTALL, $(PC_FILE)) \
@@ -259,7 +267,7 @@ config-clean:
259267
clean:
260268
$(call QUIET_CLEAN, libbpf) $(RM) $(TARGETS) $(CXX_TEST_TARGET) \
261269
*.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \
262-
*.pc LIBBPF-CFLAGS
270+
*.pc LIBBPF-CFLAGS bpf_helper_defs.h
263271
$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
264272

265273

File renamed without changes.

tools/testing/selftests/bpf/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ libbpf.so.*
3939
test_hashmap
4040
test_btf_dump
4141
xdping
42-
/bpf_helper_defs.h

tools/testing/selftests/bpf/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ include ../lib.mk
9090
TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
9191
all: $(TEST_CUSTOM_PROGS)
9292

93-
bpf_helper_defs.h: $(APIDIR)/linux/bpf.h
94-
$(BPFDIR)/../../../scripts/bpf_helpers_doc.py --header \
95-
--file $(APIDIR)/linux/bpf.h > bpf_helper_defs.h
96-
9793
$(OUTPUT)/urandom_read: $(OUTPUT)/%: %.c
9894
$(CC) -o $@ $< -Wl,--build-id
9995

@@ -127,7 +123,7 @@ $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
127123
# force a rebuild of BPFOBJ when its dependencies are updated
128124
force:
129125

130-
$(BPFOBJ): force bpf_helper_defs.h
126+
$(BPFOBJ): force
131127
$(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
132128

133129
PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)
@@ -152,7 +148,7 @@ $(shell $(1) -v -E - </dev/null 2>&1 \
152148
endef
153149
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
154150
BPF_CFLAGS = -I. -I./include/uapi -I../../../include/uapi \
155-
-I$(OUTPUT)/../usr/include -D__TARGET_ARCH_$(SRCARCH)
151+
-I$(BPFDIR) -I$(OUTPUT)/../usr/include -D__TARGET_ARCH_$(SRCARCH)
156152

157153
CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
158154
-Wno-compare-distinct-pointer-types
@@ -323,4 +319,4 @@ $(VERIFIER_TESTS_H): $(VERIFIER_TEST_FILES) | $(VERIFIER_TESTS_DIR)
323319

324320
EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(ALU32_BUILD_DIR) $(BPF_GCC_BUILD_DIR) \
325321
$(VERIFIER_TESTS_H) $(PROG_TESTS_H) $(MAP_TESTS_H) \
326-
feature bpf_helper_defs.h
322+
feature

0 commit comments

Comments
 (0)