From: Jiri Olsa <olsajiri@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>
Subject: Re: [PATCH bpf-next] tools/resolve_btfids: Compile resolve_btfids as host program
Date: Thu, 2 Feb 2023 23:20:39 +0100 [thread overview]
Message-ID: <Y9w3N4GHxipREEoO@krava> (raw)
In-Reply-To: <CAP-5=fXy0wArjfXTQHD6nXZ=8dxb6ypRMef=-M1+uTTvbdfH0A@mail.gmail.com>
On Thu, Feb 02, 2023 at 12:14:14PM -0800, Ian Rogers wrote:
> On Thu, Feb 2, 2023 at 9:21 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > On Thu, Feb 02, 2023 at 12:28:39PM +0100, Jiri Olsa wrote:
> > > Making resolve_btfids to be compiled as host program so
> > > we can avoid cross compile issues as reported by Nathan.
> > >
> > > Also we no longer need HOST_OVERRIDES for BINARY target,
> > > just for 'prepare' targets.
> > >
> > > Cc: Ian Rogers <irogers@google.com>
> > > Fixes: 13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")
> > > Reported-by: Nathan Chancellor <nathan@kernel.org>
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> >
> > Tested-by: Nathan Chancellor <nathan@kernel.org>
> >
>
> This change has my,
> Acked-by: Ian Rogers <irogers@google.com>
thanks
> but I wonder about cleaning HOST_OVERRIDES. From the patch I sent,
> would it be worth adding:
> ```
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -17,9 +17,9 @@ else
> MAKEFLAGS=--no-print-directory
> endif
>
> -# always use the host compiler
> +# Overrides for the prepare step libraries.
> HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)"
> ARCH="$(HOSTARCH)" \
> - EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)"
> + CROSS_COMPILE=""
>
> RM ?= rm
> HOSTCC ?= gcc
> ```
> It seems odd passing HOSTCFLAGS this way and mixing HOSTCC as CC with
> CROSS_COMPILE set seems open to failure. Perhaps we should just get
> rid of this, add something like a HOST=1 option for building the
> library and then in the library code do the right thing. That would
> fix the issue that libsubcmd and libbpf here are being built reporting
> CC rather than HOSTCC, make the build flags in general more sane.
could you send separate patch with that?
also I'll try to check if we could make prepare libs as hostprogs,
because I think the changes you suggest might depend on that
jirka
>
> Thanks,
> Ian
>
> > > ---
> > > tools/bpf/resolve_btfids/Build | 4 +++-
> > > tools/bpf/resolve_btfids/Makefile | 9 ++++++---
> > > 2 files changed, 9 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/bpf/resolve_btfids/Build b/tools/bpf/resolve_btfids/Build
> > > index ae82da03f9bf..077de3829c72 100644
> > > --- a/tools/bpf/resolve_btfids/Build
> > > +++ b/tools/bpf/resolve_btfids/Build
> > > @@ -1,3 +1,5 @@
> > > +hostprogs := resolve_btfids
> > > +
> > > resolve_btfids-y += main.o
> > > resolve_btfids-y += rbtree.o
> > > resolve_btfids-y += zalloc.o
> > > @@ -7,4 +9,4 @@ resolve_btfids-y += str_error_r.o
> > >
> > > $(OUTPUT)%.o: ../../lib/%.c FORCE
> > > $(call rule_mkdir)
> > > - $(call if_changed_dep,cc_o_c)
> > > + $(call if_changed_dep,host_cc_o_c)
> > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> > > index daed388aa5d7..abdd68ac08f4 100644
> > > --- a/tools/bpf/resolve_btfids/Makefile
> > > +++ b/tools/bpf/resolve_btfids/Makefile
> > > @@ -22,6 +22,9 @@ HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)
> > > EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)"
> > >
> > > RM ?= rm
> > > +HOSTCC ?= gcc
> > > +HOSTLD ?= ld
> > > +HOSTAR ?= ar
> > > CROSS_COMPILE =
> > >
> > > OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
> > > @@ -64,7 +67,7 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
> > > LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
> > > LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
> > >
> > > -CFLAGS += -g \
> > > +HOSTCFLAGS += -g \
> > > -I$(srctree)/tools/include \
> > > -I$(srctree)/tools/include/uapi \
> > > -I$(LIBBPF_INCLUDE) \
> > > @@ -73,11 +76,11 @@ CFLAGS += -g \
> > >
> > > LIBS = $(LIBELF_LIBS) -lz
> > >
> > > -export srctree OUTPUT CFLAGS Q
> > > +export srctree OUTPUT HOSTCFLAGS Q HOSTCC HOSTLD HOSTAR
> > > include $(srctree)/tools/build/Makefile.include
> > >
> > > $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
> > > - $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES)
> > > + $(Q)$(MAKE) $(build)=resolve_btfids
> > >
> > > $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
> > > $(call msg,LINK,$@)
> > > --
> > > 2.39.1
> > >
next prev parent reply other threads:[~2023-02-02 22:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 11:28 [PATCH bpf-next] tools/resolve_btfids: Compile resolve_btfids as host program Jiri Olsa
2023-02-02 17:21 ` Nathan Chancellor
2023-02-02 20:14 ` Ian Rogers
2023-02-02 22:20 ` Jiri Olsa [this message]
2023-02-07 21:50 ` patchwork-bot+netdevbpf
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=Y9w3N4GHxipREEoO@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=irogers@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=nathan@kernel.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--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