[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180430071730.nghfksp2tkj3x5ld@vm4>
Date: Mon, 30 Apr 2018 09:17:31 +0200
From: Sirio Balmelli <sirio@...d.ch>
To: daniel@...earbox.net
Cc: netdev@...r.kernel.org
Subject: [PATCH v2 1/2] selftests/bpf: Makefile: add includes to fix broken
test build
Build fails with missing 'asm/bitsperlong.h'.
Include this from tools/arch/[arch]/include/uapi
using an architecture-specific include sourced from 'Module.symvers'
(is this legitimate? another idea was to do a `uname -p` but what if
caller was cross-compiling?)
Once the arch-specific include is fixed, a lack of 'asm/byteorder.h'
now rears its ugly head.
The only sane (ie: will not pull in kernel headers) place I can find it
is in $(ROOT)/usr/include - add this to the include.
Note that $(ROOT)/usr/include is generated on kernel build, hence my
assumption that 'Module.symvers' will also be present.
This highlights a philosophical issue - should these tests build:
1. Against the kernel tree only?
In this case I likely did the right thing here.
2. Against the local machine?
Then the proper handling is to source 'arch' from eg `uname -p`
and include /usr/include/x86_64-linux-gnu/asm/byteorder.h instead
of $(ROOT)/usr/include.
Signed-off-by: Sirio Balmelli <sirio@...d.ch>
---
tools/testing/selftests/bpf/Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9d76218..a19c6af 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -84,8 +84,14 @@ else
CPU ?= generic
endif
-CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
- -Wno-compare-distinct-pointer-types
+# Assume caller has compiled the kernel; get compilation architecture from Module.symvers
+TOOLS :=../../..
+ROOT :=../../../..
+ARCH := $(shell sed -rne 's|.*(arch/[^/]+).*|\1|p' $(ROOT)/Module.symvers | head -n 1)
+CLANG_FLAGS = -I. -I./include/uapi \
+ -I$(TOOLS)/include/uapi -I$(TOOLS)/$(ARCH)/include/uapi \
+ -I$(ROOT)/usr/include \
+ -Wno-compare-distinct-pointer-types
$(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline
$(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline
--
2.7.4
Powered by blists - more mailing lists