Skip to content

Commit a2af0f6

Browse files
captain5050acmel
authored andcommitted
perf build: Add system include paths to BPF builds
There are insufficient headers in tools/include to satisfy building BPF programs and their header dependencies. Add the system include paths from the non-BPF clang compile so that these headers can be found. This code was taken from: tools/testing/selftests/bpf/Makefile Committer notes: Had to adjust the '#ifndef NO_BPF_SKEL' to '#ifdef BUILD_BPF_SKEL' as reverted that build BPF skels by default. Also cope with the addition of -I$(srctree)/tools/include/uapi done by Yang Jihong so that we prefer using the kernel sources headers instead of older ones in the system. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]>, Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: Tom Rix <[email protected]> Cc: Yang Jihong <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5be6cec commit a2af0f6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tools/perf/Makefile.perf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,24 @@ $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_
10571057

10581058
ifdef BUILD_BPF_SKEL
10591059
BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
1060-
BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
1060+
# Get Clang's default includes on this system, as opposed to those seen by
1061+
# '-target bpf'. This fixes "missing" files on some architectures/distros,
1062+
# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
1063+
#
1064+
# Use '-idirafter': Don't interfere with include mechanics except where the
1065+
# build would have failed anyways.
1066+
define get_sys_includes
1067+
$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
1068+
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
1069+
$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
1070+
endef
1071+
1072+
ifneq ($(CROSS_COMPILE),)
1073+
CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
1074+
endif
1075+
1076+
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
1077+
BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES)
10611078
TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi
10621079

10631080
$(BPFTOOL): | $(SKEL_TMP_OUT)

0 commit comments

Comments
 (0)