All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpftool: Fix bootstrapping during a cross compilation
@ 2022-06-08 14:29 Shahab Vahedi
  2022-06-08 16:49 ` Quentin Monnet
  2022-06-09 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Shahab Vahedi @ 2022-06-08 14:29 UTC (permalink / raw)
  To: bpf; +Cc: Shahab Vahedi

This change adjusts the Makefile to use "HOSTAR" as the archive tool
to keep the sanity of the build process for the bootstrap part in
check. For the rationale, please continue reading.

When cross compiling bpftool with buildroot, it leads to an invocation
like:

$ AR="/path/to/buildroot/host/bin/arc-linux-gcc-ar" \
  CC="/path/to/buildroot/host/bin/arc-linux-gcc"    \
  ...
  make

Which in return fails while building the bootstrap section:

----------------------------------8<----------------------------------

  make: Entering directory '/src/bpftool-v6.7.0/src'
  ...                        libbfd: [ on  ]
  ...        disassembler-four-args: [ on  ]
  ...                          zlib: [ on  ]
  ...                        libcap: [ OFF ]
  ...               clang-bpf-co-re: [ on  ] <-- triggers bootstrap

  .
  .
  .

    LINK     /src/bpftool-v6.7.0/src/bootstrap/bpftool
  /usr/bin/ld: /src/bpftool-v6.7.0/src/bootstrap/libbpf/libbpf.a:
               error adding symbols: archive has no index; run ranlib
               to add one
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:211: /src/bpftool-v6.7.0/src/bootstrap/bpftool]
            Error 1
  make: *** Waiting for unfinished jobs....
    AR       /src/bpftool-v6.7.0/src/libbpf/libbpf.a
    make[1]: Leaving directory '/src/bpftool-v6.7.0/libbpf/src'
    make: Leaving directory '/src/bpftool-v6.7.0/src'

---------------------------------->8----------------------------------

This occurs because setting "AR" confuses the build process for the
bootstrap section and it calls "arc-linux-gcc-ar" to create and index
"libbpf.a" instead of the host "ar".

Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
---
 tools/bpf/bpftool/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index c6d2c77d0252..c19e0e4c41bd 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -53,7 +53,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_
 $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT)
 	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \
 		DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) prefix= \
-		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers
+		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) $@ install_headers
 
 $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
 	$(call QUIET_INSTALL, $@)
-- 
2.30.2


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

* Re: [PATCH] bpftool: Fix bootstrapping during a cross compilation
  2022-06-08 14:29 [PATCH] bpftool: Fix bootstrapping during a cross compilation Shahab Vahedi
@ 2022-06-08 16:49 ` Quentin Monnet
  2022-06-09 13:43   ` Jean-Philippe Brucker
  2022-06-09 12:10 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Quentin Monnet @ 2022-06-08 16:49 UTC (permalink / raw)
  To: Shahab Vahedi, bpf; +Cc: Jean-Philippe Brucker

2022-06-08 14:29 UTC+0000 ~ Shahab Vahedi <Shahab.Vahedi@synopsys.com>
> This change adjusts the Makefile to use "HOSTAR" as the archive tool
> to keep the sanity of the build process for the bootstrap part in
> check. For the rationale, please continue reading.
> 
> When cross compiling bpftool with buildroot, it leads to an invocation
> like:
> 
> $ AR="/path/to/buildroot/host/bin/arc-linux-gcc-ar" \
>   CC="/path/to/buildroot/host/bin/arc-linux-gcc"    \
>   ...
>   make
> 
> Which in return fails while building the bootstrap section:
> 
> ----------------------------------8<----------------------------------
> 
>   make: Entering directory '/src/bpftool-v6.7.0/src'
>   ...                        libbfd: [ on  ]
>   ...        disassembler-four-args: [ on  ]
>   ...                          zlib: [ on  ]
>   ...                        libcap: [ OFF ]
>   ...               clang-bpf-co-re: [ on  ] <-- triggers bootstrap
> 
>   .
>   .
>   .
> 
>     LINK     /src/bpftool-v6.7.0/src/bootstrap/bpftool
>   /usr/bin/ld: /src/bpftool-v6.7.0/src/bootstrap/libbpf/libbpf.a:
>                error adding symbols: archive has no index; run ranlib
>                to add one
>   collect2: error: ld returned 1 exit status
>   make: *** [Makefile:211: /src/bpftool-v6.7.0/src/bootstrap/bpftool]
>             Error 1
>   make: *** Waiting for unfinished jobs....
>     AR       /src/bpftool-v6.7.0/src/libbpf/libbpf.a
>     make[1]: Leaving directory '/src/bpftool-v6.7.0/libbpf/src'
>     make: Leaving directory '/src/bpftool-v6.7.0/src'
> 
> ---------------------------------->8----------------------------------
> 
> This occurs because setting "AR" confuses the build process for the
> bootstrap section and it calls "arc-linux-gcc-ar" to create and index
> "libbpf.a" instead of the host "ar".
> 
> Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
> ---
>  tools/bpf/bpftool/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index c6d2c77d0252..c19e0e4c41bd 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -53,7 +53,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_
>  $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT)
>  	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \
>  		DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) prefix= \
> -		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers
> +		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) $@ install_headers
>  
>  $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
>  	$(call QUIET_INSTALL, $@)

+Cc Jean-Philippe

Looks good to me, thank you!
Reviewed-by: Quentin Monnet <quentin@isovalent.com>

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

* Re: [PATCH] bpftool: Fix bootstrapping during a cross compilation
  2022-06-08 14:29 [PATCH] bpftool: Fix bootstrapping during a cross compilation Shahab Vahedi
  2022-06-08 16:49 ` Quentin Monnet
@ 2022-06-09 12:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-09 12:10 UTC (permalink / raw)
  To: Shahab Vahedi; +Cc: bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Wed, 8 Jun 2022 14:29:28 +0000 you wrote:
> This change adjusts the Makefile to use "HOSTAR" as the archive tool
> to keep the sanity of the build process for the bootstrap part in
> check. For the rationale, please continue reading.
> 
> When cross compiling bpftool with buildroot, it leads to an invocation
> like:
> 
> [...]

Here is the summary with links:
  - bpftool: Fix bootstrapping during a cross compilation
    https://git.kernel.org/bpf/bpf-next/c/0b817059a883

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] bpftool: Fix bootstrapping during a cross compilation
  2022-06-08 16:49 ` Quentin Monnet
@ 2022-06-09 13:43   ` Jean-Philippe Brucker
  0 siblings, 0 replies; 4+ messages in thread
From: Jean-Philippe Brucker @ 2022-06-09 13:43 UTC (permalink / raw)
  To: Quentin Monnet; +Cc: Shahab Vahedi, bpf

On Wed, Jun 08, 2022 at 05:49:41PM +0100, Quentin Monnet wrote:
> 2022-06-08 14:29 UTC+0000 ~ Shahab Vahedi <Shahab.Vahedi@synopsys.com>
> > This change adjusts the Makefile to use "HOSTAR" as the archive tool
> > to keep the sanity of the build process for the bootstrap part in
> > check. For the rationale, please continue reading.
> > 
> > When cross compiling bpftool with buildroot, it leads to an invocation
> > like:
> > 
> > $ AR="/path/to/buildroot/host/bin/arc-linux-gcc-ar" \
> >   CC="/path/to/buildroot/host/bin/arc-linux-gcc"    \
> >   ...
> >   make
> > 
> > Which in return fails while building the bootstrap section:
> > 
> > ----------------------------------8<----------------------------------
> > 
> >   make: Entering directory '/src/bpftool-v6.7.0/src'
> >   ...                        libbfd: [ on  ]
> >   ...        disassembler-four-args: [ on  ]
> >   ...                          zlib: [ on  ]
> >   ...                        libcap: [ OFF ]
> >   ...               clang-bpf-co-re: [ on  ] <-- triggers bootstrap
> > 
> >   .
> >   .
> >   .
> > 
> >     LINK     /src/bpftool-v6.7.0/src/bootstrap/bpftool
> >   /usr/bin/ld: /src/bpftool-v6.7.0/src/bootstrap/libbpf/libbpf.a:
> >                error adding symbols: archive has no index; run ranlib
> >                to add one
> >   collect2: error: ld returned 1 exit status
> >   make: *** [Makefile:211: /src/bpftool-v6.7.0/src/bootstrap/bpftool]
> >             Error 1
> >   make: *** Waiting for unfinished jobs....
> >     AR       /src/bpftool-v6.7.0/src/libbpf/libbpf.a
> >     make[1]: Leaving directory '/src/bpftool-v6.7.0/libbpf/src'
> >     make: Leaving directory '/src/bpftool-v6.7.0/src'
> > 
> > ---------------------------------->8----------------------------------
> > 
> > This occurs because setting "AR" confuses the build process for the
> > bootstrap section and it calls "arc-linux-gcc-ar" to create and index
> > "libbpf.a" instead of the host "ar".
> > 
> > Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
> > ---
> >  tools/bpf/bpftool/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index c6d2c77d0252..c19e0e4c41bd 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -53,7 +53,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_
> >  $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT)
> >  	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \
> >  		DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) prefix= \
> > -		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers
> > +		ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) $@ install_headers
> >  
> >  $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
> >  	$(call QUIET_INSTALL, $@)
> 
> +Cc Jean-Philippe
> 
> Looks good to me, thank you!
> Reviewed-by: Quentin Monnet <quentin@isovalent.com>

Thanks, it makes sense to me as well

Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

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

end of thread, other threads:[~2022-06-09 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 14:29 [PATCH] bpftool: Fix bootstrapping during a cross compilation Shahab Vahedi
2022-06-08 16:49 ` Quentin Monnet
2022-06-09 13:43   ` Jean-Philippe Brucker
2022-06-09 12:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.