From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org, Bernhard Beschow <shentey@gmail.com>
Subject: [PATCH 1/3] rust: use "objects" for Rust executables as well
Date: Sat, 5 Apr 2025 12:06:01 +0200 [thread overview]
Message-ID: <20250405100603.253421-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20250405100603.253421-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/qemu-api/meson.build | 26 +++++---------------------
2 files changed, 5 insertions(+), 23 deletions(-)
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 88bdec1eb28..8030aa42d0c 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/qemu-api/meson.build b/rust/qemu-api/meson.build
index 858685ddd4a..8fa41c0a95e 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -45,29 +45,13 @@ _qemu_api_rs = static_library(
dependencies: [libc_dep, qemu_api_macros],
)
+qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true)
+
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: [qemuutil_rs, qemu_api_macros, qom, hwcore, chardev, migration])
test('rust-qemu-api-integration',
executable(
@@ -76,7 +60,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
next prev parent reply other threads:[~2025-04-05 10:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 10:06 [PATCH preview 0/3] rust: update build system for Meson 1.8.0 Paolo Bonzini
2025-04-05 10:06 ` Paolo Bonzini [this message]
2025-04-05 10:06 ` [PATCH 2/3] rust: add qemu-api doctests to "meson test" Paolo Bonzini
2025-04-05 10:06 ` [PATCH 3/3] rust: cell: remove support for running doctests with "cargo test --doc" Paolo Bonzini
2025-04-05 12:23 ` [PATCH 4/3] rust: use native Meson support for clippy and rustdoc Paolo Bonzini
2025-04-07 7:37 ` [PATCH preview 0/3] rust: update build system for Meson 1.8.0 Zhao Liu
2025-04-07 7:51 ` Paolo Bonzini
2025-04-08 20:34 ` Bernhard Beschow
2025-04-08 21:08 ` 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=20250405100603.253421-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@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).