Skip to content

Commit cf462c6

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 <[email protected]>
1 parent 368a1a5 commit cf462c6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Makefile.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ $(call LOG,Probing: feature-llvm)
157157
feature-llvm := $(findstring 1, $(call llvm_build))
158158
endif # llvm
159159

160+
### feature-libelf-zstd
161+
162+
ifneq ($(findstring libelf-zstd,$(FEATURE_TESTS)),)
163+
LIBELF_ZSTD_PROBE := '$(pound)include <libelf.h>\n'
164+
LIBELF_ZSTD_PROBE += 'int main(void) {'
165+
LIBELF_ZSTD_PROBE += ' elf_compress(0, ELFCOMPRESS_ZSTD, 0);'
166+
LIBELF_ZSTD_PROBE += ' return 0;'
167+
LIBELF_ZSTD_PROBE += '}'
168+
169+
LIBELF_ZSTD_PROBE_CMD = printf '%b\n' $(LIBELF_ZSTD_PROBE) | \
170+
$(CC) $(CFLAGS) -Wall -Werror -x c - -lelf -lz -lzstd -o - >/dev/null
171+
172+
define libelf_zstd_build
173+
$(call detect,$(LIBELF_ZSTD_PROBE_CMD))
174+
endef
175+
176+
$(call LOG,Probing: feature-libelf-zstd)
177+
feature-libelf-zstd := $(findstring 1, $(call libelf_zstd_build))
178+
endif # libelf-zstd
179+
160180
### Print detection results
161181

162182
define print_status

0 commit comments

Comments
 (0)