Re: [RFC PATCH v3 3/3] bpftool: Prefer zlib-rs over zlib when available

From: bot+bpf-ci

Date: Thu Nov 05 2026 - 13:56:59 EST


> bpftool: Prefer zlib-rs over zlib when available

TL;DR: Possible behaviour issue: bpftool ignores perf's NO_RUST/NO_ZLIB_RS, so
"make -C tools/perf NO_RUST=1" may still build and link the bootstrap bpftool
against zlib-rs via cargo.

> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile

[ ... ]

> @@ -115,8 +119,20 @@ ifneq ($(SKIP_CRYPTO),1)
> CRYPTO_LIBS := -lcrypto
> endif
>
> +ifneq ($(CROSS_COMPILE),)
> + ifneq ($(MAKECMDGOALS),bootstrap)
> + ifneq ($(RUST_TARGET_FLAGS_$(ARCH)),)
> + RUST_FLAGS += --target=$(RUST_TARGET_FLAGS_$(ARCH))
> + else
> + NO_ZLIB_RS := 1
> + endif
> + else
> + NO_ZLIB_RS := 1
> + endif
> +endif
> +
> ifeq ($(MAKECMDGOALS),bootstrap)
> -FEATURE_TESTS := libelf-zstd
> +FEATURE_TESTS := libelf-zstd $(if $(NO_ZLIB_RS),,zlib-rs) zlib
> FEATURE_DISPLAY :=
> else

The commit message says bpftool stays aligned with tools/perf, and that
zlib-rs is shared with the bootstrap bpftool built for perf BPF skeletons.
In perf, zlib-rs is turned off when NO_RUST is set or rustc is not found:

tools/perf/Makefile.config:
ifneq ($(NO_RUST), 0)
NO_ZLIB_RS := 1

That NO_ZLIB_RS is a plain makefile variable in perf, so it does not reach
the sub-make that tools/perf/bpf_skel.mak runs:

$(MAKE) -C ../bpf/bpftool OUTPUT=$(SKEL_TOOL_TMP_OUT)/ \
$(BPFTOOL_RUST_OUTPUT) bootstrap

bpftool only looks at NO_ZLIB_RS and CROSS_COMPILE and never at NO_RUST.

Can "make -C tools/perf NO_RUST=1" on a host that has cargo and the cargo
registry installed still list zlib-rs in the bootstrap FEATURE_TESTS here,
run cargo to build libz_rs.a, and link the bootstrap bpftool against it?

Would it make sense to pass NO_ZLIB_RS=1 from bpf_skel.mak when perf has
disabled zlib-rs, or to have bpftool honour NO_RUST=1?


---
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/42083491750