netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Roman Gushchin <guro@fb.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<kernel-team@fb.com>, <scientist@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [RFC PATCH net-next] tools/bpftool: use version from the kernel source tree
Date: Wed, 20 Dec 2017 13:52:18 -0800	[thread overview]
Message-ID: <20171220135218.1ed54acb@cakuba.netronome.com> (raw)
In-Reply-To: <20171220205332.GA28352@castle>

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

  reply	other threads:[~2017-12-20 21:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 20:19 [RFC PATCH net-next] tools/bpftool: use version from the kernel source tree Roman Gushchin
2017-12-20 20:26 ` Yonghong Song
2017-12-20 20:56   ` Roman Gushchin
2017-12-20 20:29 ` Jakub Kicinski
2017-12-20 20:53   ` Roman Gushchin
2017-12-20 21:52     ` Jakub Kicinski [this message]
2017-12-21 12:07       ` Roman Gushchin
2017-12-21 17:34         ` Jakub Kicinski

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=20171220135218.1ed54acb@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=guro@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=scientist@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).