From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sirio Balmelli Subject: [PATCH v2 1/2] selftests/bpf: Makefile: add includes to fix broken test build Date: Mon, 30 Apr 2018 09:17:31 +0200 Message-ID: <20180430071730.nghfksp2tkj3x5ld@vm4> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: netdev@vger.kernel.org To: daniel@iogearbox.net Return-path: Received: from mail-wr0-f193.google.com ([209.85.128.193]:45919 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbeD3HRd (ORCPT ); Mon, 30 Apr 2018 03:17:33 -0400 Received: by mail-wr0-f193.google.com with SMTP id p5-v6so7017831wre.12 for ; Mon, 30 Apr 2018 00:17:33 -0700 (PDT) Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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