From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
Ian Rogers <irogers@google.com>,
x86@kernel.org, netdev@vger.kernel.org
Subject: Re: [tip: objtool/core] objtool: Fix HOSTCC flag usage
Date: Sat, 4 Feb 2023 09:05:02 -0800 [thread overview]
Message-ID: <20230204170502.qjc3dpmf2owa3w7v@treble> (raw)
In-Reply-To: <20230203182540.7linqqtr3tlrbfe7@skbuf>
On Fri, Feb 03, 2023 at 08:25:40PM +0200, Vladimir Oltean wrote:
> On Wed, Feb 01, 2023 at 09:36:37AM -0800, Josh Poimboeuf wrote:
> > On Wed, Feb 01, 2023 at 05:02:16PM +0000, Mark Rutland wrote:
> > > Hi,
> > >
> > > I just spotted this breaks cross-compiling; details below.
> >
> > Thanks, we'll fix it up with
> >
> > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> > index 29a8cd7449bf..83b100c1e7f6 100644
> > --- a/tools/objtool/Makefile
> > +++ b/tools/objtool/Makefile
> > @@ -36,7 +36,7 @@ OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBE
> > OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS)
> >
> > # Allow old libelf to be used:
> > -elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
> > +elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - | grep elf_getshdr)
> > OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED)
> >
> > # Always want host compilation.
>
> Profiting off of the occasion to point out that cross-compiling with
> CONFIG_DEBUG_INFO_BTF=y is also broken (it builds the resolve_btfids
> tool):
The above patch was for objtool, though I'm guessing you were bitten by
a similar patch for bpf:
13e07691a16f ("tools/resolve_btfids: Alter how HOSTCC is forced")
It looks like it might have a similar problem we had for objtool. Does
this fix it?
diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index daed388aa5d7..fff84cd914cd 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -18,8 +18,8 @@ else
endif
# always use the host compiler
-HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \
- EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)"
+HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)"
+BTF_CFLAGS := $(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)
RM ?= rm
CROSS_COMPILE =
@@ -53,23 +53,25 @@ $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT):
$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \
- DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \
+ $(HOST_OVERRIDES) EXTRA_CFLAGS="$(BTF_CFLAGS)" \
+ DESTDIR=$(LIBBPF_DESTDIR) 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) $(HOST_OVERRIDES) prefix= subdir= \
+ $(HOST_OVERRIDES) EXTRA_CFLAGS="$(BTF_CFLAGS)" \
+ DESTDIR=$(LIBBPF_DESTDIR) prefix= subdir= \
$(abspath $@) install_headers
LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
LIBELF_LIBS := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
-CFLAGS += -g \
- -I$(srctree)/tools/include \
- -I$(srctree)/tools/include/uapi \
- -I$(LIBBPF_INCLUDE) \
- -I$(SUBCMD_INCLUDE) \
- $(LIBELF_FLAGS)
+BTF_CFLAGS += -g \
+ -I$(srctree)/tools/include \
+ -I$(srctree)/tools/include/uapi \
+ -I$(LIBBPF_INCLUDE) \
+ -I$(SUBCMD_INCLUDE) \
+ $(LIBELF_FLAGS)
LIBS = $(LIBELF_LIBS) -lz
@@ -77,7 +79,7 @@ export srctree OUTPUT CFLAGS Q
include $(srctree)/tools/build/Makefile.include
$(BINARY_IN): fixdep FORCE prepare | $(OUTPUT)
- $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES)
+ $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) CFLAGS="$(BTF_CFLAGS)"
$(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
$(call msg,LINK,$@)
next prev parent reply other threads:[~2023-02-04 17:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230126190606.40739-4-irogers@google.com>
[not found] ` <167526879495.4906.2898311831401901292.tip-bot2@tip-bot2>
[not found] ` <Y9qbGHDBFtGoqnKK@FVFF77S0Q05N>
[not found] ` <20230201173637.cyu6yzudwsuzl2vj@treble>
2023-02-03 18:25 ` [tip: objtool/core] objtool: Fix HOSTCC flag usage Vladimir Oltean
2023-02-04 17:05 ` Josh Poimboeuf [this message]
2023-02-04 21:21 ` Ian Rogers
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=20230204170502.qjc3dpmf2owa3w7v@treble \
--to=jpoimboe@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=x86@kernel.org \
/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).