* [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback
2026-11-04 4:30 [PATCH v3 0/4] tools build: Fixes for libbfd -lzstd dependency Ian Rogers
@ 2026-11-04 4:30 ` Ian Rogers
2026-11-04 4:37 ` sashiko-bot
2026-11-04 5:03 ` bot+bpf-ci
2026-11-04 4:30 ` [PATCH v3 2/4] perf " Ian Rogers
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Ian Rogers @ 2026-11-04 4:30 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Quentin Monnet, Josh Poimboeuf
Cc: Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
Kumar Kartikeya Dwivedi, Martin KaFai Lau, Song Liu,
Yonghong Song, James Clark, Leo Yan, linux-perf-users, bpf,
linux-kernel
Distributions like Fedora ship a statically compiled binutils libbfd
that depends on zstd (along with libiberty and zlib) to decompress
sections (e.g. undefined reference to 'ZSTD_decompress').
Commit 89d001d48ec7 ("tools build: Add zstd to the binutils library
feature tests") added '|| $(BUILD_BFD) -lzstd' directly to
test-libbfd.bin, test-libbfd-threadsafe.bin, and
test-disassembler-four-args.bin. However, static libbfd requires
'-liberty -lz -lzstd' together, and setting feature-libbfd=1 when extra
libraries are needed causes callers (perf, bpftool) to link only '-lbfd
-lopcodes' without '-lzstd'.
Restore test-libbfd.bin to test only $(BUILD_BFD), add the
test-libbfd-liberty-z-zstd.bin feature test and
FEATURE_GROUP_MEMBERS-libbfd entry, and append the '-liberty -lz -lzstd'
fallback to test-libbfd-threadsafe.bin, test-disassembler-four-args.bin,
and test-disassembler-init-styled.bin.
Fixes: 89d001d48ec7 ("tools build: Add zstd to the binutils library feature tests")
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/build/Makefile.feature | 3 ++-
tools/build/feature/Makefile | 19 +++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 4d37d11f674c..c010049d9720 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 \
llvm \
libbpf \
@@ -160,7 +161,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 10340a537224..359da8b98bc5 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -20,6 +20,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 \
@@ -249,18 +250,21 @@ $(OUTPUT)test-python-module.bin:
$(BUILD) $(FLAGS_PYTHON_EMBED)
$(OUTPUT)test-libbfd.bin:
- $(BUILD_BFD) || $(BUILD_BFD) -lzstd
+ $(BUILD_BFD)
$(OUTPUT)test-libbfd-threadsafe.bin:
- $(BUILD_BFD) || $(BUILD_BFD) -lzstd || $(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 -lzstd || $(BUILD_BFD) -lopcodes -liberty || \
- $(BUILD_BFD) -lopcodes -liberty -lz
+ $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
+ $(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 || $(BUILD_BFD) -lopcodes -liberty || \
+ $(BUILD_BFD) -lopcodes -liberty -lz || \
+ $(BUILD_BFD) -lopcodes -liberty -lz -lzstd
$(OUTPUT)test-reallocarray.bin:
$(BUILD)
@@ -271,6 +275,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.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback
2026-11-04 4:30 ` [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback Ian Rogers
@ 2026-11-04 4:37 ` sashiko-bot
2026-11-04 5:03 ` bot+bpf-ci
1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-04 4:37 UTC (permalink / raw)
To: Ian Rogers; +Cc: linux-perf-users
> Distributions like Fedora ship a statically compiled binutils libbfd
> that depends on zstd (along with libiberty and zlib) to decompress
> sections (e.g. undefined reference to 'ZSTD_decompress').
>
> Commit 89d001d48ec7 ("tools build: Add zstd to the binutils library
> feature tests") added '|| $(BUILD_BFD) -lzstd' directly to
> test-libbfd.bin, test-libbfd-threadsafe.bin, and
> test-disassembler-four-args.bin. However, static libbfd requires
> '-liberty -lz -lzstd' together, and setting feature-libbfd=1 when extra
> libraries are needed causes callers (perf, bpftool) to link only '-lbfd
> -lopcodes' without '-lzstd'.
>
> Restore test-libbfd.bin to test only $(BUILD_BFD), add the
> test-libbfd-liberty-z-zstd.bin feature test and
> FEATURE_GROUP_MEMBERS-libbfd entry, and append the '-liberty -lz -lzstd'
> fallback to test-libbfd-threadsafe.bin, test-disassembler-four-args.bin,
> and test-disassembler-init-styled.bin.
>
> Fixes: 89d001d48ec7 ("tools build: Add zstd to the binutils library feature tests")
> Signed-off-by: Ian Rogers <irogers@google.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104043006.1199857-1-irogers@google.com?part=1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback
2026-11-04 4:30 ` [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback Ian Rogers
2026-11-04 4:37 ` sashiko-bot
@ 2026-11-04 5:03 ` bot+bpf-ci
1 sibling, 0 replies; 10+ messages in thread
From: bot+bpf-ci @ 2026-11-04 5:03 UTC (permalink / raw)
To: irogers, peterz, mingo, acme, namhyung, jolsa, irogers,
adrian.hunter, qmo, jpoimboe
Cc: daniel, andrii, eddyz87, memxor, martin.lau, song, yonghong.song,
james.clark, leo.yan, linux-perf-users, bpf, linux-kernel, ast,
andrii, daniel, martin.lau, eddyz87, yonghong.song, mason,
ihor.solodrai
[-- Attachment #1: Type: text/plain, Size: 2680 bytes --]
> tools build: Add explicitly sequenced -lzstd to libbfd feature fallback
TL;DR: Possible build break at this commit: the libbfd -lzstd fallback is
removed but no consumer uses the new feature test yet, so perf may fail to
link and bpftool may lose JIT disassembly.
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
[ ... ]
> @@ -249,18 +250,21 @@ $(OUTPUT)test-python-module.bin:
> $(BUILD) $(FLAGS_PYTHON_EMBED)
>
> $(OUTPUT)test-libbfd.bin:
> - $(BUILD_BFD) || $(BUILD_BFD) -lzstd
> + $(BUILD_BFD)
>
> $(OUTPUT)test-libbfd-threadsafe.bin:
> - $(BUILD_BFD) || $(BUILD_BFD) -lzstd || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
> + $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz || \
> + $(BUILD_BFD) -liberty -lz -lzstd
Can this leave perf and bpftool unable to link libbfd at this commit?
Nothing here reads the new libbfd-liberty-z-zstd result. Neither
tools/perf/Makefile.config nor tools/bpf/bpftool/Makefile calls
feature_check for it or has a branch that uses it.
On a system where "-lbfd -ldl" fails but "-lbfd -ldl -lzstd" links, the
parent commit gave feature-libbfd=1 through the removed fallback. Here
feature-libbfd, feature-libbfd-liberty and feature-libbfd-liberty-z are
all 0, while feature-libbfd-threadsafe is 1 through the new
"-liberty -lz -lzstd" fallback.
With BUILD_NONDISTRO=1, perf's Makefile.config then passes the threadsafe
check but takes none of the EXTLIBS branches:
ifeq ($(feature-libbfd), 1)
EXTLIBS += -lbfd -lopcodes
else ifeq ($(feature-libbfd-liberty), 1)
EXTLIBS += -lbfd -lopcodes -liberty
else ifeq ($(feature-libbfd-liberty-z), 1)
EXTLIBS += -lbfd -lopcodes -liberty -lz
endif
CFLAGS += -DHAVE_LIBBFD_SUPPORT
util/libbfd.o is still built, so the perf link can fail with undefined
references to bfd_openr(), bfd_check_format() and disassembler(). bpftool
goes down the same chain, silently drops -lbfd and -DHAVE_LIBBFD_SUPPORT,
and loses JIT disassembly.
The consumers are added later in the series:
6eb66acc776f ("perf build: Add explicitly sequenced -lzstd to libbfd
feature fallback")
155513d3a59d ("bpftool: Add explicitly sequenced -lzstd to libbfd
feature fallback")
Would it be better to keep the old -lzstd fallback until those consumers
land, or to reorder or squash so that each commit remains buildable?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/41774922004
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/4] perf build: Add explicitly sequenced -lzstd to libbfd feature fallback
2026-11-04 4:30 [PATCH v3 0/4] tools build: Fixes for libbfd -lzstd dependency Ian Rogers
2026-11-04 4:30 ` [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback Ian Rogers
@ 2026-11-04 4:30 ` Ian Rogers
2026-11-04 4:37 ` sashiko-bot
2026-11-04 4:30 ` [PATCH v3 3/4] bpftool: " Ian Rogers
2026-11-04 4:30 ` [PATCH v3 4/4] objtool: Add explicitly sequenced -lzstd to libopcodes fallback Ian Rogers
3 siblings, 1 reply; 10+ messages in thread
From: Ian Rogers @ 2026-11-04 4:30 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Quentin Monnet, Josh Poimboeuf
Cc: Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
Kumar Kartikeya Dwivedi, Martin KaFai Lau, Song Liu,
Yonghong Song, James Clark, Leo Yan, linux-perf-users, bpf,
linux-kernel
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@google.com>
---
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
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 3/4] bpftool: Add explicitly sequenced -lzstd to libbfd feature fallback
2026-11-04 4:30 [PATCH v3 0/4] tools build: Fixes for libbfd -lzstd dependency Ian Rogers
2026-11-04 4:30 ` [PATCH v3 1/4] tools build: Add explicitly sequenced -lzstd to libbfd feature fallback Ian Rogers
2026-11-04 4:30 ` [PATCH v3 2/4] perf " Ian Rogers
@ 2026-11-04 4:30 ` Ian Rogers
2026-11-04 4:34 ` sashiko-bot
2026-11-04 4:30 ` [PATCH v3 4/4] objtool: Add explicitly sequenced -lzstd to libopcodes fallback Ian Rogers
3 siblings, 1 reply; 10+ messages in thread
From: Ian Rogers @ 2026-11-04 4:30 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Quentin Monnet, Josh Poimboeuf
Cc: Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
Kumar Kartikeya Dwivedi, Martin KaFai Lau, Song Liu,
Yonghong Song, James Clark, Leo Yan, linux-perf-users, bpf,
linux-kernel
Distributions like Fedora ship a statically compiled binutils libbfd
that depends on zstd to decompress sections (e.g. undefined reference to
'ZSTD_decompress').
Add libbfd-liberty-z-zstd to FEATURE_TESTS and FEATURE_DISPLAY in
tools/bpf/bpftool/Makefile and append the '-lbfd -ldl -lopcodes -liberty
-lz -lzstd' branch to the libbfd fallback chain.
Acked-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/bpf/bpftool/Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index b0f7168e7943..1cac4508eb0c 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -125,6 +125,7 @@ FEATURE_TESTS += libcap
FEATURE_TESTS += libbfd
FEATURE_TESTS += libbfd-liberty
FEATURE_TESTS += libbfd-liberty-z
+FEATURE_TESTS += libbfd-liberty-z-zstd
FEATURE_TESTS += disassembler-four-args
FEATURE_TESTS += disassembler-init-styled
FEATURE_TESTS += libelf-zstd
@@ -135,6 +136,7 @@ FEATURE_DISPLAY += libcap
FEATURE_DISPLAY += libbfd
FEATURE_DISPLAY += libbfd-liberty
FEATURE_DISPLAY += libbfd-liberty-z
+FEATURE_DISPLAY += libbfd-liberty-z-zstd
endif
check_feat := 1
@@ -201,6 +203,8 @@ else
LIBS += -lbfd -ldl -lopcodes -liberty
else ifeq ($(feature-libbfd-liberty-z),1)
LIBS += -lbfd -ldl -lopcodes -liberty -lz
+ else ifeq ($(feature-libbfd-liberty-z-zstd),1)
+ LIBS += -lbfd -ldl -lopcodes -liberty -lz -lzstd
endif
# If one of the above feature combinations is set, we support libbfd
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 4/4] objtool: Add explicitly sequenced -lzstd to libopcodes fallback
2026-11-04 4:30 [PATCH v3 0/4] tools build: Fixes for libbfd -lzstd dependency Ian Rogers
` (2 preceding siblings ...)
2026-11-04 4:30 ` [PATCH v3 3/4] bpftool: " Ian Rogers
@ 2026-11-04 4:30 ` Ian Rogers
2026-11-04 4:32 ` sashiko-bot
3 siblings, 1 reply; 10+ messages in thread
From: Ian Rogers @ 2026-11-04 4:30 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Quentin Monnet, Josh Poimboeuf
Cc: Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
Kumar Kartikeya Dwivedi, Martin KaFai Lau, Song Liu,
Yonghong Song, James Clark, Leo Yan, linux-perf-users, bpf,
linux-kernel
Distributions like Fedora ship a statically compiled binutils libbfd (an
intrinsic dependency of libopcodes) that uses zstd to decompress
sections.
Because objtool resolves host dependencies sequentially via a manual
HOSTCC shell loop, linking against static binutils fails with undefined
references to 'ZSTD_decompress' unless the loop probes for -lzstd.
Add the '-lopcodes -lbfd -liberty -lz -lzstd' combination to the
LIBOPCODES_LIBS fallback chain.
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/objtool/Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index db99c4759b2c..238da6fd277f 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -81,14 +81,15 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)"
#
# When using shared libraries, -lopcodes is sufficient as dependencies are
# resolved automatically. With static libraries, we must explicitly link
-# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz.
-# Try each combination and use the first one that succeeds.
+# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz
+# and libzstd. Try each combination and use the first one that succeeds.
#
LIBOPCODES_LIBS := $(shell \
for libs in "-lopcodes" \
"-lopcodes -lbfd" \
"-lopcodes -lbfd -liberty" \
- "-lopcodes -lbfd -liberty -lz"; do \
+ "-lopcodes -lbfd -liberty -lz" \
+ "-lopcodes -lbfd -liberty -lz -lzstd"; do \
printf '%s\n' \
'$(pound)include <bfd.h>' \
'$(pound)include <dis-asm.h>' \
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread