* [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11
2020-03-10 18:36 [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile Song Liu
@ 2020-03-10 18:36 ` Song Liu
2020-03-10 22:44 ` Quentin Monnet
2020-03-10 18:36 ` [PATCH bpf-next 2/2] bpftool: skeleton should depend on libbpf Song Liu
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Song Liu @ 2020-03-10 18:36 UTC (permalink / raw)
To: netdev, bpf
Cc: quentin, kernel-team, ast, daniel, arnaldo.melo, jolsa, Song Liu
bpftool-prog-profile requires clang of version 11.0.0 or newer. If
bpftool is built with older clang, show a hint of to the user.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
tools/bpf/bpftool/Makefile | 13 +++++++++++--
tools/bpf/bpftool/prog.c | 2 ++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 20a90d8450f8..05a37f0f76a9 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -60,6 +60,15 @@ LIBS = $(LIBBPF) -lelf -lz
INSTALL ?= install
RM ?= rm -f
CLANG ?= clang
+CLANG_VERS = $(shell $(CLANG) --version | head -n 1 | awk '{print $$3}')
+CLANG_MAJ = $(shell echo $(CLANG_VERS) | cut -d '.' -f 1)
+WITHOUT_SKELETONS = -DBPFTOOL_WITHOUT_SKELETONS
+
+ifeq ($(shell test $(CLANG_MAJ) -ge 11; echo $$?),0)
+ PROG_FLAGS =
+else
+ PROG_FLAGS = $(WITHOUT_SKELETONS)
+endif
FEATURE_USER = .bpftool
FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib
@@ -114,7 +123,7 @@ OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
_OBJS = $(filter-out $(OUTPUT)prog.o,$(OBJS)) $(OUTPUT)_prog.o
$(OUTPUT)_prog.o: prog.c
- $(QUIET_CC)$(COMPILE.c) -MMD -DBPFTOOL_WITHOUT_SKELETONS -o $@ $<
+ $(QUIET_CC)$(COMPILE.c) -MMD $(WITHOUT_SKELETONS) -o $@ $<
$(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
@@ -126,7 +135,7 @@ profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o
$(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@
$(OUTPUT)prog.o: prog.c profiler.skel.h
- $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
+ $(QUIET_CC)$(COMPILE.c) -MMD $(PROG_FLAGS) -o $@ $<
$(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 576ddd82bc96..5db378d5d970 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1545,6 +1545,8 @@ static int do_loadall(int argc, char **argv)
static int do_profile(int argc, char **argv)
{
+ fprintf(stdout, "bpftool prog profile command is not supported.\n"
+ "Please recompile bpftool with clang >= 11.0.0\n");
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11
2020-03-10 18:36 ` [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11 Song Liu
@ 2020-03-10 22:44 ` Quentin Monnet
2020-03-10 22:54 ` Alexei Starovoitov
0 siblings, 1 reply; 7+ messages in thread
From: Quentin Monnet @ 2020-03-10 22:44 UTC (permalink / raw)
To: Song Liu, netdev, bpf; +Cc: kernel-team, ast, daniel, arnaldo.melo, jolsa
2020-03-10 11:36 UTC-0700 ~ Song Liu <songliubraving@fb.com>
> bpftool-prog-profile requires clang of version 11.0.0 or newer. If
> bpftool is built with older clang, show a hint of to the user.
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
> tools/bpf/bpftool/Makefile | 13 +++++++++++--
> tools/bpf/bpftool/prog.c | 2 ++
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index 20a90d8450f8..05a37f0f76a9 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -60,6 +60,15 @@ LIBS = $(LIBBPF) -lelf -lz
> INSTALL ?= install
> RM ?= rm -f
> CLANG ?= clang
> +CLANG_VERS = $(shell $(CLANG) --version | head -n 1 | awk '{print $$3}')
> +CLANG_MAJ = $(shell echo $(CLANG_VERS) | cut -d '.' -f 1)
This will produce error messages on stderr if clang is not installed on
the system.
> +WITHOUT_SKELETONS = -DBPFTOOL_WITHOUT_SKELETONS
> +
> +ifeq ($(shell test $(CLANG_MAJ) -ge 11; echo $$?),0)
Not exactly what I had in mind. I thought about the feature detection
facility we have under tools/build/feature/, as is used for e.g.
detecting libbfd. It would allow to check the feature is available,
instead of tying the build to a numeric version number. But that's more
work to do, so I suppose this version can work, too...
> + PROG_FLAGS =
> +else
> + PROG_FLAGS = $(WITHOUT_SKELETONS)
> +endif
>
> FEATURE_USER = .bpftool
> FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib
> @@ -114,7 +123,7 @@ OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
> _OBJS = $(filter-out $(OUTPUT)prog.o,$(OBJS)) $(OUTPUT)_prog.o
>
> $(OUTPUT)_prog.o: prog.c
> - $(QUIET_CC)$(COMPILE.c) -MMD -DBPFTOOL_WITHOUT_SKELETONS -o $@ $<
> + $(QUIET_CC)$(COMPILE.c) -MMD $(WITHOUT_SKELETONS) -o $@ $<
>
> $(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF)
> $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
> @@ -126,7 +135,7 @@ profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o
> $(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@
>
> $(OUTPUT)prog.o: prog.c profiler.skel.h
> - $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
> + $(QUIET_CC)$(COMPILE.c) -MMD $(PROG_FLAGS) -o $@ $<
Would be nice to find a way to skip the second build if it is not needed?
>
> $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
> $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
> diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
> index 576ddd82bc96..5db378d5d970 100644
> --- a/tools/bpf/bpftool/prog.c
> +++ b/tools/bpf/bpftool/prog.c
> @@ -1545,6 +1545,8 @@ static int do_loadall(int argc, char **argv)
>
> static int do_profile(int argc, char **argv)
> {
> + fprintf(stdout, "bpftool prog profile command is not supported.\n"
> + "Please recompile bpftool with clang >= 11.0.0\n");
p_err()?
> return 0;
> }
>
>
Thanks a lot for the follow-up!
Quentin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11
2020-03-10 22:44 ` Quentin Monnet
@ 2020-03-10 22:54 ` Alexei Starovoitov
0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2020-03-10 22:54 UTC (permalink / raw)
To: Quentin Monnet
Cc: Song Liu, Network Development, bpf, Kernel Team,
Alexei Starovoitov, Daniel Borkmann, Arnaldo Carvalho de Melo,
Jiri Olsa
On Tue, Mar 10, 2020 at 3:45 PM Quentin Monnet <quentin@isovalent.com> wrote:
>
> 2020-03-10 11:36 UTC-0700 ~ Song Liu <songliubraving@fb.com>
> > bpftool-prog-profile requires clang of version 11.0.0 or newer. If
> > bpftool is built with older clang, show a hint of to the user.
> >
> > Signed-off-by: Song Liu <songliubraving@fb.com>
> > ---
> > tools/bpf/bpftool/Makefile | 13 +++++++++++--
> > tools/bpf/bpftool/prog.c | 2 ++
> > 2 files changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index 20a90d8450f8..05a37f0f76a9 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -60,6 +60,15 @@ LIBS = $(LIBBPF) -lelf -lz
> > INSTALL ?= install
> > RM ?= rm -f
> > CLANG ?= clang
> > +CLANG_VERS = $(shell $(CLANG) --version | head -n 1 | awk '{print $$3}')
> > +CLANG_MAJ = $(shell echo $(CLANG_VERS) | cut -d '.' -f 1)
>
> This will produce error messages on stderr if clang is not installed on
> the system.
>
> > +WITHOUT_SKELETONS = -DBPFTOOL_WITHOUT_SKELETONS
> > +
> > +ifeq ($(shell test $(CLANG_MAJ) -ge 11; echo $$?),0)
>
> Not exactly what I had in mind. I thought about the feature detection
> facility we have under tools/build/feature/, as is used for e.g.
> detecting libbfd. It would allow to check the feature is available,
> instead of tying the build to a numeric version number.
+1
I think the global data feature is actually present in v10.
Version check won't work for backported clangs.
So please do feature check.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH bpf-next 2/2] bpftool: skeleton should depend on libbpf
2020-03-10 18:36 [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile Song Liu
2020-03-10 18:36 ` [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11 Song Liu
@ 2020-03-10 18:36 ` Song Liu
2020-03-10 22:00 ` [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile John Fastabend
2020-03-11 4:33 ` Andrii Nakryiko
3 siblings, 0 replies; 7+ messages in thread
From: Song Liu @ 2020-03-10 18:36 UTC (permalink / raw)
To: netdev, bpf
Cc: quentin, kernel-team, ast, daniel, arnaldo.melo, jolsa, Song Liu
Add the dependency to libbpf, to fix build errors like:
In file included from skeleton/profiler.bpf.c:5:
.../bpf_helpers.h:5:10: fatal error: 'bpf_helper_defs.h' file not found
#include "bpf_helper_defs.h"
^~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [skeleton/profiler.bpf.o] Error 1
make: *** Waiting for unfinished jobs....
Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command")
Signed-off-by: Song Liu <songliubraving@fb.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 05a37f0f76a9..0389355f8bdc 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -128,7 +128,7 @@ $(OUTPUT)_prog.o: prog.c
$(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
-skeleton/profiler.bpf.o: skeleton/profiler.bpf.c
+skeleton/profiler.bpf.o: skeleton/profiler.bpf.c $(LIBBPF)
$(QUIET_CLANG)$(CLANG) -I$(srctree)/tools/lib -g -O2 -target bpf -c $< -o $@
profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile
2020-03-10 18:36 [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile Song Liu
2020-03-10 18:36 ` [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11 Song Liu
2020-03-10 18:36 ` [PATCH bpf-next 2/2] bpftool: skeleton should depend on libbpf Song Liu
@ 2020-03-10 22:00 ` John Fastabend
2020-03-11 4:33 ` Andrii Nakryiko
3 siblings, 0 replies; 7+ messages in thread
From: John Fastabend @ 2020-03-10 22:00 UTC (permalink / raw)
To: Song Liu, netdev, bpf
Cc: quentin, kernel-team, ast, daniel, arnaldo.melo, jolsa, Song Liu
Song Liu wrote:
> 1. Fix build for older clang;
> 2. Fix skeleton's dependency on libbpf.
>
> Song Liu (2):
> bpftool: only build bpftool-prog-profile with clang >= v11
> bpftool: skeleton should depend on libbpf
>
> tools/bpf/bpftool/Makefile | 15 ++++++++++++---
> tools/bpf/bpftool/prog.c | 2 ++
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> --
> 2.17.1
Maybe instead of "Please recompile" -> "Please build" sounds a bit better
to me but that is probably a matter of preference and doesn't matter much.
Anyways for the series,
Acked-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile
2020-03-10 18:36 [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile Song Liu
` (2 preceding siblings ...)
2020-03-10 22:00 ` [PATCH bpf-next 0/2] Fixes for bpftool-prog-profile John Fastabend
@ 2020-03-11 4:33 ` Andrii Nakryiko
3 siblings, 0 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2020-03-11 4:33 UTC (permalink / raw)
To: Song Liu
Cc: Networking, bpf, quentin, Kernel Team, Alexei Starovoitov,
Daniel Borkmann, Arnaldo Carvalho de Melo, Jiri Olsa
On Tue, Mar 10, 2020 at 11:36 AM Song Liu <songliubraving@fb.com> wrote:
>
> 1. Fix build for older clang;
> 2. Fix skeleton's dependency on libbpf.
>
Can you please also add tools/bpf/bpftool/profiler.skel.h to .gitignore?
> Song Liu (2):
> bpftool: only build bpftool-prog-profile with clang >= v11
> bpftool: skeleton should depend on libbpf
>
> tools/bpf/bpftool/Makefile | 15 ++++++++++++---
> tools/bpf/bpftool/prog.c | 2 ++
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> --
> 2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread