netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpfilter: fix user mode helper cross compilation
@ 2018-06-20 14:04 Matteo Croce
  2018-06-20 14:19 ` Stefano Brivio
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Matteo Croce @ 2018-06-20 14:04 UTC (permalink / raw)
  To: netdev

Use $(OBJDUMP) instead of literal 'objdump' to avoid
using host toolchain when cross compiling.

Fixes: 421780fd4983 ("bpfilter: fix build error")
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 net/bpfilter/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index dd86b022eff0..051dc18b8ccb 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -22,7 +22,7 @@ endif
 quiet_cmd_copy_umh = GEN $@
       cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
       $(OBJCOPY) -I binary \
-          `LC_ALL=C objdump -f net/bpfilter/bpfilter_umh \
+          `LC_ALL=C $(OBJDUMP) -f net/bpfilter/bpfilter_umh \
           |awk -F' |,' '/file format/{print "-O",$$NF} \
           /^architecture:/{print "-B",$$2}'` \
       --rename-section .data=.init.rodata $< $@
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpfilter: fix user mode helper cross compilation
  2018-06-20 14:04 [PATCH] bpfilter: fix user mode helper cross compilation Matteo Croce
@ 2018-06-20 14:19 ` Stefano Brivio
  2018-06-21  0:19 ` David Miller
  2018-06-28  6:17 ` Andrew Morton
  2 siblings, 0 replies; 6+ messages in thread
From: Stefano Brivio @ 2018-06-20 14:19 UTC (permalink / raw)
  To: Matteo Croce; +Cc: netdev

On Wed, 20 Jun 2018 16:04:34 +0200
Matteo Croce <mcroce@redhat.com> wrote:

> Use $(OBJDUMP) instead of literal 'objdump' to avoid
> using host toolchain when cross compiling.
> 
> Fixes: 421780fd4983 ("bpfilter: fix build error")
> Signed-off-by: Matteo Croce <mcroce@redhat.com>

Reported-by: Stefano Brivio <sbrivio@redhat.com>

-- 
Stefano

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpfilter: fix user mode helper cross compilation
  2018-06-20 14:04 [PATCH] bpfilter: fix user mode helper cross compilation Matteo Croce
  2018-06-20 14:19 ` Stefano Brivio
@ 2018-06-21  0:19 ` David Miller
  2018-06-28  6:17 ` Andrew Morton
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-06-21  0:19 UTC (permalink / raw)
  To: mcroce; +Cc: netdev

From: Matteo Croce <mcroce@redhat.com>
Date: Wed, 20 Jun 2018 16:04:34 +0200

> Use $(OBJDUMP) instead of literal 'objdump' to avoid
> using host toolchain when cross compiling.
> 
> Fixes: 421780fd4983 ("bpfilter: fix build error")
> Signed-off-by: Matteo Croce <mcroce@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpfilter: fix user mode helper cross compilation
  2018-06-20 14:04 [PATCH] bpfilter: fix user mode helper cross compilation Matteo Croce
  2018-06-20 14:19 ` Stefano Brivio
  2018-06-21  0:19 ` David Miller
@ 2018-06-28  6:17 ` Andrew Morton
  2018-06-28  9:23   ` Matteo Croce
  2018-06-28 14:43   ` Alexei Starovoitov
  2 siblings, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2018-06-28  6:17 UTC (permalink / raw)
  To: Matteo Croce; +Cc: netdev

On Wed, 20 Jun 2018 16:04:34 +0200 Matteo Croce <mcroce@redhat.com> wrote:

> Use $(OBJDUMP) instead of literal 'objdump' to avoid
> using host toolchain when cross compiling.
> 

I'm still having issues here, with ld.

x86_64 machine, ARCH=i386:

y:/usr/src/25> make V=1 M=net/bpfilter
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (       \
echo >&2;                                                       \
echo >&2 "  ERROR: Kernel configuration is invalid.";           \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
echo >&2 ;                                                      \
/bin/false)
mkdir -p net/bpfilter/.tmp_versions ; rm -f net/bpfilter/.tmp_versions/*
make -f ./scripts/Makefile.build obj=net/bpfilter
(cat /dev/null;   echo kernel/net/bpfilter/bpfilter.ko;) > net/bpfilter/modules.order
  ld -m elf_i386   -r -o net/bpfilter/bpfilter.o net/bpfilter/bpfilter_kern.o net/bpfilter/bpfilter_umh.o ; scripts/mod/modpost net/bpfilter/bpfilter.o
ld: i386:x86-64 architecture of input file `net/bpfilter/bpfilter_umh.o' is incompatible with i386 output
scripts/Makefile.build:530: recipe for target 'net/bpfilter/bpfilter.o' failed
make[1]: *** [net/bpfilter/bpfilter.o] Error 1
Makefile:1518: recipe for target '_module_net/bpfilter' failed
make: *** [_module_net/bpfilter] Error 2

y:/usr/src/25> ld --version
GNU ld (GNU Binutils for Ubuntu) 2.29.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpfilter: fix user mode helper cross compilation
  2018-06-28  6:17 ` Andrew Morton
@ 2018-06-28  9:23   ` Matteo Croce
  2018-06-28 14:43   ` Alexei Starovoitov
  1 sibling, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2018-06-28  9:23 UTC (permalink / raw)
  To: akpm; +Cc: netdev

On Thu, Jun 28, 2018 at 6:17 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 20 Jun 2018 16:04:34 +0200 Matteo Croce <mcroce@redhat.com> wrote:
>
> > Use $(OBJDUMP) instead of literal 'objdump' to avoid
> > using host toolchain when cross compiling.
> >
>
> I'm still having issues here, with ld.
>
> x86_64 machine, ARCH=i386:
>
> y:/usr/src/25> make V=1 M=net/bpfilter
> test -e include/generated/autoconf.h -a -e include/config/auto.conf || (       \
> echo >&2;                                                       \
> echo >&2 "  ERROR: Kernel configuration is invalid.";           \
> echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
> echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
> echo >&2 ;                                                      \
> /bin/false)
> mkdir -p net/bpfilter/.tmp_versions ; rm -f net/bpfilter/.tmp_versions/*
> make -f ./scripts/Makefile.build obj=net/bpfilter
> (cat /dev/null;   echo kernel/net/bpfilter/bpfilter.ko;) > net/bpfilter/modules.order
>   ld -m elf_i386   -r -o net/bpfilter/bpfilter.o net/bpfilter/bpfilter_kern.o net/bpfilter/bpfilter_umh.o ; scripts/mod/modpost net/bpfilter/bpfilter.o
> ld: i386:x86-64 architecture of input file `net/bpfilter/bpfilter_umh.o' is incompatible with i386 output
> scripts/Makefile.build:530: recipe for target 'net/bpfilter/bpfilter.o' failed
> make[1]: *** [net/bpfilter/bpfilter.o] Error 1
> Makefile:1518: recipe for target '_module_net/bpfilter' failed
> make: *** [_module_net/bpfilter] Error 2
>
> y:/usr/src/25> ld --version
> GNU ld (GNU Binutils for Ubuntu) 2.29.1
>
>

Hi Andrew,

That's because the Makefile does `HOSTCC:=$(CC)` which replaces the
tools compiler with the target one.
The problem is that for i386 and x86_64 the compiler is the same, it's
just called with different arguments, -m32 and -m64.
This ends up with mixed i386 and x86_64 binaries which obviously can't
link together.

Personally I think that we should add infrastructure to build target
progs like we do with hostprogs-y instead of keeping messing with
variables and flags. If you want a quick and dirty hack to build it,
I'm using this.

Regards,

diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index 051dc18b8ccb..5de353cfd26b 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -5,8 +5,9 @@

 hostprogs-y := bpfilter_umh
 bpfilter_umh-objs := main.o
-HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
 HOSTCC := $(CC)
+HOSTCFLAGS := $(KBUILD_CFLAGS) -I. -Itools/include/ -Itools/include/uapi
+HOSTLOADLIBES_bpfilter_umh := $(KBUILD_CFLAGS)

 ifeq ($(CONFIG_BPFILTER_UMH), y)
 # builtin bpfilter_umh should be compiled with -static

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpfilter: fix user mode helper cross compilation
  2018-06-28  6:17 ` Andrew Morton
  2018-06-28  9:23   ` Matteo Croce
@ 2018-06-28 14:43   ` Alexei Starovoitov
  1 sibling, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2018-06-28 14:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matteo Croce, netdev

On Wed, Jun 27, 2018 at 11:17:09PM -0700, Andrew Morton wrote:
> On Wed, 20 Jun 2018 16:04:34 +0200 Matteo Croce <mcroce@redhat.com> wrote:
> 
> > Use $(OBJDUMP) instead of literal 'objdump' to avoid
> > using host toolchain when cross compiling.
> > 
> 
> I'm still having issues here, with ld.
> 
> x86_64 machine, ARCH=i386:
> 
> y:/usr/src/25> make V=1 M=net/bpfilter
> test -e include/generated/autoconf.h -a -e include/config/auto.conf || (       \
> echo >&2;                                                       \
> echo >&2 "  ERROR: Kernel configuration is invalid.";           \
> echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
> echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
> echo >&2 ;                                                      \
> /bin/false)
> mkdir -p net/bpfilter/.tmp_versions ; rm -f net/bpfilter/.tmp_versions/*
> make -f ./scripts/Makefile.build obj=net/bpfilter
> (cat /dev/null;   echo kernel/net/bpfilter/bpfilter.ko;) > net/bpfilter/modules.order
>   ld -m elf_i386   -r -o net/bpfilter/bpfilter.o net/bpfilter/bpfilter_kern.o net/bpfilter/bpfilter_umh.o ; scripts/mod/modpost net/bpfilter/bpfilter.o
> ld: i386:x86-64 architecture of input file `net/bpfilter/bpfilter_umh.o' is incompatible with i386 output

could you please try with this patch
https://patchwork.ozlabs.org/patch/935246/
that is already in net tree?

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-28 14:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20 14:04 [PATCH] bpfilter: fix user mode helper cross compilation Matteo Croce
2018-06-20 14:19 ` Stefano Brivio
2018-06-21  0:19 ` David Miller
2018-06-28  6:17 ` Andrew Morton
2018-06-28  9:23   ` Matteo Croce
2018-06-28 14:43   ` Alexei Starovoitov

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).