[PATCH v2 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback
From: Ian Rogers
Date: Wed Sep 09 2026 - 16:42:53 EST
Distributions like Fedora currently ship a statically compiled binutils
libbfd that natively depends on zstd to decompress sections (e.g.
undefined reference to 'ZSTD_decompress').
Extend the testing cascade in tools/build/feature/Makefile to natively
probe for '-lz -lzstd' when the basic fallback variants fail. This adds
the generic framework for referencing static binutils across all tools.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/build/Makefile.feature | 3 ++-
tools/build/feature/Makefile | 12 +++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 99eb0ea09537..1268ac6f130e 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -121,6 +121,7 @@ FEATURE_TESTS_EXTRA := \
libcheck \
libbfd-liberty \
libbfd-liberty-z \
+ libbfd-liberty-z-zstd \
libopencsd \
libperl \
llvm \
@@ -161,7 +162,7 @@ FEATURE_DISPLAY ?= \
# Declare group members of a feature to display the logical OR of the detection
# result instead of each member result.
#
-FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z
+FEATURE_GROUP_MEMBERS-libbfd = libbfd-liberty libbfd-liberty-z libbfd-liberty-z-zstd
#
# Declare list of feature dependency packages that provide pkg-config files.
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 7d165018116a..410987df3a48 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -21,6 +21,7 @@ FILES= \
test-reallocarray.bin \
test-libbfd-liberty.bin \
test-libbfd-liberty-z.bin \
+ test-libbfd-liberty-z-zstd.bin \
test-cplus-demangle.bin \
test-cxa-demangle.bin \
test-libcap.bin \
@@ -272,15 +273,17 @@ $(OUTPUT)test-libbfd.bin:
$(BUILD_BFD)
$(OUTPUT)test-libbfd-threadsafe.bin:
- $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
+ $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz || $(BUILD_BFD) -liberty -lz -lzstd
$(OUTPUT)test-disassembler-four-args.bin:
$(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
- $(BUILD_BFD) -lopcodes -liberty -lz
+ $(BUILD_BFD) -lopcodes -liberty -lz || \
+ $(BUILD_BFD) -lopcodes -liberty -lz -lzstd
$(OUTPUT)test-disassembler-init-styled.bin:
$(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
- $(BUILD_BFD) -lopcodes -liberty -lz
+ $(BUILD_BFD) -lopcodes -liberty -lz || \
+ $(BUILD_BFD) -lopcodes -liberty -lz -lzstd
$(OUTPUT)test-reallocarray.bin:
$(BUILD)
@@ -291,6 +294,9 @@ $(OUTPUT)test-libbfd-liberty.bin:
$(OUTPUT)test-libbfd-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
+$(OUTPUT)test-libbfd-liberty-z-zstd.bin:
+ $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz -lzstd
+
$(OUTPUT)test-cplus-demangle.bin:
$(BUILD) -liberty
--
2.55.0.1003.g10538fe699-goog