File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1057,7 +1057,24 @@ $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_
1057
1057
1058
1058
ifdef BUILD_BPF_SKEL
1059
1059
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)
1061
1078
TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi
1062
1079
1063
1080
$(BPFTOOL): | $(SKEL_TMP_OUT)
You can’t perform that action at this time.
0 commit comments