aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-02-27 13:36:49 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-06-03 22:42:18 +0200
commit4f04a4eaf0576a5a5a1c347b63d17b4d5244c979 (patch)
tree39a171098636194749a776bf45a22ca413b7c771
parent0074a471477d56723bd6fd044b78c30ff5958f56 (diff)
downloadqemu-4f04a4eaf0576a5a5a1c347b63d17b4d5244c979.zip
qemu-4f04a4eaf0576a5a5a1c347b63d17b4d5244c979.tar.gz
qemu-4f04a4eaf0576a5a5a1c347b63d17b4d5244c979.tar.bz2
rust: use "objects" for Rust executables as well
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>
-rw-r--r--docs/devel/rust.rst2
-rw-r--r--rust/meson.build2
-rw-r--r--rust/qemu-api/meson.build27
3 files changed, 7 insertions, 24 deletions
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 171d908..11328c0 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 1f0dcce..801f437 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 1ea86b8..6206835 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',