linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] bpftool: Fix the static linkage failure
@ 2024-12-11  9:31 Leo Yan
  2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Leo Yan @ 2024-12-11  9:31 UTC (permalink / raw)
  To: Quentin Monnet, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users
  Cc: Leo Yan

This series follows up on the discussion in [1] for fixing the static
linkage issue in bpftool.

Patch 01 introduces a new feature for libelf-zstd.  If this feature
is detected, it means the zstd lib is required by libelf.

Patch 02 is a minor improvement for linking the zstd lib in the perf.

Patch 03 fixes the static build failure by linking the zstd lib when
the feature-libelf-zstd is detected.

[1] https://lore.kernel.org/linux-perf-users/Z1H9-9xrWM4FBbNI@mini-arch/T/#m2300b127424e9e2ace7da497a20d88534eb6866f


Leo Yan (3):
  tools build: Add feature test for libelf with ZSTD
  perf: build: Minor improvement for linking libzstd
  bpftool: Link zstd lib required by libelf

 tools/bpf/bpftool/Makefile             | 8 ++++++++
 tools/build/Makefile.feature           | 1 +
 tools/build/feature/Makefile           | 4 ++++
 tools/build/feature/test-all.c         | 4 ++++
 tools/build/feature/test-libelf-zstd.c | 9 +++++++++
 tools/perf/Makefile.config             | 8 +++++++-
 6 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 tools/build/feature/test-libelf-zstd.c

-- 
2.34.1


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

* [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD
  2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
@ 2024-12-11  9:31 ` Leo Yan
  2024-12-11 12:48   ` Quentin Monnet
  2024-12-11 15:05   ` Jiri Olsa
  2024-12-11  9:31 ` [PATCH v2 2/3] perf: build: Minor improvement for linking libzstd Leo Yan
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Leo Yan @ 2024-12-11  9:31 UTC (permalink / raw)
  To: Quentin Monnet, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users
  Cc: Leo Yan

Add a test for checking if libelf supports ZSTD compress algorithm.

The macro ELFCOMPRESS_ZSTD is defined for the algorithm, pass it as an
argument to the elf_compress() function.  If the build succeeds, it
means the feature is supported.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/build/Makefile.feature           | 1 +
 tools/build/feature/Makefile           | 4 ++++
 tools/build/feature/test-all.c         | 4 ++++
 tools/build/feature/test-libelf-zstd.c | 9 +++++++++
 4 files changed, 18 insertions(+)
 create mode 100644 tools/build/feature/test-libelf-zstd.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index bca47d136f05..b2884bc23775 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -43,6 +43,7 @@ FEATURE_TESTS_BASIC :=                  \
         libelf-getphdrnum               \
         libelf-gelf_getnote             \
         libelf-getshdrstrndx            \
+        libelf-zstd                     \
         libnuma                         \
         numa_num_possible_cpus          \
         libperl                         \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 043dfd00fce7..f12b89103d7a 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -28,6 +28,7 @@ FILES=                                          \
          test-libelf-getphdrnum.bin             \
          test-libelf-gelf_getnote.bin           \
          test-libelf-getshdrstrndx.bin          \
+         test-libelf-zstd.bin                   \
          test-libdebuginfod.bin                 \
          test-libnuma.bin                       \
          test-numa_num_possible_cpus.bin        \
@@ -196,6 +197,9 @@ $(OUTPUT)test-libelf-gelf_getnote.bin:
 $(OUTPUT)test-libelf-getshdrstrndx.bin:
 	$(BUILD) -lelf
 
+$(OUTPUT)test-libelf-zstd.bin:
+	$(BUILD) -lelf -lz -lzstd
+
 $(OUTPUT)test-libdebuginfod.bin:
 	$(BUILD) -ldebuginfod
 
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 80ac297f8196..67125f967860 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -58,6 +58,10 @@
 # include "test-libelf-getshdrstrndx.c"
 #undef main
 
+#define main main_test_libelf_zstd
+# include "test-libelf-zstd.c"
+#undef main
+
 #define main main_test_libslang
 # include "test-libslang.c"
 #undef main
diff --git a/tools/build/feature/test-libelf-zstd.c b/tools/build/feature/test-libelf-zstd.c
new file mode 100644
index 000000000000..a1324a1db3bb
--- /dev/null
+++ b/tools/build/feature/test-libelf-zstd.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <stddef.h>
+#include <libelf.h>
+
+int main(void)
+{
+	elf_compress(NULL, ELFCOMPRESS_ZSTD, 0);
+	return 0;
+}
-- 
2.34.1


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

* [PATCH v2 2/3] perf: build: Minor improvement for linking libzstd
  2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
  2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
@ 2024-12-11  9:31 ` Leo Yan
  2024-12-11  9:31 ` [PATCH v2 3/3] bpftool: Link zstd lib required by libelf Leo Yan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Leo Yan @ 2024-12-11  9:31 UTC (permalink / raw)
  To: Quentin Monnet, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users
  Cc: Leo Yan

The zstd library will be automatically linked automatically by detecting
the feature-libzstd.  It is no need to explicitly link it for static
builds, so remove the redundant linkage.

It is contradictory to detect the feature-libelf-zstd while the build
configuration NO_LIBZSTD is set.  Report an error for reminding users
not to set NO_LIBZSTD.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.config | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0e4f6a860ae2..155cb9d20011 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -171,7 +171,7 @@ ifdef LIBDW_DIR
 endif
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
+  DWARFLIBS += -lelf -lz -llzma -lbz2
 
   LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
@@ -566,6 +566,12 @@ ifndef NO_LIBELF
     CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT
   endif
 
+  ifeq ($(feature-libelf-zstd), 1)
+    ifdef NO_LIBZSTD
+      $(error Error: libzstd is required by libelf, please do not set NO_LIBZSTD)
+    endif
+  endif
+
   ifndef NO_LIBDEBUGINFOD
     $(call feature_check,libdebuginfod)
     ifeq ($(feature-libdebuginfod), 1)
-- 
2.34.1


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

* [PATCH v2 3/3] bpftool: Link zstd lib required by libelf
  2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
  2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
  2024-12-11  9:31 ` [PATCH v2 2/3] perf: build: Minor improvement for linking libzstd Leo Yan
@ 2024-12-11  9:31 ` Leo Yan
  2024-12-11 12:48   ` Quentin Monnet
  2024-12-11 13:18 ` [PATCH v2 0/3] bpftool: Fix the static linkage failure Arnaldo Carvalho de Melo
  2024-12-11 19:44 ` Namhyung Kim
  4 siblings, 1 reply; 11+ messages in thread
From: Leo Yan @ 2024-12-11  9:31 UTC (permalink / raw)
  To: Quentin Monnet, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users
  Cc: Leo Yan

When the feature-libelf-zstd is detected, the zstd lib is required by
libelf.  Link the zstd lib in this case.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/bpf/bpftool/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index a4263dfb5e03..469f841abaff 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -106,6 +106,7 @@ FEATURE_TESTS += libbfd-liberty
 FEATURE_TESTS += libbfd-liberty-z
 FEATURE_TESTS += disassembler-four-args
 FEATURE_TESTS += disassembler-init-styled
+FEATURE_TESTS += libelf-zstd
 
 FEATURE_DISPLAY := clang-bpf-co-re
 FEATURE_DISPLAY += llvm
@@ -113,6 +114,7 @@ FEATURE_DISPLAY += libcap
 FEATURE_DISPLAY += libbfd
 FEATURE_DISPLAY += libbfd-liberty
 FEATURE_DISPLAY += libbfd-liberty-z
+FEATURE_DISPLAY += libelf-zstd
 
 check_feat := 1
 NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall
@@ -132,6 +134,12 @@ endif
 
 LIBS = $(LIBBPF) -lelf -lz
 LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz
+
+ifeq ($(feature-libelf-zstd),1)
+LIBS += -lzstd
+LIBS_BOOTSTRAP += -lzstd
+endif
+
 ifeq ($(feature-libcap), 1)
 CFLAGS += -DUSE_LIBCAP
 LIBS += -lcap
-- 
2.34.1


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

* Re: [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD
  2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
@ 2024-12-11 12:48   ` Quentin Monnet
  2024-12-11 15:05   ` Jiri Olsa
  1 sibling, 0 replies; 11+ messages in thread
From: Quentin Monnet @ 2024-12-11 12:48 UTC (permalink / raw)
  To: Leo Yan, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users

2024-12-11 09:31 UTC+0000 ~ Leo Yan <leo.yan@arm.com>
> Add a test for checking if libelf supports ZSTD compress algorithm.
> 
> The macro ELFCOMPRESS_ZSTD is defined for the algorithm, pass it as an
> argument to the elf_compress() function.  If the build succeeds, it
> means the feature is supported.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/build/Makefile.feature           | 1 +
>  tools/build/feature/Makefile           | 4 ++++
>  tools/build/feature/test-all.c         | 4 ++++
>  tools/build/feature/test-libelf-zstd.c | 9 +++++++++
>  4 files changed, 18 insertions(+)
>  create mode 100644 tools/build/feature/test-libelf-zstd.c
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index bca47d136f05..b2884bc23775 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -43,6 +43,7 @@ FEATURE_TESTS_BASIC :=                  \
>          libelf-getphdrnum               \
>          libelf-gelf_getnote             \
>          libelf-getshdrstrndx            \
> +        libelf-zstd                     \
>          libnuma                         \
>          numa_num_possible_cpus          \
>          libperl                         \
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 043dfd00fce7..f12b89103d7a 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -28,6 +28,7 @@ FILES=                                          \
>           test-libelf-getphdrnum.bin             \
>           test-libelf-gelf_getnote.bin           \
>           test-libelf-getshdrstrndx.bin          \
> +         test-libelf-zstd.bin                   \
>           test-libdebuginfod.bin                 \
>           test-libnuma.bin                       \
>           test-numa_num_possible_cpus.bin        \
> @@ -196,6 +197,9 @@ $(OUTPUT)test-libelf-gelf_getnote.bin:
>  $(OUTPUT)test-libelf-getshdrstrndx.bin:
>  	$(BUILD) -lelf
>  
> +$(OUTPUT)test-libelf-zstd.bin:
> +	$(BUILD) -lelf -lz -lzstd
> +
>  $(OUTPUT)test-libdebuginfod.bin:
>  	$(BUILD) -ldebuginfod
>  
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index 80ac297f8196..67125f967860 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -58,6 +58,10 @@
>  # include "test-libelf-getshdrstrndx.c"
>  #undef main
>  
> +#define main main_test_libelf_zstd
> +# include "test-libelf-zstd.c"
> +#undef main
> +
>  #define main main_test_libslang
>  # include "test-libslang.c"
>  #undef main
> diff --git a/tools/build/feature/test-libelf-zstd.c b/tools/build/feature/test-libelf-zstd.c
> new file mode 100644
> index 000000000000..a1324a1db3bb
> --- /dev/null
> +++ b/tools/build/feature/test-libelf-zstd.c
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <stddef.h>
> +#include <libelf.h>
> +
> +int main(void)
> +{
> +	elf_compress(NULL, ELFCOMPRESS_ZSTD, 0);
> +	return 0;
> +}


It's not obvious that the feature indicates that (in the case of
bpftool) support for ZSTD _must_ be added when the probe builds, it
reads more like it _can_ be added if we're after the feature, but that's
fine by me. I double-checked and ELFCOMPRESS_ZSTD support was introduced
in libelf 0.189 indeed, which is the version introducing the linkage
issue for static bpftool builds (maybe this is some info we could
mention in the commit description, by the way). As expected, the probe
sample fails to build on Ubuntu 22.04 (libelf 0.186) but passes on
Ubuntu 24.04 (libelf 0.190). Thanks!

Tested-by: Quentin Monnet <qmo@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>

Note: This being a bpftool fix, I suppose you're targetting the bpf-next
tree? If so, you've got a conflict on test-all.c given that commit
176c9d1e6a06 ("tools features: Don't check for libunwind devel files by
default") has not been synced there yet.

Thanks,
Quentin

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

* Re: [PATCH v2 3/3] bpftool: Link zstd lib required by libelf
  2024-12-11  9:31 ` [PATCH v2 3/3] bpftool: Link zstd lib required by libelf Leo Yan
@ 2024-12-11 12:48   ` Quentin Monnet
  0 siblings, 0 replies; 11+ messages in thread
From: Quentin Monnet @ 2024-12-11 12:48 UTC (permalink / raw)
  To: Leo Yan, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users

2024-12-11 09:31 UTC+0000 ~ Leo Yan <leo.yan@arm.com>
> When the feature-libelf-zstd is detected, the zstd lib is required by
> libelf.  Link the zstd lib in this case.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/bpf/bpftool/Makefile | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index a4263dfb5e03..469f841abaff 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -106,6 +106,7 @@ FEATURE_TESTS += libbfd-liberty
>  FEATURE_TESTS += libbfd-liberty-z
>  FEATURE_TESTS += disassembler-four-args
>  FEATURE_TESTS += disassembler-init-styled
> +FEATURE_TESTS += libelf-zstd
>  
>  FEATURE_DISPLAY := clang-bpf-co-re
>  FEATURE_DISPLAY += llvm
> @@ -113,6 +114,7 @@ FEATURE_DISPLAY += libcap
>  FEATURE_DISPLAY += libbfd
>  FEATURE_DISPLAY += libbfd-liberty
>  FEATURE_DISPLAY += libbfd-liberty-z
> +FEATURE_DISPLAY += libelf-zstd


Let's not display this one, please, it brings no information to the user
about what features bpftool will support.

Looks good otherwise, thank you!


>  
>  check_feat := 1
>  NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall
> @@ -132,6 +134,12 @@ endif
>  
>  LIBS = $(LIBBPF) -lelf -lz
>  LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz
> +
> +ifeq ($(feature-libelf-zstd),1)
> +LIBS += -lzstd
> +LIBS_BOOTSTRAP += -lzstd
> +endif
> +
>  ifeq ($(feature-libcap), 1)
>  CFLAGS += -DUSE_LIBCAP
>  LIBS += -lcap


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

* Re: [PATCH v2 0/3] bpftool: Fix the static linkage failure
  2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
                   ` (2 preceding siblings ...)
  2024-12-11  9:31 ` [PATCH v2 3/3] bpftool: Link zstd lib required by libelf Leo Yan
@ 2024-12-11 13:18 ` Arnaldo Carvalho de Melo
  2024-12-11 20:26   ` Leo Yan
  2024-12-11 19:44 ` Namhyung Kim
  4 siblings, 1 reply; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-12-11 13:18 UTC (permalink / raw)
  To: Leo Yan
  Cc: Quentin Monnet, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Nick Terrell, Ian Rogers, Adrian Hunter,
	Liang, Kan, James Clark, Guilherme Amadio, linux-kernel, bpf,
	linux-perf-users

On Wed, Dec 11, 2024 at 09:31:11AM +0000, Leo Yan wrote:
> This series follows up on the discussion in [1] for fixing the static
> linkage issue in bpftool.
> 
> Patch 01 introduces a new feature for libelf-zstd.  If this feature
> is detected, it means the zstd lib is required by libelf.
> 
> Patch 02 is a minor improvement for linking the zstd lib in the perf.
> 
> Patch 03 fixes the static build failure by linking the zstd lib when
> the feature-libelf-zstd is detected.
> 
> [1] https://lore.kernel.org/linux-perf-users/Z1H9-9xrWM4FBbNI@mini-arch/T/#m2300b127424e9e2ace7da497a20d88534eb6866f

So, this was originally reported as a perf build failure when trying a
static build, so something not so common, no urgency, I guess, but it
involves a tools/perf/bpftool/Makefile change, I think I can process
this as I'll then test it in the many build containers for old distros I
have, ok?

- Arnaldo
 
> 
> Leo Yan (3):
>   tools build: Add feature test for libelf with ZSTD
>   perf: build: Minor improvement for linking libzstd
>   bpftool: Link zstd lib required by libelf
> 
>  tools/bpf/bpftool/Makefile             | 8 ++++++++
>  tools/build/Makefile.feature           | 1 +
>  tools/build/feature/Makefile           | 4 ++++
>  tools/build/feature/test-all.c         | 4 ++++
>  tools/build/feature/test-libelf-zstd.c | 9 +++++++++
>  tools/perf/Makefile.config             | 8 +++++++-
>  6 files changed, 33 insertions(+), 1 deletion(-)
>  create mode 100644 tools/build/feature/test-libelf-zstd.c
> 
> -- 
> 2.34.1

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

* Re: [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD
  2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
  2024-12-11 12:48   ` Quentin Monnet
@ 2024-12-11 15:05   ` Jiri Olsa
  1 sibling, 0 replies; 11+ messages in thread
From: Jiri Olsa @ 2024-12-11 15:05 UTC (permalink / raw)
  To: Leo Yan
  Cc: Quentin Monnet, Arnaldo Carvalho de Melo, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users

On Wed, Dec 11, 2024 at 09:31:12AM +0000, Leo Yan wrote:
> Add a test for checking if libelf supports ZSTD compress algorithm.
> 
> The macro ELFCOMPRESS_ZSTD is defined for the algorithm, pass it as an
> argument to the elf_compress() function.  If the build succeeds, it
> means the feature is supported.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>

lgtm

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  tools/build/Makefile.feature           | 1 +
>  tools/build/feature/Makefile           | 4 ++++
>  tools/build/feature/test-all.c         | 4 ++++
>  tools/build/feature/test-libelf-zstd.c | 9 +++++++++
>  4 files changed, 18 insertions(+)
>  create mode 100644 tools/build/feature/test-libelf-zstd.c
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index bca47d136f05..b2884bc23775 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -43,6 +43,7 @@ FEATURE_TESTS_BASIC :=                  \
>          libelf-getphdrnum               \
>          libelf-gelf_getnote             \
>          libelf-getshdrstrndx            \
> +        libelf-zstd                     \
>          libnuma                         \
>          numa_num_possible_cpus          \
>          libperl                         \
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 043dfd00fce7..f12b89103d7a 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -28,6 +28,7 @@ FILES=                                          \
>           test-libelf-getphdrnum.bin             \
>           test-libelf-gelf_getnote.bin           \
>           test-libelf-getshdrstrndx.bin          \
> +         test-libelf-zstd.bin                   \
>           test-libdebuginfod.bin                 \
>           test-libnuma.bin                       \
>           test-numa_num_possible_cpus.bin        \
> @@ -196,6 +197,9 @@ $(OUTPUT)test-libelf-gelf_getnote.bin:
>  $(OUTPUT)test-libelf-getshdrstrndx.bin:
>  	$(BUILD) -lelf
>  
> +$(OUTPUT)test-libelf-zstd.bin:
> +	$(BUILD) -lelf -lz -lzstd
> +
>  $(OUTPUT)test-libdebuginfod.bin:
>  	$(BUILD) -ldebuginfod
>  
> diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
> index 80ac297f8196..67125f967860 100644
> --- a/tools/build/feature/test-all.c
> +++ b/tools/build/feature/test-all.c
> @@ -58,6 +58,10 @@
>  # include "test-libelf-getshdrstrndx.c"
>  #undef main
>  
> +#define main main_test_libelf_zstd
> +# include "test-libelf-zstd.c"
> +#undef main
> +
>  #define main main_test_libslang
>  # include "test-libslang.c"
>  #undef main
> diff --git a/tools/build/feature/test-libelf-zstd.c b/tools/build/feature/test-libelf-zstd.c
> new file mode 100644
> index 000000000000..a1324a1db3bb
> --- /dev/null
> +++ b/tools/build/feature/test-libelf-zstd.c
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <stddef.h>
> +#include <libelf.h>
> +
> +int main(void)
> +{
> +	elf_compress(NULL, ELFCOMPRESS_ZSTD, 0);
> +	return 0;
> +}
> -- 
> 2.34.1
> 

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

* Re: [PATCH v2 0/3] bpftool: Fix the static linkage failure
  2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
                   ` (3 preceding siblings ...)
  2024-12-11 13:18 ` [PATCH v2 0/3] bpftool: Fix the static linkage failure Arnaldo Carvalho de Melo
@ 2024-12-11 19:44 ` Namhyung Kim
  4 siblings, 0 replies; 11+ messages in thread
From: Namhyung Kim @ 2024-12-11 19:44 UTC (permalink / raw)
  To: Leo Yan
  Cc: Quentin Monnet, Arnaldo Carvalho de Melo, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau,
	Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Nick Terrell,
	Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users

On Wed, Dec 11, 2024 at 09:31:11AM +0000, Leo Yan wrote:
> This series follows up on the discussion in [1] for fixing the static
> linkage issue in bpftool.
> 
> Patch 01 introduces a new feature for libelf-zstd.  If this feature
> is detected, it means the zstd lib is required by libelf.
> 
> Patch 02 is a minor improvement for linking the zstd lib in the perf.
> 
> Patch 03 fixes the static build failure by linking the zstd lib when
> the feature-libelf-zstd is detected.
> 
> [1] https://lore.kernel.org/linux-perf-users/Z1H9-9xrWM4FBbNI@mini-arch/T/#m2300b127424e9e2ace7da497a20d88534eb6866f
> 
> 
> Leo Yan (3):
>   tools build: Add feature test for libelf with ZSTD
>   perf: build: Minor improvement for linking libzstd
>   bpftool: Link zstd lib required by libelf

Tested-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> 
>  tools/bpf/bpftool/Makefile             | 8 ++++++++
>  tools/build/Makefile.feature           | 1 +
>  tools/build/feature/Makefile           | 4 ++++
>  tools/build/feature/test-all.c         | 4 ++++
>  tools/build/feature/test-libelf-zstd.c | 9 +++++++++
>  tools/perf/Makefile.config             | 8 +++++++-
>  6 files changed, 33 insertions(+), 1 deletion(-)
>  create mode 100644 tools/build/feature/test-libelf-zstd.c
> 
> -- 
> 2.34.1
> 

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

* Re: [PATCH v2 0/3] bpftool: Fix the static linkage failure
  2024-12-11 13:18 ` [PATCH v2 0/3] bpftool: Fix the static linkage failure Arnaldo Carvalho de Melo
@ 2024-12-11 20:26   ` Leo Yan
  2024-12-12 23:53     ` Andrii Nakryiko
  0 siblings, 1 reply; 11+ messages in thread
From: Leo Yan @ 2024-12-11 20:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Quentin Monnet, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Nick Terrell, Ian Rogers, Adrian Hunter,
	Liang, Kan, James Clark, Guilherme Amadio, linux-kernel, bpf,
	linux-perf-users

On Wed, Dec 11, 2024 at 10:18:10AM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Dec 11, 2024 at 09:31:11AM +0000, Leo Yan wrote:
> > This series follows up on the discussion in [1] for fixing the static
> > linkage issue in bpftool.
> >
> > Patch 01 introduces a new feature for libelf-zstd.  If this feature
> > is detected, it means the zstd lib is required by libelf.
> >
> > Patch 02 is a minor improvement for linking the zstd lib in the perf.
> >
> > Patch 03 fixes the static build failure by linking the zstd lib when
> > the feature-libelf-zstd is detected.
>
> So, this was originally reported as a perf build failure when trying a
> static build, so something not so common, no urgency, I guess, but it
> involves a tools/perf/bpftool/Makefile change, I think I can process
> this as I'll then test it in the many build containers for old distros I
> have, ok?

As Quentin said in another reply, there is a delta change between the
Linux perf tree and bpf-next tree.  So this series has a conflict on
bpf-next tree but it can be applied cleanly on perf tree.

Before I respin to update the commit logs based on comments, I need BPF
maintainers agreement with Arnaldo on proceeding on which source tree
to proceed with.

Thanks,
Leo

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

* Re: [PATCH v2 0/3] bpftool: Fix the static linkage failure
  2024-12-11 20:26   ` Leo Yan
@ 2024-12-12 23:53     ` Andrii Nakryiko
  0 siblings, 0 replies; 11+ messages in thread
From: Andrii Nakryiko @ 2024-12-12 23:53 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Quentin Monnet, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Nick Terrell, Ian Rogers, Adrian Hunter, Liang, Kan, James Clark,
	Guilherme Amadio, linux-kernel, bpf, linux-perf-users

On Wed, Dec 11, 2024 at 12:26 PM Leo Yan <leo.yan@arm.com> wrote:
>
> On Wed, Dec 11, 2024 at 10:18:10AM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Dec 11, 2024 at 09:31:11AM +0000, Leo Yan wrote:
> > > This series follows up on the discussion in [1] for fixing the static
> > > linkage issue in bpftool.
> > >
> > > Patch 01 introduces a new feature for libelf-zstd.  If this feature
> > > is detected, it means the zstd lib is required by libelf.
> > >
> > > Patch 02 is a minor improvement for linking the zstd lib in the perf.
> > >
> > > Patch 03 fixes the static build failure by linking the zstd lib when
> > > the feature-libelf-zstd is detected.
> >
> > So, this was originally reported as a perf build failure when trying a
> > static build, so something not so common, no urgency, I guess, but it
> > involves a tools/perf/bpftool/Makefile change, I think I can process
> > this as I'll then test it in the many build containers for old distros I
> > have, ok?
>
> As Quentin said in another reply, there is a delta change between the
> Linux perf tree and bpf-next tree.  So this series has a conflict on
> bpf-next tree but it can be applied cleanly on perf tree.
>
> Before I respin to update the commit logs based on comments, I need BPF
> maintainers agreement with Arnaldo on proceeding on which source tree
> to proceed with.
>

I think it's fine to route this through a perf tree.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

> Thanks,
> Leo

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

end of thread, other threads:[~2024-12-12 23:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11  9:31 [PATCH v2 0/3] bpftool: Fix the static linkage failure Leo Yan
2024-12-11  9:31 ` [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Leo Yan
2024-12-11 12:48   ` Quentin Monnet
2024-12-11 15:05   ` Jiri Olsa
2024-12-11  9:31 ` [PATCH v2 2/3] perf: build: Minor improvement for linking libzstd Leo Yan
2024-12-11  9:31 ` [PATCH v2 3/3] bpftool: Link zstd lib required by libelf Leo Yan
2024-12-11 12:48   ` Quentin Monnet
2024-12-11 13:18 ` [PATCH v2 0/3] bpftool: Fix the static linkage failure Arnaldo Carvalho de Melo
2024-12-11 20:26   ` Leo Yan
2024-12-12 23:53     ` Andrii Nakryiko
2024-12-11 19:44 ` Namhyung Kim

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