lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240815192433.68d97420.gary@garyguo.net>
Date: Thu, 15 Aug 2024 19:24:33 +0100
From: Gary Guo <gary@...yguo.net>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho
 <wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin
 <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...sung.com>, Alice
 Ryhl <aliceryhl@...gle.com>, rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org, patches@...ts.linux.dev
Subject: Re: [PATCH] rust: enable bindgen's
 `--enable-function-attribute-detection` flag

On Wed, 14 Aug 2024 18:37:22 +0200
Miguel Ojeda <ojeda@...nel.org> wrote:

> `bindgen` is able to detect certain function attributes and annotate
> functions correspondingly in its output for the Rust side, when the
> `--enable-function-attribute-detection` is passed.
> 
> In particular, it is currently able to use `__must_check` in C
> (`#[must_use]` in Rust), which give us a bunch of annotations that are
> nice to have to prevent possible issues in Rust abstractions, e.g.:
> 
>      extern "C" {
>     +    #[must_use]
>          pub fn kobject_add(
>              kobj: *mut kobject,
>              parent: *mut kobject,
>              fmt: *const core::ffi::c_char,
>              ...
>          ) -> core::ffi::c_int;
>      }
> 
> Apparently, there are edge cases where this can make generation very slow,
> which is why it is behind a flag [1], but it does not seem to affect us
> in any major way at the moment.
> 
> Link: https://github.com/rust-lang/rust-bindgen/issues/1465 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72=u5Nrz_NW3U3_VqywJkD8pECA07q2pFDd1wjtXOWdkAQ@mail.gmail.com/
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Gary Guo <gary@...yguo.net>

> ---
> If someone notices a major performance difference, please let me know!
> 
>  rust/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rust/Makefile b/rust/Makefile
> index 1f10f92737f2..c28b81e2a5fa 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -270,7 +270,7 @@ quiet_cmd_bindgen = BINDGEN $@
>        cmd_bindgen = \
>  	$(BINDGEN) $< $(bindgen_target_flags) \
>  		--use-core --with-derive-default --ctypes-prefix core::ffi --no-layout-tests \
> -		--no-debug '.*' \
> +		--no-debug '.*' --enable-function-attribute-detection \
>  		-o $@ -- $(bindgen_c_flags_final) -DMODULE \
>  		$(bindgen_target_cflags) $(bindgen_target_extra)
> 
> 
> base-commit: de9c2c66ad8e787abec7c9d7eff4f8c3cdd28aed
> --
> 2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ