[PATCH] rust: bindgen: disable GCC latent entropy plugin

stijn@linux-ipv6.be posted 1 patch 1 month, 2 weeks ago
rust/Makefile | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] rust: bindgen: disable GCC latent entropy plugin
Posted by stijn@linux-ipv6.be 1 month, 2 weeks ago
When CONFIG_GCC_PLUGIN_LATENT_ENTROPY and CONFIG_RUST are enabled, rust
bindgen fails due to latent_entropy being undeclared:

  BINDGEN rust/bindings/bindings_generated.rs
./include/linux/random.h:24:39: error: use of undeclared identifier 'latent_entropy'
./include/linux/random.h:24:62: error: use of undeclared identifier 'latent_entropy'
Unable to generate bindings: clang diagnosed error: ./include/linux/random.h:24:39: error: use of undeclared identifier 'latent_entropy'
./include/linux/random.h:24:62: error: use of undeclared identifier 'latent_entropy'

Fix this by adding DISABLE_LATENT_ENTROPY_PLUGIN to
bindgen_extra_c_flags.

Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
---
 rust/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/rust/Makefile b/rust/Makefile
index 5d357dce1704d..633dec548f6e0 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -412,6 +412,10 @@ bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-r
 endif
 endif
 
+ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
+bindgen_extra_c_flags += $(DISABLE_LATENT_ENTROPY_PLUGIN)
+endif
+
 bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
 	$(bindgen_extra_c_flags)
 endif
-- 
2.51.2
Re: [PATCH] rust: bindgen: disable GCC latent entropy plugin
Posted by Miguel Ojeda 2 weeks, 5 days ago
On Sun, Dec 21, 2025 at 9:17 AM <stijn@linux-ipv6.be> wrote:
>
> When CONFIG_GCC_PLUGIN_LATENT_ENTROPY and CONFIG_RUST are enabled, rust
> bindgen fails due to latent_entropy being undeclared:
>
>   BINDGEN rust/bindings/bindings_generated.rs
> ./include/linux/random.h:24:39: error: use of undeclared identifier 'latent_entropy'
> ./include/linux/random.h:24:62: error: use of undeclared identifier 'latent_entropy'
> Unable to generate bindings: clang diagnosed error: ./include/linux/random.h:24:39: error: use of undeclared identifier 'latent_entropy'
> ./include/linux/random.h:24:62: error: use of undeclared identifier 'latent_entropy'
>
> Fix this by adding DISABLE_LATENT_ENTROPY_PLUGIN to
> bindgen_extra_c_flags.
>
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>

Cc'ing plugins and Kbuild.

Kees, Emese: from a quick look at the plugin, it doesn't seem to
change the signature of the functions (and even for variables it just
initializes), so it seems OK to ignore it for `bindgen` purposes, at
least naively. So I think this sounds fine.

Thanks!

Cheers,
Miguel
Re: [PATCH] rust: bindgen: disable GCC latent entropy plugin
Posted by Miguel Ojeda 2 weeks, 5 days ago
On Sun, Jan 18, 2026 at 11:46 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> change the signature of the functions (and even for variables it just

And by "signature", I should have written "ABI".

Cheers,
Miguel