linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Connor OBrien <connoro@google.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] tools/resolve_btfids: Install subcmd headers
Date: Mon, 16 Jan 2023 13:15:11 -0800	[thread overview]
Message-ID: <CAP-5=fUKZwbnGA6H96w5U_-L6s7XMHvXkcQXQCrYpup_Qs4aSA@mail.gmail.com> (raw)
In-Reply-To: <Y8WVVLEIkXgYvePd@krava>

On Mon, Jan 16, 2023 at 10:20 AM Jiri Olsa <olsajiri@gmail.com> wrote:
>
> On Mon, Jan 16, 2023 at 09:20:39AM -0800, Ian Rogers wrote:
> > On Mon, Jan 16, 2023 at 3:22 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> > >
> > > On Wed, Jan 11, 2023 at 04:40:24PM -0800, Ian Rogers wrote:
> > > > Previously tools/lib/subcmd was added to the include path, switch to
> > > > installing the headers and then including from that directory. This
> > > > avoids dependencies on headers internal to tools/lib/subcmd. Add the
> > > > missing subcmd directory to the affected #include.
> > > >
> > > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > > ---
> > > >  tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++-----
> > > >  tools/bpf/resolve_btfids/main.c   |  2 +-
> > > >  2 files changed, 15 insertions(+), 6 deletions(-)
> > >
> > > this depends on changes that went to Arnaldo's tree right?
> > > I can't apply this on bpf-next/master
> >
> > Hmm.. sorry for that. I did the work on the master branch of
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >
> > > >
> > > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> > > > index 19a3112e271a..de7d29cf43d6 100644
> > > > --- a/tools/bpf/resolve_btfids/Makefile
> > > > +++ b/tools/bpf/resolve_btfids/Makefile
> > > > @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
> > > >  BPFOBJ     := $(OUTPUT)/libbpf/libbpf.a
> > > >  LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/
> > > >  SUBCMDOBJ  := $(OUTPUT)/libsubcmd/libsubcmd.a
> > > > +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/
> > > >
> > > >  LIBBPF_DESTDIR := $(LIBBPF_OUT)
> > > >  LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include
> > > >
> > > > +SUBCMD_DESTDIR := $(SUBCMD_OUT)
> > > > +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include
> > > > +
> > > >  BINARY     := $(OUTPUT)/resolve_btfids
> > > >  BINARY_IN  := $(BINARY)-in.o
> > > >
> > > >  all: $(BINARY)
> > > >
> > > > +prepare: $(SUBCMDOBJ)
> > >
> > > do we need special target for that? we already have BPFOBJ dependency
> > > placed in the BINARY_IN as prereq
> >
> > BPFOBJ is $(OUTPUT)/libbpf/libbpf.a which is needed at link time. The
> > prepare step is one we have elsewhere and it creates things like the
> > header files necessary to compile the C code, so we need it earlier is
> > the answer.
> >
> > > why not place both as BINARY_IN prereq, or is there some other reason
> > > for new 'prepare' target?
> >
> > I was trying to follow the convention elsewhere in the tree of having
> > a prepare target that does things like get the necessary header files
> > ready. Having prepare is useful because if an additional dependency is
> > added, then it just needs to be added to prepare. It could be tedious
> > to list all the dependencies for every C file, although Makefile.build
>
> ok, could we maybe add the BPFOBJ in prepare target as well?

Agreed, added to v2.

> > handles most of that. It isn't clear to me why $(BPFOBJ) is a
> > dependency of $(BINARY_IN) as it is already a dependency of $(BINARY).
>
> I think that if you specify OUTPUT then we need the libbpf headers
> to be created before we go to compile resolve_btfids objects
>
> thanks,
> jirka

Yep. I also noticed that this code is doing the "CC=$(HOSTCC)" thing.
The problem with that is Makefile.include (line 2) will set things
like CFLAGS based on CC and then you change it. I sent out some
objtool build cleanup for this:
https://lore.kernel.org/lkml/20230105090155.357604-4-irogers@google.com/
I'll add a patch for this in v2.

Thanks,
Ian

      reply	other threads:[~2023-01-16 21:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  0:40 [PATCH v1] tools/resolve_btfids: Install subcmd headers Ian Rogers
2023-01-16 11:22 ` Jiri Olsa
2023-01-16 17:20   ` Ian Rogers
2023-01-16 18:20     ` Jiri Olsa
2023-01-16 21:15       ` Ian Rogers [this message]

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='CAP-5=fUKZwbnGA6H96w5U_-L6s7XMHvXkcQXQCrYpup_Qs4aSA@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=connoro@google.com \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=nathan@kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@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).