lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230204170502.qjc3dpmf2owa3w7v@treble>
Date:   Sat, 4 Feb 2023 09:05:02 -0800
From:   Josh Poimboeuf <jpoimboe@...nel.org>
To:     Vladimir Oltean <olteanv@...il.com>
Cc:     Mark Rutland <mark.rutland@....com>, linux-kernel@...r.kernel.org,
        linux-tip-commits@...r.kernel.org, Ian Rogers <irogers@...gle.com>,
        x86@...nel.org, netdev@...r.kernel.org
Subject: Re: [tip: objtool/core] objtool: Fix HOSTCC flag usage

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,$@)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ