[PATCH v3 2/4] perf build: Add explicitly sequenced -lzstd to libbfd feature fallback

From: Ian Rogers

Date: Tue Nov 03 2026 - 23:31:52 EST


Distributions like Fedora ship a statically compiled binutils libbfd
that depends on zstd to decompress sections (e.g. undefined reference to
'ZSTD_decompress').

Since libbfd does not reliably distribute a .pc file for pkg-config,
perf probes manual linker flag combinations in fallback chains (-lbfd
-ldl -liberty -lz).

Extend the testing cascade in tools/perf/Makefile.config to check
libbfd-liberty-z-zstd and append '-lbfd -lopcodes -liberty -lz -lzstd'
when detected.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/Makefile.config | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index b4764f69f47f..78423b0dcc73 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -896,6 +896,7 @@ ifdef BUILD_NONDISTRO
$(call feature_check,libbfd-threadsafe)
$(call feature_check,libbfd-liberty)
$(call feature_check,libbfd-liberty-z)
+ $(call feature_check,libbfd-liberty-z-zstd)

ifneq ($(feature-libbfd-threadsafe), 1)
$(error binutils-dev(el) 2.42 or later is required for non-distro builds)
@@ -909,6 +910,8 @@ ifdef BUILD_NONDISTRO
EXTLIBS += -lbfd -lopcodes -liberty
else ifeq ($(feature-libbfd-liberty-z), 1)
EXTLIBS += -lbfd -lopcodes -liberty -lz
+ else ifeq ($(feature-libbfd-liberty-z-zstd), 1)
+ EXTLIBS += -lbfd -lopcodes -liberty -lz -lzstd
endif

CFLAGS += -DHAVE_LIBBFD_SUPPORT
--
2.56.0.385.gac671c819a-goog