From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 03/16] rust: pass rustc_args when building all crates
Date: Mon, 21 Oct 2024 14:32:45 +0800 [thread overview]
Message-ID: <ZxX1jSkJ3Muk11zC@intel.com> (raw)
In-Reply-To: <20241015131735.518771-4-pbonzini@redhat.com>
On Tue, Oct 15, 2024 at 03:17:21PM +0200, Paolo Bonzini wrote:
> Date: Tue, 15 Oct 2024 15:17:21 +0200
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 03/16] rust: pass rustc_args when building all crates
> X-Mailer: git-send-email 2.46.2
>
> rustc_args is needed to smooth the difference in warnings between the various
> versions of rustc. Always include those arguments.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> meson.build | 18 +++++++++++-------
> rust/qemu-api/meson.build | 2 +-
> rust/qemu-api/src/device_class.rs | 10 ++++++----
> 3 files changed, 18 insertions(+), 12 deletions(-)
LGTM (with one trivial comment inline)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_class.rs
> index 1ea95beb78d..b6b68cf9ce2 100644
> --- a/rust/qemu-api/src/device_class.rs
> +++ b/rust/qemu-api/src/device_class.rs
> @@ -16,10 +16,12 @@ macro_rules! device_class_init {
> ) {
> let mut dc =
> ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::DeviceClass>()).unwrap();
> - dc.as_mut().realize = $realize_fn;
> - dc.as_mut().vmsd = &$vmsd;
> - $crate::bindings::device_class_set_legacy_reset(dc.as_mut(), $legacy_reset_fn);
> - $crate::bindings::device_class_set_props(dc.as_mut(), $props.as_mut_ptr());
> + unsafe {
> + dc.as_mut().realize = $realize_fn;
> + dc.as_mut().vmsd = &$vmsd;
> + $crate::bindings::device_class_set_legacy_reset(dc.as_mut(), $legacy_reset_fn);
> + $crate::bindings::device_class_set_props(dc.as_mut(), $props.as_mut_ptr());
> + }
The issue exists because the unsafe_op_in_unsafe_fn is allowed in
rust/qemu-api/src/lib.rs. So should we wrap the bindings in a separate
lib (similar to the rust/bindings in the Linux kernel)?
This way, the special lint settings can be applied only to the binding
files, while the default lint checks can cover the other user
development code.
In addition, another thing that confuses me is why bindgen still
generates code that does not follow the unsafe_op_in_unsafe_fn
requirement. It seems that bindgen has supported unsafe_op_in_unsafe_fn
since v0.62 [1, 2], but binding code we generated still violates
unsafe_op_in_unsafe_fn. Is this a bug of bindgen?
[1]: https://github.com/rust-lang/rust-bindgen/pull/2266
[2]: https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md#changed-12
Regards,
Zhao
next prev parent reply other threads:[~2024-10-21 6:17 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 13:17 [RFC PATCH 00/16] rust: allow older versions of rustc and bindgen Paolo Bonzini
2024-10-15 13:17 ` [PATCH 01/16] meson: import rust module into a global variable Paolo Bonzini
2024-10-18 15:12 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 02/16] meson: remove repeated search for rust_root_crate.sh Paolo Bonzini
2024-10-16 6:50 ` Junjie Mao
2024-10-18 15:16 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 03/16] rust: pass rustc_args when building all crates Paolo Bonzini
2024-10-21 6:32 ` Zhao Liu [this message]
2024-10-21 13:38 ` Paolo Bonzini
2024-10-21 14:49 ` Zhao Liu
2024-10-22 2:22 ` Junjie Mao
2024-10-22 3:59 ` Paolo Bonzini
2024-10-15 13:17 ` [PATCH 04/16] rust: patch bilge-impl to allow compilation with 1.63.0 Paolo Bonzini
2024-10-18 15:55 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 05/16] rust: fix cfgs of proc-macro2 for 1.63.0 Paolo Bonzini
2024-10-21 7:40 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 06/16] rust: do not use OnceLock for properties Paolo Bonzini
2024-10-18 16:02 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 07/16] rust: use std::os::raw instead of core::ffi Paolo Bonzini
2024-10-18 16:07 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 08/16] rust: build tests for the qemu_api crate Paolo Bonzini
2024-10-21 9:07 ` Zhao Liu
2024-10-21 8:51 ` Paolo Bonzini
2024-10-21 14:51 ` Zhao Liu
2024-10-21 14:36 ` Paolo Bonzini
2024-10-21 16:04 ` Zhao Liu
2024-10-15 13:17 ` [PATCH 09/16] rust: introduce a c_str macro Paolo Bonzini
2024-10-15 13:17 ` [PATCH 10/16] rust: introduce alternative implementation of offset_of! Paolo Bonzini
2024-10-17 5:07 ` Junjie Mao
2024-10-17 8:44 ` Paolo Bonzini
2024-10-18 3:01 ` Junjie Mao
2024-10-18 6:51 ` Paolo Bonzini
2024-10-15 13:17 ` [PATCH 11/16] rust: do not use MaybeUninit::zeroed() Paolo Bonzini
2024-10-15 13:17 ` [PATCH 12/16] rust: allow version 1.63.0 of rustc Paolo Bonzini
2024-10-16 6:01 ` Junjie Mao
2024-10-16 7:51 ` Paolo Bonzini
2024-10-16 9:53 ` Junjie Mao
2024-10-18 2:44 ` Junjie Mao
2024-10-18 9:56 ` Paolo Bonzini
2024-10-15 13:17 ` [PATCH 13/16] rust: do not use TYPE_CHARDEV unnecessarily Paolo Bonzini
2024-10-15 13:17 ` [PATCH 14/16] rust: do not use --no-size_t-is-usize Paolo Bonzini
2024-10-15 13:17 ` [PATCH 15/16] rust: do not use --generate-cstr Paolo Bonzini
2024-10-15 13:17 ` [PATCH 16/16] rust: allow older version of bindgen Paolo Bonzini
2024-10-16 6:15 ` Junjie Mao
2024-10-16 7:50 ` Paolo Bonzini
2024-10-18 13:09 ` [RFC PATCH 00/16] rust: allow older versions of rustc and bindgen Kevin Wolf
2024-10-18 13:31 ` Daniel P. Berrangé
2024-10-18 15:43 ` Paolo Bonzini
2024-10-18 17:05 ` Kevin Wolf
2024-10-21 14:15 ` Peter Maydell
2024-10-21 14:48 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZxX1jSkJ3Muk11zC@intel.com \
--to=zhao1.liu@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).