From: Sirio Balmelli <sirio@b-ad.ch>
To: daniel@iogearbox.net
Cc: netdev@vger.kernel.org
Subject: [PATCH v2 1/2] selftests/bpf: Makefile: add includes to fix broken test build
Date: Mon, 30 Apr 2018 09:17:31 +0200 [thread overview]
Message-ID: <20180430071730.nghfksp2tkj3x5ld@vm4> (raw)
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@b-ad.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
next reply other threads:[~2018-04-30 7:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-30 7:17 Sirio Balmelli [this message]
2018-04-30 10:12 ` [PATCH v2 1/2] selftests/bpf: Makefile: add includes to fix broken test build Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180430071730.nghfksp2tkj3x5ld@vm4 \
--to=sirio@b-ad.ch \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox