From: Sirio Balmelli <sirio@b-ad.ch>
To: daniel@iogearbox.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/1] selftests/bpf: Makefile fix "missing" headers on build with -idirafter
Date: Mon, 21 May 2018 09:00:03 +0200 [thread overview]
Message-ID: <20180521070001.tzyzdb3o2ma3hwdv@vm4> (raw)
Selftests fail to build on several distros/architectures because of
missing headers files.
On a Ubuntu/x86_64 some missing headers are:
asm/byteorder.h, asm/socket.h, asm/sockios.h
On a Debian/arm32 build already fails at sys/cdefs.h
In both cases, these already exist in /usr/include/<arch-specific-dir>,
but Clang does not include these when using '-target bpf' flag,
since it is no longer compiling against the host architecture.
The solution is to:
- run Clang without '-target bpf' and extract the include chain for the
current system
- add these to the bpf build with '-idirafter'
The choice of -idirafter is to catch this error without injecting
unexpected include behavior: if an arch-specific tree is built
for bpf in the future, this will be correctly found by Clang.
Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
---
tools/testing/selftests/bpf/Makefile | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 1eb0fa2aba92..e0c8d3cdc6c9 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -84,7 +84,16 @@ else
CPU ?= generic
endif
+# Get Clang's default includes on this system, as opposed to those seen by '-target bpf'.
+# This fixes "missing" files on some architectures/distros,
+#+ such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
+# Use '-idirafter': don't interfere with include mechanics
+#+ except where the build would have failed anyways.
+CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
+ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
+
CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
+ $(CLANG_SYS_INCLUDES) \
-Wno-compare-distinct-pointer-types
$(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline
--
2.16.2
next reply other threads:[~2018-05-21 7:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 7:00 Sirio Balmelli [this message]
2018-05-23 12:44 ` [PATCH 1/1] selftests/bpf: Makefile fix "missing" headers on build with -idirafter 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=20180521070001.tzyzdb3o2ma3hwdv@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