qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Bernhard Beschow <shentey@gmail.com>
Subject: [PULL 03/16] rust: use "objects" for Rust executables as well
Date: Tue,  3 Jun 2025 23:45:10 +0200	[thread overview]
Message-ID: <20250603214523.131185-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20250603214523.131185-1-pbonzini@redhat.com>

libqemuutil is not meant be linked as a whole; if modules are enabled, doing
so results in undefined symbols (corresponding to QMP commands) in
rust/qemu-api/rust-qemu-api-integration.

Support for "objects" in Rust executables is available in Meson 1.8.0; use it
to switching to the same dependencies that C targets use: link_with for
libqemuutil, and objects for everything else.

Reported-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/devel/rust.rst       |  2 --
 rust/meson.build          |  2 ++
 rust/qemu-api/meson.build | 27 +++++----------------------
 3 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 171d908e0b0..11328c05b45 100644
--- a/docs/devel/rust.rst
+++ b/docs/devel/rust.rst
@@ -66,8 +66,6 @@ be run via ``meson test`` or ``make``::
 
    make check-rust
 
-Building Rust code with ``--enable-modules`` is not supported yet.
-
 Supported tools
 '''''''''''''''
 
diff --git a/rust/meson.build b/rust/meson.build
index 1f0dcce7d04..801f4374dfa 100644
--- a/rust/meson.build
+++ b/rust/meson.build
@@ -14,6 +14,8 @@ quote_rs_native = dependency('quote-1-rs', native: true)
 syn_rs_native = dependency('syn-2-rs', native: true)
 proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true)
 
+qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true)
+
 subdir('qemu-api-macros')
 subdir('qemu-api')
 
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index 1ea86b8bbf1..62068352b0b 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -35,32 +35,15 @@ _qemu_api_rs = static_library(
   override_options: ['rust_std=2021', 'build.rust_std=2021'],
   rust_abi: 'rust',
   rust_args: _qemu_api_cfg,
-  dependencies: [libc_rs, qemu_api_macros],
+  dependencies: [libc_rs, qemu_api_macros, qemuutil_rs,
+                 qom, hwcore, chardev, migration],
 )
 
 rust.test('rust-qemu-api-tests', _qemu_api_rs,
           suite: ['unit', 'rust'])
 
-qemu_api = declare_dependency(link_with: _qemu_api_rs)
-
-# Rust executables do not support objects, so add an intermediate step.
-rust_qemu_api_objs = static_library(
-    'rust_qemu_api_objs',
-    objects: [libqom.extract_all_objects(recursive: false),
-              libhwcore.extract_all_objects(recursive: false),
-              libchardev.extract_all_objects(recursive: false),
-              libcrypto.extract_all_objects(recursive: false),
-              libauthz.extract_all_objects(recursive: false),
-              libio.extract_all_objects(recursive: false),
-              libmigration.extract_all_objects(recursive: false)])
-rust_qemu_api_deps = declare_dependency(
-    dependencies: [
-      qom_ss.dependencies(),
-      chardev_ss.dependencies(),
-      crypto_ss.dependencies(),
-      authz_ss.dependencies(),
-      io_ss.dependencies()],
-    link_whole: [rust_qemu_api_objs, libqemuutil])
+qemu_api = declare_dependency(link_with: [_qemu_api_rs],
+  dependencies: [qemu_api_macros, qom, hwcore, chardev, migration])
 
 test('rust-qemu-api-integration',
     executable(
@@ -69,7 +52,7 @@ test('rust-qemu-api-integration',
         override_options: ['rust_std=2021', 'build.rust_std=2021'],
         rust_args: ['--test'],
         install: false,
-        dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]),
+        dependencies: [qemu_api]),
     args: [
         '--test', '--test-threads', '1',
         '--format', 'pretty',
-- 
2.49.0



  parent reply	other threads:[~2025-06-03 21:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 21:45 [PULL 00/16] rust, i386 changes for 2025-06-03 Paolo Bonzini
2025-06-03 21:45 ` [PULL 01/16] rust: bindings: allow ptr_offset_with_cast Paolo Bonzini
2025-06-03 21:45 ` [PULL 02/16] meson: update to version 1.8.1 Paolo Bonzini
2025-06-03 21:45 ` Paolo Bonzini [this message]
2025-06-03 21:45 ` [PULL 04/16] build, dockerfiles: add support for detecting rustdoc Paolo Bonzini
2025-06-03 21:45 ` [PULL 05/16] rust: add qemu-api doctests to "meson test" Paolo Bonzini
2025-06-03 21:45 ` [PULL 06/16] rust: cell: remove support for running doctests with "cargo test --doc" Paolo Bonzini
2025-06-03 21:45 ` [PULL 07/16] rust: use native Meson support for clippy and rustdoc Paolo Bonzini
2025-06-03 21:45 ` [PULL 08/16] target/i386: Remove FRED dependency on WRMSRNS Paolo Bonzini
2025-06-03 21:45 ` [PULL 09/16] target/i386: Add a new CPU feature word for CPUID.7.1.ECX Paolo Bonzini
2025-06-03 21:45 ` [PULL 10/16] target/i386: Add the immediate form MSR access instruction support Paolo Bonzini
2025-06-03 21:45 ` [PULL 11/16] meson: use config_base_arch for target libraries Paolo Bonzini
2025-06-03 21:45 ` [PULL 12/16] i386/tdx: Fix build on 32-bit host Paolo Bonzini
2025-06-03 21:45 ` [PULL 13/16] i386/tdvf: " Paolo Bonzini
2025-06-03 21:45 ` [PULL 14/16] rust: add "bits", a custom bitflags implementation Paolo Bonzini
2025-06-03 21:45 ` [PULL 15/16] rust: pl011: use the bits macro Paolo Bonzini
2025-06-03 21:45 ` [PULL 16/16] rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)] Paolo Bonzini
2025-06-05 14:56 ` [PULL 00/16] rust, i386 changes for 2025-06-03 Stefan Hajnoczi

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=20250603214523.131185-4-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    /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).