Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/bpf: Move linux/types.h for selftests and bpftool

Commit fe4eb069edb7 ("bpftool: Use linux/types.h from source tree for
profiler build") added a build dependency on tools/testing/selftests/bpf
to tools/bpf/bpftool. This is suboptimal with respect to a possible
stand-alone build of bpftool.

Fix this by moving tools/testing/selftests/bpf/include/uapi/linux/types.h
to tools/include/uapi/linux/types.h.

This requires an adjustment in the include search path order for the
tests in tools/testing/selftests/bpf so that tools/include/linux/types.h
is selected when building host binaries and
tools/include/uapi/linux/types.h is selected when building bpf binaries.

Verified by compiling bpftool and the bpf selftests on x86_64 with this
change.

Fixes: fe4eb069edb7 ("bpftool: Use linux/types.h from source tree for profiler build")
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20200313113105.6918-1-tklauser@distanz.ch

authored by

Tobias Klauser and committed by
Daniel Borkmann
bcd66b10 dcce11d5

+4 -4
-1
tools/bpf/bpftool/Makefile
··· 129 129 skeleton/profiler.bpf.o: skeleton/profiler.bpf.c $(LIBBPF) 130 130 $(QUIET_CLANG)$(CLANG) \ 131 131 -I$(srctree)/tools/include/uapi/ \ 132 - -I$(srctree)/tools/testing/selftests/bpf/include/uapi \ 133 132 -I$(LIBBPF_PATH) -I$(srctree)/tools/lib \ 134 133 -g -O2 -target bpf -c $< -o $@ 135 134
+4 -3
tools/testing/selftests/bpf/Makefile
··· 20 20 LLC ?= llc 21 21 LLVM_OBJCOPY ?= llvm-objcopy 22 22 BPF_GCC ?= $(shell command -v bpf-gcc;) 23 - CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) -I$(CURDIR) -I$(APIDIR) \ 23 + CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) -I$(CURDIR) \ 24 24 -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) -I$(TOOLSINCDIR) \ 25 + -I$(APIDIR) \ 25 26 -Dbpf_prog_load=bpf_prog_test_load \ 26 27 -Dbpf_load_program=bpf_test_load_program 27 28 LDLIBS += -lcap -lelf -lz -lrt -lpthread ··· 195 194 196 195 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG)) 197 196 BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ 198 - -I$(INCLUDE_DIR) -I$(CURDIR) -I$(CURDIR)/include/uapi \ 199 - -I$(APIDIR) -I$(abspath $(OUTPUT)/../usr/include) 197 + -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \ 198 + -I$(abspath $(OUTPUT)/../usr/include) 200 199 201 200 CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \ 202 201 -Wno-compare-distinct-pointer-types
tools/testing/selftests/bpf/include/uapi/linux/types.h tools/include/uapi/linux/types.h