Skip to contentSkip to conversation

selftests/bpf: Makefile: add includes to fix broken test build

PATCH Superseded Sirio Balmelli 2 participants 2 messages Apr 26, 2018 – Apr 27, 2018

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 selftests/bpf: Makefile: add includes to fix broken test build

several bpf tests fail to build with clang 7.0.0:
...
In file included from ../../../include/uapi/linux/bpf.h:11:
In file included from ./include/uapi/linux/types.h:5:
/usr/include/asm-generic/int-ll64.h:11:10: fatal error: 'asm/bitsperlong.h' file not found

/usr/include/asm-generic/int-ll64.h is from outside the kernel repo, probably a good idea to repoint to -I$(ROOT)/include/uapi. asm/bitsperlong.h is architecture-specific, cater for this with an architecture-specific include -I$(ROOT)/$(ARCH)/include/uapi.

Re-building now yields:
../../../../include/uapi/linux/stddef.h:2:10: fatal error: 'linux/compiler_types.h' file not found

Fix this with -I$(ROOT)/include

---
 tools/testing/selftests/bpf/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +8 -2
index 0b72cc7..6a8cfaf 100644
@@ -80,8 +80,14 @@ else
   CPU ?= generic
 endif
 
-CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
-	      -Wno-compare-distinct-pointer-types
+ARCH := arch/$(subst _64,,$(shell uname -p))
+ROOT :=../../../..
+TOOLS :=../../..
+CLANG_FLAGS = -I. -I./include/uapi \
+	-I$(TOOLS)/include/uapi -I$(TOOLS)/include \
+	-I$(ROOT)/$(ARCH)/include/uapi \
+	-I$(ROOT)/include/uapi -I$(ROOT)/include \
+	-Wno-compare-distinct-pointer-types
 
 $(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline
 $(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 29 lines · Sirio Balmelli

several bpf tests fail to build with clang 7.0.0:
...
In file included from ../../../include/uapi/linux/bpf.h:11:
In file included from ./include/uapi/linux/types.h:5:
/usr/include/asm-generic/int-ll64.h:11:10: fatal error: 'asm/bitsperlong.h' file not found

/usr/include/asm-generic/int-ll64.h is from outside the kernel repo, probably a good idea to repoint to -I$(ROOT)/include/uapi. asm/bitsperlong.h is architecture-specific, cater for this with an architecture-specific include -I$(ROOT)/$(ARCH)/include/uapi.

Re-building now yields:
../../../../include/uapi/linux/stddef.h:2:10: fatal error: 'linux/compiler_types.h' file not found

Fix this with -I$(ROOT)/include

---
 tools/testing/selftests/bpf/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +0 -0
index 0b72cc7..6a8cfaf 100644
@@ -80,8 +80,14 @@ else
   CPU ?= generic
 endif
 

tools/testing/selftests/bpf/Makefile else · line 90

Quoted 10 lines
tools/testing/selftests/bpf/Makefile +8 -2
-CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
-	      -Wno-compare-distinct-pointer-types
+ARCH := arch/$(subst _64,,$(shell uname -p))
+ROOT :=../../../..
+TOOLS :=../../..
+CLANG_FLAGS = -I. -I./include/uapi \
+	-I$(TOOLS)/include/uapi -I$(TOOLS)/include \
+	-I$(ROOT)/$(ARCH)/include/uapi \
+	-I$(ROOT)/include/uapi -I$(ROOT)/include \
+	-Wno-compare-distinct-pointer-types

Problem is that this will now pull in all sort of kernel headers whereas before the includes are limited and contained to tools/include/ respectively tools/arch/*/include/, meaning, the tools/ infrastructure has specifically headers that are needed under these locations. And a bitsperlong.h is already present there, thus please change and respin your fix to reuse that one.

Thanks Sirio!