[v2,2/3] perf build: Remove libbpf pre-1.0 feature tests
Commit Message
The feature tests were necessary for libbpf pre-1.0, but as the libbpf
implies at least 1.0 we can remove these now.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/build/feature/Makefile | 7 ---
.../feature/test-libbpf-bpf_map_create.c | 8 ----
.../test-libbpf-bpf_object__next_map.c | 8 ----
.../test-libbpf-bpf_object__next_program.c | 8 ----
.../build/feature/test-libbpf-bpf_prog_load.c | 9 ----
.../test-libbpf-bpf_program__set_insns.c | 8 ----
.../test-libbpf-btf__load_from_kernel_by_id.c | 8 ----
.../build/feature/test-libbpf-btf__raw_data.c | 8 ----
tools/perf/Makefile.config | 48 ++++---------------
9 files changed, 10 insertions(+), 102 deletions(-)
delete mode 100644 tools/build/feature/test-libbpf-bpf_map_create.c
delete mode 100644 tools/build/feature/test-libbpf-bpf_object__next_map.c
delete mode 100644 tools/build/feature/test-libbpf-bpf_object__next_program.c
delete mode 100644 tools/build/feature/test-libbpf-bpf_prog_load.c
delete mode 100644 tools/build/feature/test-libbpf-bpf_program__set_insns.c
delete mode 100644 tools/build/feature/test-libbpf-btf__load_from_kernel_by_id.c
delete mode 100644 tools/build/feature/test-libbpf-btf__raw_data.c
Comments
Em Sun, Jan 15, 2023 at 05:01:14PM -0800, Ian Rogers escreveu:
> The feature tests were necessary for libbpf pre-1.0, but as the libbpf
> implies at least 1.0 we can remove these now.
So I added this:
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 8b0bd3aa018ef166..b715cd4f43f4a014 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -580,7 +580,7 @@ ifndef NO_LIBELF
EXTLIBS += -lbpf
$(call detected,CONFIG_LIBBPF_DYNAMIC)
else
- dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
+ dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
endif
else
# Libbpf will be built as a static library from tools/lib/bpf.
To better reflect the failure reason:
⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
5 | #error At least libbpf 1.0 is required for Linux tools.
| ^~~~~
⬢[acme@toolbox perf-tools-next]$ rpm -q libbpf-devel
libbpf-devel-0.8.0-2.fc37.x86_64
⬢[acme@toolbox perf-tools-next]$
I'll see if I can make the build test conditional on libbpf being >= 1.0
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/build/feature/Makefile | 7 ---
> .../feature/test-libbpf-bpf_map_create.c | 8 ----
> .../test-libbpf-bpf_object__next_map.c | 8 ----
> .../test-libbpf-bpf_object__next_program.c | 8 ----
> .../build/feature/test-libbpf-bpf_prog_load.c | 9 ----
> .../test-libbpf-bpf_program__set_insns.c | 8 ----
> .../test-libbpf-btf__load_from_kernel_by_id.c | 8 ----
> .../build/feature/test-libbpf-btf__raw_data.c | 8 ----
> tools/perf/Makefile.config | 48 ++++---------------
> 9 files changed, 10 insertions(+), 102 deletions(-)
> delete mode 100644 tools/build/feature/test-libbpf-bpf_map_create.c
> delete mode 100644 tools/build/feature/test-libbpf-bpf_object__next_map.c
> delete mode 100644 tools/build/feature/test-libbpf-bpf_object__next_program.c
> delete mode 100644 tools/build/feature/test-libbpf-bpf_prog_load.c
> delete mode 100644 tools/build/feature/test-libbpf-bpf_program__set_insns.c
> delete mode 100644 tools/build/feature/test-libbpf-btf__load_from_kernel_by_id.c
> delete mode 100644 tools/build/feature/test-libbpf-btf__raw_data.c
>
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 690fe97be190..dc9323e01e42 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -58,13 +58,6 @@ FILES= \
> test-lzma.bin \
> test-bpf.bin \
> test-libbpf.bin \
> - test-libbpf-btf__load_from_kernel_by_id.bin \
> - test-libbpf-bpf_prog_load.bin \
> - test-libbpf-bpf_map_create.bin \
> - test-libbpf-bpf_object__next_program.bin \
> - test-libbpf-bpf_object__next_map.bin \
> - test-libbpf-bpf_program__set_insns.bin \
> - test-libbpf-btf__raw_data.bin \
> test-get_cpuid.bin \
> test-sdt.bin \
> test-cxx.bin \
> diff --git a/tools/build/feature/test-libbpf-bpf_map_create.c b/tools/build/feature/test-libbpf-bpf_map_create.c
> deleted file mode 100644
> index b9f550e332c8..000000000000
> --- a/tools/build/feature/test-libbpf-bpf_map_create.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/bpf.h>
> -
> -int main(void)
> -{
> - return bpf_map_create(0 /* map_type */, NULL /* map_name */, 0, /* key_size */,
> - 0 /* value_size */, 0 /* max_entries */, NULL /* opts */);
> -}
> diff --git a/tools/build/feature/test-libbpf-bpf_object__next_map.c b/tools/build/feature/test-libbpf-bpf_object__next_map.c
> deleted file mode 100644
> index 64adb519e97e..000000000000
> --- a/tools/build/feature/test-libbpf-bpf_object__next_map.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/libbpf.h>
> -
> -int main(void)
> -{
> - bpf_object__next_map(NULL /* obj */, NULL /* prev */);
> - return 0;
> -}
> diff --git a/tools/build/feature/test-libbpf-bpf_object__next_program.c b/tools/build/feature/test-libbpf-bpf_object__next_program.c
> deleted file mode 100644
> index 8bf4fd26b545..000000000000
> --- a/tools/build/feature/test-libbpf-bpf_object__next_program.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/libbpf.h>
> -
> -int main(void)
> -{
> - bpf_object__next_program(NULL /* obj */, NULL /* prev */);
> - return 0;
> -}
> diff --git a/tools/build/feature/test-libbpf-bpf_prog_load.c b/tools/build/feature/test-libbpf-bpf_prog_load.c
> deleted file mode 100644
> index 47f516d63ebc..000000000000
> --- a/tools/build/feature/test-libbpf-bpf_prog_load.c
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/bpf.h>
> -
> -int main(void)
> -{
> - return bpf_prog_load(0 /* prog_type */, NULL /* prog_name */,
> - NULL /* license */, NULL /* insns */,
> - 0 /* insn_cnt */, NULL /* opts */);
> -}
> diff --git a/tools/build/feature/test-libbpf-bpf_program__set_insns.c b/tools/build/feature/test-libbpf-bpf_program__set_insns.c
> deleted file mode 100644
> index f3b7f18c8f49..000000000000
> --- a/tools/build/feature/test-libbpf-bpf_program__set_insns.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/libbpf.h>
> -
> -int main(void)
> -{
> - bpf_program__set_insns(NULL /* prog */, NULL /* new_insns */, 0 /* new_insn_cnt */);
> - return 0;
> -}
> diff --git a/tools/build/feature/test-libbpf-btf__load_from_kernel_by_id.c b/tools/build/feature/test-libbpf-btf__load_from_kernel_by_id.c
> deleted file mode 100644
> index a17647f7d5a4..000000000000
> --- a/tools/build/feature/test-libbpf-btf__load_from_kernel_by_id.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/btf.h>
> -
> -int main(void)
> -{
> - btf__load_from_kernel_by_id(20151128);
> - return 0;
> -}
> diff --git a/tools/build/feature/test-libbpf-btf__raw_data.c b/tools/build/feature/test-libbpf-btf__raw_data.c
> deleted file mode 100644
> index 57da31dd7581..000000000000
> --- a/tools/build/feature/test-libbpf-btf__raw_data.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -#include <bpf/btf.h>
> -
> -int main(void)
> -{
> - btf__raw_data(NULL /* btf_ro */, NULL /* size */);
> - return 0;
> -}
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 5b8784675903..5ab7cac48c4a 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -565,54 +565,26 @@ ifndef NO_LIBELF
>
> # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
> $(call feature_check,libbpf)
> +
> + # Feature test requires libbpf 1.0 so we can assume the following:
> + CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
> + CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
> + CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
> + CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
> + CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
> + CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
> + CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
> +
> ifdef LIBBPF_DYNAMIC
> ifeq ($(feature-libbpf), 1)
> EXTLIBS += -lbpf
> $(call detected,CONFIG_LIBBPF_DYNAMIC)
> -
> - $(call feature_check,libbpf-btf__load_from_kernel_by_id)
> - ifeq ($(feature-libbpf-btf__load_from_kernel_by_id), 1)
> - CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
> - endif
> - $(call feature_check,libbpf-bpf_prog_load)
> - ifeq ($(feature-libbpf-bpf_prog_load), 1)
> - CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
> - endif
> - $(call feature_check,libbpf-bpf_object__next_program)
> - ifeq ($(feature-libbpf-bpf_object__next_program), 1)
> - CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
> - endif
> - $(call feature_check,libbpf-bpf_object__next_map)
> - ifeq ($(feature-libbpf-bpf_object__next_map), 1)
> - CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
> - endif
> - $(call feature_check,libbpf-bpf_program__set_insns)
> - ifeq ($(feature-libbpf-bpf_program__set_insns), 1)
> - CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
> - else
> - dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
> - endif
> - $(call feature_check,libbpf-btf__raw_data)
> - ifeq ($(feature-libbpf-btf__raw_data), 1)
> - CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
> - endif
> - $(call feature_check,libbpf-bpf_map_create)
> - ifeq ($(feature-libbpf-bpf_map_create), 1)
> - CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
> - endif
> else
> dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
> endif
> else
> # Libbpf will be built as a static library from tools/lib/bpf.
> LIBBPF_STATIC := 1
> - CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
> - CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
> - CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
> - CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
> - CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
> - CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
> - CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
> endif
> endif
>
> --
> 2.39.0.314.g84b9a713c41-goog
Em Mon, Mar 13, 2023 at 06:10:40PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Jan 15, 2023 at 05:01:14PM -0800, Ian Rogers escreveu:
> > The feature tests were necessary for libbpf pre-1.0, but as the libbpf
> > implies at least 1.0 we can remove these now.
>
> So I added this:
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 8b0bd3aa018ef166..b715cd4f43f4a014 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -580,7 +580,7 @@ ifndef NO_LIBELF
> EXTLIBS += -lbpf
> $(call detected,CONFIG_LIBBPF_DYNAMIC)
> else
> - dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
> + dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
> endif
> else
> # Libbpf will be built as a static library from tools/lib/bpf.
>
> To better reflect the failure reason:
>
> ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
> test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
> 5 | #error At least libbpf 1.0 is required for Linux tools.
> | ^~~~~
> ⬢[acme@toolbox perf-tools-next]$ rpm -q libbpf-devel
> libbpf-devel-0.8.0-2.fc37.x86_64
> ⬢[acme@toolbox perf-tools-next]$
>
> I'll see if I can make the build test conditional on libbpf being >= 1.0
I'm trying with this:
⬢[acme@toolbox libbpf]$ git log --oneline -1 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
9476dce6fe905a6b libbpf: remove deprecated low-level APIs
⬢[acme@toolbox libbpf]$ git tag --contains 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
v1.0.0
v1.0.1
v1.1.0
⬢[acme@toolbox libbpf]$
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 531324c3dab594e1..f866c58b916f4d7a 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -63,6 +63,7 @@ endif
has = $(shell which $1 2>/dev/null)
python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
+old_libbpf := $(shell grep -q LIBBPF_DEPRECATED /usr/include/bpf/bpf.h)
# standard single make variable specified
make_clean_all := clean all
@@ -151,7 +152,9 @@ run += make_no_libaudit
run += make_no_libbionic
run += make_no_auxtrace
run += make_no_libbpf
+ifneq ($(old_libbpf),)
run += make_libbpf_dynamic
+endif
run += make_no_libbpf_DEBUG
run += make_no_libcrypto
run += make_no_sdt
On Mon, Mar 13, 2023 at 2:38 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Mon, Mar 13, 2023 at 06:10:40PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Sun, Jan 15, 2023 at 05:01:14PM -0800, Ian Rogers escreveu:
> > > The feature tests were necessary for libbpf pre-1.0, but as the libbpf
> > > implies at least 1.0 we can remove these now.
> >
> > So I added this:
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 8b0bd3aa018ef166..b715cd4f43f4a014 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -580,7 +580,7 @@ ifndef NO_LIBELF
> > EXTLIBS += -lbpf
> > $(call detected,CONFIG_LIBBPF_DYNAMIC)
> > else
> > - dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
> > + dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
> > endif
> > else
> > # Libbpf will be built as a static library from tools/lib/bpf.
> >
> > To better reflect the failure reason:
> >
> > ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
> > test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
> > 5 | #error At least libbpf 1.0 is required for Linux tools.
> > | ^~~~~
> > ⬢[acme@toolbox perf-tools-next]$ rpm -q libbpf-devel
> > libbpf-devel-0.8.0-2.fc37.x86_64
> > ⬢[acme@toolbox perf-tools-next]$
> >
> > I'll see if I can make the build test conditional on libbpf being >= 1.0
>
> I'm trying with this:
>
> ⬢[acme@toolbox libbpf]$ git log --oneline -1 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> 9476dce6fe905a6b libbpf: remove deprecated low-level APIs
> ⬢[acme@toolbox libbpf]$ git tag --contains 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> v1.0.0
> v1.0.1
> v1.1.0
> ⬢[acme@toolbox libbpf]$
>
> diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> index 531324c3dab594e1..f866c58b916f4d7a 100644
> --- a/tools/perf/tests/make
> +++ b/tools/perf/tests/make
> @@ -63,6 +63,7 @@ endif
>
> has = $(shell which $1 2>/dev/null)
> python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
> +old_libbpf := $(shell grep -q LIBBPF_DEPRECATED /usr/include/bpf/bpf.h)
I think this could also be:
old_libbpf := $(shell grep MAJOR /usr/include/bpf/libbpf_version.h
2>&1 |grep -q 0)
Which may be a bit more intention revealing and future proof.
Thanks,
Ian
> # standard single make variable specified
> make_clean_all := clean all
> @@ -151,7 +152,9 @@ run += make_no_libaudit
> run += make_no_libbionic
> run += make_no_auxtrace
> run += make_no_libbpf
> +ifneq ($(old_libbpf),)
> run += make_libbpf_dynamic
> +endif
> run += make_no_libbpf_DEBUG
> run += make_no_libcrypto
> run += make_no_sdt
On Mon, Mar 13, 2023 at 5:19 PM Ian Rogers <irogers@google.com> wrote:
>
> On Mon, Mar 13, 2023 at 2:38 PM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Mon, Mar 13, 2023 at 06:10:40PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Sun, Jan 15, 2023 at 05:01:14PM -0800, Ian Rogers escreveu:
> > > > The feature tests were necessary for libbpf pre-1.0, but as the libbpf
> > > > implies at least 1.0 we can remove these now.
> > >
> > > So I added this:
> > >
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index 8b0bd3aa018ef166..b715cd4f43f4a014 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -580,7 +580,7 @@ ifndef NO_LIBELF
> > > EXTLIBS += -lbpf
> > > $(call detected,CONFIG_LIBBPF_DYNAMIC)
> > > else
> > > - dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
> > > + dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
> > > endif
> > > else
> > > # Libbpf will be built as a static library from tools/lib/bpf.
> > >
> > > To better reflect the failure reason:
> > >
> > > ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
> > > test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
> > > 5 | #error At least libbpf 1.0 is required for Linux tools.
> > > | ^~~~~
> > > ⬢[acme@toolbox perf-tools-next]$ rpm -q libbpf-devel
> > > libbpf-devel-0.8.0-2.fc37.x86_64
> > > ⬢[acme@toolbox perf-tools-next]$
> > >
> > > I'll see if I can make the build test conditional on libbpf being >= 1.0
> >
> > I'm trying with this:
> >
> > ⬢[acme@toolbox libbpf]$ git log --oneline -1 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> > 9476dce6fe905a6b libbpf: remove deprecated low-level APIs
> > ⬢[acme@toolbox libbpf]$ git tag --contains 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> > v1.0.0
> > v1.0.1
> > v1.1.0
> > ⬢[acme@toolbox libbpf]$
> >
> > diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> > index 531324c3dab594e1..f866c58b916f4d7a 100644
> > --- a/tools/perf/tests/make
> > +++ b/tools/perf/tests/make
> > @@ -63,6 +63,7 @@ endif
> >
> > has = $(shell which $1 2>/dev/null)
> > python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
> > +old_libbpf := $(shell grep -q LIBBPF_DEPRECATED /usr/include/bpf/bpf.h)
>
> I think this could also be:
> old_libbpf := $(shell grep MAJOR /usr/include/bpf/libbpf_version.h
> 2>&1 |grep -q 0)
> Which may be a bit more intention revealing and future proof.
>
> Thanks,
> Ian
To avoid /usr/include assumptions, there's also:
old_libbpf := $(shell echo "#include <bpf/libbpf.h>" | $(CC) -E -dM -x
c -|grep "define LIBBPF_MAJOR_VERSION"|grep -q 0)
:-)
Ian
> > # standard single make variable specified
> > make_clean_all := clean all
> > @@ -151,7 +152,9 @@ run += make_no_libaudit
> > run += make_no_libbionic
> > run += make_no_auxtrace
> > run += make_no_libbpf
> > +ifneq ($(old_libbpf),)
> > run += make_libbpf_dynamic
> > +endif
> > run += make_no_libbpf_DEBUG
> > run += make_no_libcrypto
> > run += make_no_sdt
Em Mon, Mar 13, 2023 at 05:19:45PM -0700, Ian Rogers escreveu:
> On Mon, Mar 13, 2023 at 2:38 PM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Mon, Mar 13, 2023 at 06:10:40PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Sun, Jan 15, 2023 at 05:01:14PM -0800, Ian Rogers escreveu:
> > > > The feature tests were necessary for libbpf pre-1.0, but as the libbpf
> > > > implies at least 1.0 we can remove these now.
> > >
> > > So I added this:
> > >
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index 8b0bd3aa018ef166..b715cd4f43f4a014 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -580,7 +580,7 @@ ifndef NO_LIBELF
> > > EXTLIBS += -lbpf
> > > $(call detected,CONFIG_LIBBPF_DYNAMIC)
> > > else
> > > - dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
> > > + dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
> > > endif
> > > else
> > > # Libbpf will be built as a static library from tools/lib/bpf.
> > >
> > > To better reflect the failure reason:
> > >
> > > ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
> > > test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
> > > 5 | #error At least libbpf 1.0 is required for Linux tools.
> > > | ^~~~~
> > > ⬢[acme@toolbox perf-tools-next]$ rpm -q libbpf-devel
> > > libbpf-devel-0.8.0-2.fc37.x86_64
> > > ⬢[acme@toolbox perf-tools-next]$
> > >
> > > I'll see if I can make the build test conditional on libbpf being >= 1.0
> >
> > I'm trying with this:
> >
> > ⬢[acme@toolbox libbpf]$ git log --oneline -1 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> > 9476dce6fe905a6b libbpf: remove deprecated low-level APIs
> > ⬢[acme@toolbox libbpf]$ git tag --contains 9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
> > v1.0.0
> > v1.0.1
> > v1.1.0
> > ⬢[acme@toolbox libbpf]$
> >
> > diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> > index 531324c3dab594e1..f866c58b916f4d7a 100644
> > --- a/tools/perf/tests/make
> > +++ b/tools/perf/tests/make
> > @@ -63,6 +63,7 @@ endif
> >
> > has = $(shell which $1 2>/dev/null)
> > python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
> > +old_libbpf := $(shell grep -q LIBBPF_DEPRECATED /usr/include/bpf/bpf.h)
>
> I think this could also be:
> old_libbpf := $(shell grep MAJOR /usr/include/bpf/libbpf_version.h
> 2>&1 |grep -q 0)
> Which may be a bit more intention revealing and future proof.
Thanks, I used:
old_libbpf := $(shell echo "#include <bpf/libbpf.h>" | $(CC) -E -dM -x c -| egrep -q "define[[:space:]]+LIBBPF_MAJOR_VERSION[[:space:]]+0{1}")
- Arnaldo
@@ -58,13 +58,6 @@ FILES= \
test-lzma.bin \
test-bpf.bin \
test-libbpf.bin \
- test-libbpf-btf__load_from_kernel_by_id.bin \
- test-libbpf-bpf_prog_load.bin \
- test-libbpf-bpf_map_create.bin \
- test-libbpf-bpf_object__next_program.bin \
- test-libbpf-bpf_object__next_map.bin \
- test-libbpf-bpf_program__set_insns.bin \
- test-libbpf-btf__raw_data.bin \
test-get_cpuid.bin \
test-sdt.bin \
test-cxx.bin \
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/bpf.h>
-
-int main(void)
-{
- return bpf_map_create(0 /* map_type */, NULL /* map_name */, 0, /* key_size */,
- 0 /* value_size */, 0 /* max_entries */, NULL /* opts */);
-}
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/libbpf.h>
-
-int main(void)
-{
- bpf_object__next_map(NULL /* obj */, NULL /* prev */);
- return 0;
-}
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/libbpf.h>
-
-int main(void)
-{
- bpf_object__next_program(NULL /* obj */, NULL /* prev */);
- return 0;
-}
deleted file mode 100644
@@ -1,9 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/bpf.h>
-
-int main(void)
-{
- return bpf_prog_load(0 /* prog_type */, NULL /* prog_name */,
- NULL /* license */, NULL /* insns */,
- 0 /* insn_cnt */, NULL /* opts */);
-}
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/libbpf.h>
-
-int main(void)
-{
- bpf_program__set_insns(NULL /* prog */, NULL /* new_insns */, 0 /* new_insn_cnt */);
- return 0;
-}
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/btf.h>
-
-int main(void)
-{
- btf__load_from_kernel_by_id(20151128);
- return 0;
-}
deleted file mode 100644
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <bpf/btf.h>
-
-int main(void)
-{
- btf__raw_data(NULL /* btf_ro */, NULL /* size */);
- return 0;
-}
@@ -565,54 +565,26 @@ ifndef NO_LIBELF
# detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
$(call feature_check,libbpf)
+
+ # Feature test requires libbpf 1.0 so we can assume the following:
+ CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
+ CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
+ CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
+ CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
+ CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
+ CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
+ CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
+
ifdef LIBBPF_DYNAMIC
ifeq ($(feature-libbpf), 1)
EXTLIBS += -lbpf
$(call detected,CONFIG_LIBBPF_DYNAMIC)
-
- $(call feature_check,libbpf-btf__load_from_kernel_by_id)
- ifeq ($(feature-libbpf-btf__load_from_kernel_by_id), 1)
- CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
- endif
- $(call feature_check,libbpf-bpf_prog_load)
- ifeq ($(feature-libbpf-bpf_prog_load), 1)
- CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
- endif
- $(call feature_check,libbpf-bpf_object__next_program)
- ifeq ($(feature-libbpf-bpf_object__next_program), 1)
- CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
- endif
- $(call feature_check,libbpf-bpf_object__next_map)
- ifeq ($(feature-libbpf-bpf_object__next_map), 1)
- CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
- endif
- $(call feature_check,libbpf-bpf_program__set_insns)
- ifeq ($(feature-libbpf-bpf_program__set_insns), 1)
- CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
- else
- dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
- endif
- $(call feature_check,libbpf-btf__raw_data)
- ifeq ($(feature-libbpf-btf__raw_data), 1)
- CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
- endif
- $(call feature_check,libbpf-bpf_map_create)
- ifeq ($(feature-libbpf-bpf_map_create), 1)
- CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
- endif
else
dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
endif
else
# Libbpf will be built as a static library from tools/lib/bpf.
LIBBPF_STATIC := 1
- CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
- CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
- CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
- CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
- CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
- CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
- CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
endif
endif