* [PATCH] kbuild: rust: drop the obsolete libclang stack-init probe
@ 2026-11-25 10:32 Peder Bergan via B4 Relay
2026-11-25 15:39 ` Gary Guo
0 siblings, 1 reply; 2+ messages in thread
From: Peder Bergan via B4 Relay @ 2026-11-25 10:32 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Nathan Chancellor, Nicolas Schier, rust-for-linux, linux-kbuild,
llvm, linux-kernel
From: Peder Bergan <peder.bergan@gmail.com>
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@gmail.com>
---
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@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] kbuild: rust: drop the obsolete libclang stack-init probe
2026-11-25 10:32 [PATCH] kbuild: rust: drop the obsolete libclang stack-init probe Peder Bergan via B4 Relay
@ 2026-11-25 15:39 ` Gary Guo
0 siblings, 0 replies; 2+ messages in thread
From: Gary Guo @ 2026-11-25 15:39 UTC (permalink / raw)
To: peder.bergan, Miguel Ojeda
Cc: Nathan Chancellor, Nicolas Schier, rust-for-linux, linux-kbuild,
llvm, linux-kernel
On Wed Nov 25, 2026 at 10:32 AM GMT, Peder Bergan via B4 Relay wrote:
> From: Peder Bergan <peder.bergan@gmail.com>
>
> 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@gmail.com>
Link: https://github.com/llvm/llvm-project/issues/44842
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> 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@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 15:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 10:32 [PATCH] kbuild: rust: drop the obsolete libclang stack-init probe Peder Bergan via B4 Relay
2026-11-25 15:39 ` Gary Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®