Skip to content

Commit 76501d1

Browse files
committed
rust: enable bindgen's --enable-function-attribute-detection flag
`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. Thus enable it. Link: rust-lang/rust-bindgen#1465 [1] Link: https://lore.kernel.org/rust-for-linux/CANiq72=u5Nrz_NW3U3_VqywJkD8pECA07q2pFDd1wjtXOWdkAQ@mail.gmail.com/ Reviewed-by: Alice Ryhl <aliceryhl@google.com> Tested-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20240814163722.1550064-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 1d15880 commit 76501d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ quiet_cmd_bindgen = BINDGEN $@
270270
cmd_bindgen = \
271271
$(BINDGEN) $< $(bindgen_target_flags) \
272272
--use-core --with-derive-default --ctypes-prefix core::ffi --no-layout-tests \
273-
--no-debug '.*' \
273+
--no-debug '.*' --enable-function-attribute-detection \
274274
-o $@ -- $(bindgen_c_flags_final) -DMODULE \
275275
$(bindgen_target_cflags) $(bindgen_target_extra)
276276

0 commit comments

Comments
 (0)