[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP-5=fVoWZUAVne0q46Z6w89yyh8DL_u2L6ugs0d5yqF0Ngkig@mail.gmail.com>
Date: Thu, 19 Jan 2023 10:13:46 -0800
From: Ian Rogers <irogers@...gle.com>
To: Jiri Olsa <olsajiri@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>,
Connor OBrien <connoro@...gle.com>,
Nathan Chancellor <nathan@...nel.org>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] tools/resolve_btfids: Alter how HOSTCC is forced
On Thu, Jan 19, 2023 at 6:51 AM Jiri Olsa <olsajiri@...il.com> wrote:
>
> On Mon, Jan 16, 2023 at 01:57:51PM -0800, Ian Rogers wrote:
> > HOSTCC is always wanted when building. Setting CC to HOSTCC happens
> > after tools/scripts/Makefile.include is included, meaning flags are
> > set assuming say CC is gcc, but then it can be later set to HOSTCC
> > which may be clang. tools/scripts/Makefile.include is needed for host
> > set up and common macros in objtool's Makefile. Rather than override
> > CC to HOSTCC, just pass CC as HOSTCC to Makefile.build, the libsubcmd
> > builds and the linkage step. This means the Makefiles don't see things
> > like CC changing and tool flag determination, and similar, work
> > properly.
> >
> > Also, clear the passed subdir as otherwise an outer build may break by
> > inadvertently passing an inappropriate value.
>
> I tested with cross builds for s390/ppc/arm64 and it was ok
>
> some comments below
>
> thanks,
> jirka
>
>
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> > tools/bpf/resolve_btfids/Makefile | 17 +++++++----------
> > 1 file changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> > index 76b737b2560d..515d87b32fb8 100644
> > --- a/tools/bpf/resolve_btfids/Makefile
> > +++ b/tools/bpf/resolve_btfids/Makefile
> > @@ -18,14 +18,11 @@ else
> > endif
> >
> > # always use the host compiler
> > -AR = $(HOSTAR)
> > -CC = $(HOSTCC)
> > -LD = $(HOSTLD)
> > -ARCH = $(HOSTARCH)
>
> I wonder all the tools should use HOSTCC in the first place?
> seems more clear than forcing it from other makefiles
>
> subcmd even has:
>
> CC ?= $(CROSS_COMPILE)gcc
> LD ?= $(CROSS_COMPILE)ld
> AR ?= $(CROSS_COMPILE)ar
>
> which seems wrong unless I'm missing something.. should be always
> the host compiler, right?
Hmm.. it seems like a feature to be able to cross compile things like
the perf tool.
I agree the way this is all done is muddling and we should try to keep
the way it is done consistent. The pattern of always early including
Makefile.include, that sets flags based on CC, but then overriding CC
was what I was after cleaning up here. Let's work on migrating to
something better.
> > +HOST_OVERRIDES := AR=$(HOSTAR) CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
> > + ARCH=$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)"
>
> there's extra AR set and ARCH value is not in ""
Ack. Will fix in v3.
Thanks,
Ian
> > +
> > RM ?= rm
> > CROSS_COMPILE =
> > -CFLAGS := $(KBUILD_HOSTCFLAGS)
> > -LDFLAGS := $(KBUILD_HOSTLDFLAGS)
> >
> > OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
> >
> > @@ -56,12 +53,12 @@ $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
> >
> > $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
> > $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \
> > - DESTDIR=$(SUBCMD_DESTDIR) prefix= \
> > + DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
> > $(abspath $@) install_headers
> >
> > $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT)
> > $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \
> > - DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \
> > + DESTDIR=$(LIBBPF_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
> > $(abspath $@) install_headers
> >
> > CFLAGS += -g \
> > @@ -76,11 +73,11 @@ export srctree OUTPUT CFLAGS Q
> > include $(srctree)/tools/build/Makefile.include
> >
> > $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
> > - $(Q)$(MAKE) $(build)=resolve_btfids
> > + $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES)
> >
> > $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
> > $(call msg,LINK,$@)
> > - $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
> > + $(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HOSTLDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
> >
> > clean_objects := $(wildcard $(OUTPUT)/*.o \
> > $(OUTPUT)/.*.o.cmd \
> > --
> > 2.39.0.314.g84b9a713c41-goog
> >
Powered by blists - more mailing lists