diff mbox series

[bpf-next,05/11] samples: bpf: use host bpftool to generate vmlinux.h, not target

Message ID 20220414223704.341028-6-alobakin@pm.me (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series bpf: random unpopular userspace fixes (32 bit et al.) | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 14 of 14 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 success Logs for Kernel LATEST on ubuntu-latest + selftests
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Kernel LATEST on z15 + selftests

Commit Message

Alexander Lobakin April 14, 2022, 10:45 p.m. UTC
Use the host build of bpftool (bootstrap) instead of the target one
to generate vmlinux.h/skeletons for the BPF samples. Otherwise, when
host != target, samples compilation fails with:

/bin/sh: line 1: samples/bpf/bpftool/bpftool: failed to exec: Exec
format error

Fixes: 384b6b3bbf0d ("samples: bpf: Add vmlinux.h generation support")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 samples/bpf/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--
2.35.2

Comments

Kumar Kartikeya Dwivedi April 15, 2022, 1:38 p.m. UTC | #1
On Fri, Apr 15, 2022 at 04:15:50AM IST, Alexander Lobakin wrote:
> Use the host build of bpftool (bootstrap) instead of the target one
> to generate vmlinux.h/skeletons for the BPF samples. Otherwise, when
> host != target, samples compilation fails with:
>
> /bin/sh: line 1: samples/bpf/bpftool/bpftool: failed to exec: Exec
> format error
>
> Fixes: 384b6b3bbf0d ("samples: bpf: Add vmlinux.h generation support")
> Signed-off-by: Alexander Lobakin <alobakin@pm.me>
> ---

Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

>  samples/bpf/Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 97203c0de252..02f999a8ef84 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -291,12 +291,13 @@ $(LIBBPF): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
>
>  BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool
>  BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool
> -BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool
> +BPFTOOL := $(BPFTOOL_OUTPUT)/bootstrap/bpftool
>  $(BPFTOOL): $(LIBBPF) $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT)
>  	    $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \
>  		OUTPUT=$(BPFTOOL_OUTPUT)/ \
>  		LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \
> -		LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/
> +		LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ \
> +		bootstrap
>
>  $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
>  	$(call msg,MKDIR,$@)
> --
> 2.35.2
>
>

--
Kartikeya
Song Liu April 15, 2022, 11:44 p.m. UTC | #2
On Fri, Apr 15, 2022 at 6:38 AM Kumar Kartikeya Dwivedi
<memxor@gmail.com> wrote:
>
> On Fri, Apr 15, 2022 at 04:15:50AM IST, Alexander Lobakin wrote:
> > Use the host build of bpftool (bootstrap) instead of the target one
> > to generate vmlinux.h/skeletons for the BPF samples. Otherwise, when
> > host != target, samples compilation fails with:
> >
> > /bin/sh: line 1: samples/bpf/bpftool/bpftool: failed to exec: Exec
> > format error
> >
> > Fixes: 384b6b3bbf0d ("samples: bpf: Add vmlinux.h generation support")
> > Signed-off-by: Alexander Lobakin <alobakin@pm.me>
> > ---
>
> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

Acked-by: Song Liu <songliubraving@fb.com>

>
> >  samples/bpf/Makefile | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> > index 97203c0de252..02f999a8ef84 100644
> > --- a/samples/bpf/Makefile
> > +++ b/samples/bpf/Makefile
> > @@ -291,12 +291,13 @@ $(LIBBPF): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
> >
> >  BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool
> >  BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool
> > -BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool
> > +BPFTOOL := $(BPFTOOL_OUTPUT)/bootstrap/bpftool
> >  $(BPFTOOL): $(LIBBPF) $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT)
> >           $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \
> >               OUTPUT=$(BPFTOOL_OUTPUT)/ \
> >               LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \
> > -             LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/
> > +             LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ \
> > +             bootstrap
> >
> >  $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
> >       $(call msg,MKDIR,$@)
> > --
> > 2.35.2
> >
> >
>
> --
> Kartikeya
diff mbox series

Patch

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 97203c0de252..02f999a8ef84 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -291,12 +291,13 @@  $(LIBBPF): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU

 BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool
 BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool
-BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool
+BPFTOOL := $(BPFTOOL_OUTPUT)/bootstrap/bpftool
 $(BPFTOOL): $(LIBBPF) $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT)
 	    $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \
 		OUTPUT=$(BPFTOOL_OUTPUT)/ \
 		LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \
-		LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/
+		LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ \
+		bootstrap

 $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
 	$(call msg,MKDIR,$@)