qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/16] rust: allow older versions of rustc and bindgen
@ 2024-10-15 13:17 Paolo Bonzini
  2024-10-15 13:17 ` [PATCH 01/16] meson: import rust module into a global variable Paolo Bonzini
                   ` (17 more replies)
  0 siblings, 18 replies; 51+ messages in thread
From: Paolo Bonzini @ 2024-10-15 13:17 UTC (permalink / raw)
  To: qemu-devel

This includes a few fixes to the Rust build system machinery, and
removes constructs that were added or stabilized after version 1.63.0:

- "let else" (by patching bilge-impl, patch 4; stable in 1.65.0)

- std::sync::OnceLock (patch 6; stable in 1.70.0)

- core::ffi (patch 7; stable in 1.64.0)

- c"" literals (patch 9; stable in 1.77.0)

- offset_of! (patch 10; stable in 1.77.0)

- MaybeUninit::zeroed() (patch 11; stable in 1.75.0 in const context)

It also replicates the configuration checks normally done by
proc-macro2's build.rs into our Meson-based build rules, so that
the crate can be made to work with an older version of rustc.

As a small bonus, patch 11 removes some uses of unsafe, so that patch
probably won't just be simply reverted even once we can assume version
1.75.0 of the language.  And as another small bonus this series introduces
the first use of Rust unit tests.

On top of this, the required version of bindgen is still too new
for Debian 12 and Ubuntu 22.04.  This is fixed by the last four patches.

This is an RFC for two reasons.  First, because it would be a valid
decision to delay enabling of Rust until at least some of these
features are available in all supported distros.  Another possibility
could be to accept Rust 1.64.0 but require installing a newer bindgen
(0.66.x for example) on those two distros with an older release.  Second,
because the series is missing the CI updates to actually ensure that
these minimum versions keep working.

The main purpose is to show the kind of hacks that would be needed
to support older toolchains.  The fixes (for example patches
1/2/3/6/8/11/13/14) can be easily extracted independent of the outcome
of the discussion, and/or while the CI updates are made.

Thanks,

Paolo

Paolo Bonzini (16):
  meson: import rust module into a global variable
  meson: remove repeated search for rust_root_crate.sh
  rust: pass rustc_args when building all crates
  rust: patch bilge-impl to allow compilation with 1.63.0
  rust: fix cfgs of proc-macro2 for 1.63.0
  rust: do not use OnceLock for properties
  rust: use std::os::raw instead of core::ffi
  rust: build tests for the qemu_api crate
  rust: introduce a c_str macro
  rust: introduce alternative implementation of offset_of!
  rust: do not use MaybeUninit::zeroed()
  rust: allow version 1.63.0 of rustc
  rust: do not use TYPE_CHARDEV unnecessarily
  rust: do not use --no-size_t-is-usize
  rust: do not use --generate-cstr
  rust: allow older version of bindgen

 meson.build                                   |  42 ++++---
 .gitattributes                                |   2 +
 rust/hw/char/pl011/src/device.rs              | 117 ++++++++++--------
 rust/hw/char/pl011/src/device_class.rs        |  13 +-
 rust/hw/char/pl011/src/lib.rs                 |   4 +-
 rust/hw/char/pl011/src/memory_ops.rs          |  21 ++--
 rust/qemu-api-macros/meson.build              |   2 +-
 rust/qemu-api/meson.build                     |  17 ++-
 rust/qemu-api/src/c_str.rs                    |  52 ++++++++
 rust/qemu-api/src/definitions.rs              |  10 +-
 rust/qemu-api/src/device_class.rs             |  49 +++++---
 rust/qemu-api/src/lib.rs                      |  14 ++-
 rust/qemu-api/src/offset_of.rs                | 106 ++++++++++++++++
 rust/qemu-api/src/tests.rs                    |  21 ++--
 rust/qemu-api/src/zeroable.rs                 |  75 +++++++++++
 subprojects/bilge-impl-0.2-rs.wrap            |   1 +
 .../packagefiles/bilge-impl-1.63.0.patch      |  45 +++++++
 .../packagefiles/proc-macro2-1-rs/meson.build |   4 +-
 18 files changed, 469 insertions(+), 126 deletions(-)
 create mode 100644 rust/qemu-api/src/c_str.rs
 create mode 100644 rust/qemu-api/src/offset_of.rs
 create mode 100644 rust/qemu-api/src/zeroable.rs
 create mode 100644 subprojects/packagefiles/bilge-impl-1.63.0.patch

-- 
2.46.2



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2024-10-22  4:00 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).