Skip to content

Commit b32f192

Browse files
committed
mirror: Add probe for libelf-zstd feature
Add the probe to test whether we need to link against the zstd library to use libelf in bpftool. This should ideally have been merged before commit 67f1758 ("bpftool: Link zstd lib required by libelf"), where we have the Makefile use the actual feature, but I forgot to add the probe when synchronising the repository. Elfutils commit a5b07cdf9c49 adds support for ZSTD compression, first shipped with elfutils 0.189. Distros now have it; for example, Ubuntu 22.04 ships version 0.186 (or 0.188 in backports), but Ubuntu 24.04 has 0.189 or 0.190 depending on the arch. Link: https://sourceware.org/git/?p=elfutils.git;a=commit;h=a5b07cdf9c491fb7a4a16598c482c68b718f59b9 Signed-off-by: Quentin Monnet <qmo@kernel.org>
1 parent 4565cfe commit b32f192

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Makefile.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ feature-clang-bpf-co-re := \
3737
$(findstring 1,$(call detect,$(CLANG_BPF_CO_RE_PROBE_CMD)))
3838
endif # clang-bpf-co-re
3939

40+
### feature-libelf-zstd
41+
42+
# Define these unconditionally so we can also use the probe for feature-libbfd
43+
LIBELF_ZSTD_PROBE := '$(pound)include <libelf.h>\n'
44+
LIBELF_ZSTD_PROBE += 'int main(void) {'
45+
LIBELF_ZSTD_PROBE += ' elf_compress(0, ELFCOMPRESS_ZSTD, 0);'
46+
LIBELF_ZSTD_PROBE += ' return 0;'
47+
LIBELF_ZSTD_PROBE += '}'
48+
49+
LIBELF_ZSTD_PROBE_CMD = printf '%b\n' $(LIBELF_ZSTD_PROBE) | \
50+
$(CC) $(CFLAGS) -Wall -Werror -x c - $(LDFLAGS) -lelf -lz -lzstd -o - >/dev/null
51+
52+
define libelf_zstd_build
53+
$(call detect,$(LIBELF_ZSTD_PROBE_CMD))
54+
endef
55+
56+
ifneq ($(findstring libelf-zstd,$(FEATURE_TESTS)),)
57+
$(call LOG,Probing: feature-libelf-zstd)
58+
feature-libelf-zstd := $(findstring 1, $(call libelf_zstd_build))
59+
endif # libelf-zstd
60+
4061
### feature-libbfd
4162

4263
ifneq ($(findstring libbfd,$(FEATURE_TESTS)),)

0 commit comments

Comments
 (0)