From patchwork Thu Mar 12 10:53:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Klauser X-Patchwork-Id: 1253485 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=distanz.ch Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48dQfq2F3hz9sPF for ; Thu, 12 Mar 2020 21:53:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726044AbgCLKxi (ORCPT ); Thu, 12 Mar 2020 06:53:38 -0400 Received: from sym2.noone.org ([178.63.92.236]:49416 "EHLO sym2.noone.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbgCLKxi (ORCPT ); Thu, 12 Mar 2020 06:53:38 -0400 Received: by sym2.noone.org (Postfix, from userid 1002) id 48dQfl6p9LzvjdW; Thu, 12 Mar 2020 11:53:35 +0100 (CET) From: Tobias Klauser To: Daniel Borkmann , Alexei Starovoitov Cc: Song Liu , Yonghong Song , bpf@vger.kernel.org, Alexei Starovoitov Subject: [PATCH] bpftool: use linux/types.h from source tree for profiler build Date: Thu, 12 Mar 2020 11:53:35 +0100 Message-Id: <20200312105335.10465-1-tklauser@distanz.ch> X-Mailer: git-send-email 2.11.0 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org When compiling bpftool on a system where the /usr/include/asm symlink doesn't exist (e.g. on an Ubuntu system without gcc-multilib installed), the build fails with: CLANG skeleton/profiler.bpf.o In file included from skeleton/profiler.bpf.c:4: In file included from /usr/include/linux/bpf.h:11: /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found #include ^~~~~~~~~~~~~ 1 error generated. make: *** [Makefile:123: skeleton/profiler.bpf.o] Error 1 This indicates that the build is using linux/types.h from system headers instead of source tree headers. To fix this, adjust the clang search path to include the necessary headers from tools/testing/selftests/bpf/include/uapi and tools/include/uapi. Also undef __bitwise in skeleton/profiler.h avoid clashing with the empty definition in tools/testing/selftests/bpf/include/uapi/linux/types.h. Cc: Daniel Borkmann Cc: Song Liu Cc: Alexei Starovoitov Signed-off-by: Tobias Klauser --- tools/bpf/bpftool/Makefile | 5 ++++- tools/bpf/bpftool/skeleton/profiler.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 20a90d8450f8..f294f6c1e795 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -120,7 +120,10 @@ $(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF) $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS) skeleton/profiler.bpf.o: skeleton/profiler.bpf.c - $(QUIET_CLANG)$(CLANG) -I$(srctree)/tools/lib -g -O2 -target bpf -c $< -o $@ + $(QUIET_CLANG)$(CLANG) \ + -I$(srctree)/tools/include/uapi/ \ + -I$(srctree)/tools/testing/selftests/bpf/include/uapi \ + -I$(srctree)/tools/lib -g -O2 -target bpf -c $< -o $@ profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o $(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@ diff --git a/tools/bpf/bpftool/skeleton/profiler.h b/tools/bpf/bpftool/skeleton/profiler.h index e03b53eae767..95358c0df5ef 100644 --- a/tools/bpf/bpftool/skeleton/profiler.h +++ b/tools/bpf/bpftool/skeleton/profiler.h @@ -27,6 +27,7 @@ enum { true = 1, }; +#undef __bitwise #ifdef __CHECKER__ #define __bitwise__ __attribute__((bitwise)) #else