Re: [PATCH] kbuild: rust: drop the obsolete libclang stack-init probe
From: Gary Guo
Date: Wed Nov 25 2026 - 10:41:57 EST
On Wed Nov 25, 2026 at 10:32 AM GMT, Peder Bergan via B4 Relay wrote:
> From: Peder Bergan <peder.bergan@xxxxxxxxx>
>
> For Rust-enabled GCC builds with CONFIG_INIT_STACK_ALL_ZERO, the Rust
> Makefile runs bindgen to check whether libclang needs the old enabler
> for -ftrivial-auto-var-init=zero. LLVM 16 made the flag usable on its own,
> and the Rust toolchain check already requires libclang 17.0.1 or newer
> (18.0.0 on LoongArch).
>
> Drop the obsolete enabler and the bindgen invocation that selects it.
> On this rust-next base, median warm make prepare time fell from 0.72 s
> to 0.49 s over ten runs per version on x86-64 with GCC 16.2.1, libclang
> 23.1.5 and bindgen 0.73.2. For both GCC and Clang, the generated kernel,
> helper and UAPI bindings matched byte for byte before and after the
> change.
>
> Signed-off-by: Peder Bergan <peder.bergan@xxxxxxxxx>
Link: https://github.com/llvm/llvm-project/issues/44842
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> OpenAI Codex assisted with coding and testing.
> ---
> rust/Makefile | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 6dceabbf02c87..66b06ad6f11df 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -483,20 +483,6 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
> # some configurations, with new GCC versions, etc.
> bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
>
> -# Auto variable zero-initialization requires an additional special option with
> -# clang that is going to be removed sometime in the future (likely in
> -# clang-18), so make sure to pass this option only if clang supports it
> -# (libclang major version < 16).
> -#
> -# https://github.com/llvm/llvm-project/issues/44842
> -# https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags
> -ifdef CONFIG_INIT_STACK_ALL_ZERO
> -libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
> -ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
> -bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
> -endif
> -endif
> -
> bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
> $(bindgen_extra_c_flags)
> endif
>
> ---
> base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
> change-id: 20261125-perf-rust-bindgen-drop-legacy-clang-149a05cc71a9
>
> Best regards,
> --
> Peder Bergan <peder.bergan@xxxxxxxxx>