Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756535AbdLTVwY (ORCPT ); Wed, 20 Dec 2017 16:52:24 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:36189 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755631AbdLTVwW (ORCPT ); Wed, 20 Dec 2017 16:52:22 -0500 X-Google-Smtp-Source: ACJfBou7vXvyxqELOQsL0Kfo92okv+YvLREyEFLHuJo+bMjUnbcymzv6UhdMZkRiwe/uxIFCGSt2Lg== Date: Wed, 20 Dec 2017 13:52:18 -0800 From: Jakub Kicinski To: Roman Gushchin Cc: , , , , Alexei Starovoitov , Daniel Borkmann , Arnaldo Carvalho de Melo Subject: Re: [RFC PATCH net-next] tools/bpftool: use version from the kernel source tree Message-ID: <20171220135218.1ed54acb@cakuba.netronome.com> In-Reply-To: <20171220205332.GA28352@castle> References: <20171220201943.24440-1-guro@fb.com> <20171220122921.62e10f33@cakuba.netronome.com> <20171220205332.GA28352@castle> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2587 Lines: 65 On Wed, 20 Dec 2017 20:53:41 +0000, Roman Gushchin wrote: > On Wed, Dec 20, 2017 at 12:29:21PM -0800, Jakub Kicinski wrote: > > On Wed, 20 Dec 2017 20:19:43 +0000, Roman Gushchin wrote: > > > Bpftool determines it's own version based on the kernel > > > version, which is picked from the linux/version.h header. > > > > > > It's strange to use the version of the installed kernel > > > headers, and makes much more sense to use the version > > > of the actual source tree, where bpftool sources are. > > > > > > This patch adds $(srctree)/usr/include to the list > > > of include files, which causes bpftool to use the version > > > from the source tree. > > > > > > Example: > > > before: > > > > > > $ bpftool version > > > bpftool v4.14.6 > > > > > > after: > > > $ bpftool version > > > bpftool v4.15.0 > > > > Thanks for the patch, this would indeed use some improvement. > > > > How about we just run make to get the version like liblockdep does? > > > > LIBLOCKDEP_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion) > > > > probably s@../../..@$(srctree)@ > > > > $(srctree)/usr/include is not going to be there for out-of-source builds. > > Hm, why it's better? It's not only about the kernel version, > IMO it's generally better to use includes from the source tree, > rather then system-wide installed kernel headers. Right I agree the kernel headers are preferred. I'm not entirely sure why we don't use them, if it was OK to assume usr/ is there we wouldn't need the tools/include/uapi/ contraption. Maybe Arnaldo could explain? > I've got about out-of-source builds, but do we support it in general? > How can I build bpftool outside of the kernel tree? > I've tried a bit, but failed. This is what I do: make -C tools/bpf/bpftool/ W=1 O=/tmp/builds/bpftool > > > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile > > > index 9c089cfa5f3f..6864d416c49e 100644 > > > --- a/tools/bpf/bpftool/Makefile > > > +++ b/tools/bpf/bpftool/Makefile > > > @@ -37,7 +37,9 @@ CC = gcc > > > > > > CFLAGS += -O2 > > > CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow > > > -CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/> > > tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/ > > > +CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi > > > +CFLAGS += -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf > > > +CFLAGS += -I$(srctree)/kernel/bpf/ -I$(srctree)/usr/include > > > LIBS = -lelf -lbfd -lopcodes $(LIBBPF) > > > > > > INSTALL ?= install