Re: [RFC PATCH v3 1/3] tools build: Add Rust library build infrastructure and zlib-rs feature test
From: bot+bpf-ci
Date: Thu Nov 05 2026 - 13:57:21 EST
> tools build: Add Rust library build infrastructure and zlib-rs feature test
TL;DR: Prepending CLANG_CROSS_FLAGS to CXXFLAGS in the feature tests may break
C++ checks (cxa-demangle, llvm) when cross-building with CC=clang but a g++
CXX, silently dropping perf features.
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 4d37d11f674c..ecf27626d493 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -5,10 +5,11 @@ ifneq ($(OUTPUT),)
> OUTPUT_FEATURES = $(OUTPUT)feature/
> $(shell mkdir -p $(OUTPUT_FEATURES))
> endif
> +RUST_OUTPUT ?= $(abspath $(or $(OUTPUT),$(CURDIR)))/
>
> feature_check = $(eval $(feature_check_code))
> define feature_check_code
> - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
> + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) RUST_OUTPUT="$(RUST_OUTPUT)" CC="$(CC)" CXX="$(CXX)" CARGO="$(CARGO)" RUSTC="$(RUSTC)" $(if $(PKG_CONFIG),PKG_CONFIG="$(PKG_CONFIG)") CFLAGS="$(CLANG_CROSS_FLAGS) $(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(CLANG_CROSS_FLAGS) $(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" RUST_FLAGS="$(RUST_FLAGS)" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
> endef
Is it correct to prepend $(CLANG_CROSS_FLAGS) to CXXFLAGS here?
CLANG_CROSS_FLAGS is computed in tools/scripts/Makefile.include from a
probe of CC alone (CC_NO_CLANG == 0 && CROSS_COMPILE set), and holds
clang-only options such as --target=<triple>, --prefix=, --sysroot= and
--gcc-toolchain=. Nothing checks that CXX is clang.
With 'make CC=clang CROSS_COMPILE=aarch64-linux-gnu-' (no LLVM=1),
Makefile.include leaves CXX as $(CROSS_COMPILE)g++, so each C++ feature
test would run as something like:
aarch64-linux-gnu-g++ --target=aarch64-linux-gnu ... --gcc-toolchain=/usr
-MD -Wall -Werror -o test-cxa-demangle.bin test-cxa-demangle.cpp
and g++ rejects the unrecognized --target option. The probe is silent
(output goes to /dev/null), so feature_check for cxa-demangle, llvm and
llvm-perf would return 0 and perf would drop HAVE_CXA_DEMANGLE_SUPPORT
and libllvm support without any error.
Before this patch CXXFLAGS in the feature sub-make did not contain
CLANG_CROSS_FLAGS, and Makefile.include only appends it to CFLAGS and
AFLAGS, so those tests passed. The same kind of failure was already fixed
for native perf builds in c8592f8da838 ("perf build: Only pass clang flags
to CXX when CXX is clang"), where tools/perf/Makefile.config probes
CXX_NO_CLANG separately.
Could CLANG_CROSS_FLAGS be added to CXXFLAGS only when CXX is clang, or
left on CFLAGS only? The commit message also does not mention that
CLANG_CROSS_FLAGS is now passed to every tool's feature tests.
---
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