Re: [PATCH 9/9] rust: only link the Rust part of the code into devices

Paolo Bonzini <[email protected]>
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-devel
Message-ID <CABgObfaQouR4Jc20XM+LT0m0O7agBGtWU_WVuAcO-bQt-hpezA@mail.gmail.com>
Turns out these last two patches only work with unreleased Meson. I will
put everything into a testable series once 1.10 is out (should be soon,
it's already at rc2).

Paolo

Il gio 27 nov 2025, 14:20 Paolo Bonzini <[email protected]> ha scritto:

> Do not include libqemuutil in the device crates for the same
> reason as in the previous commit.  Static libraries like qemuutil
> are sensitive to their position on the command line and rustc does not
> always get it right.
>
> If rustc places the library too early on the command line, the stubs
> are included in the final link product, which results in duplicate
> symbols.
>
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
>  rust/hw/char/pl011/meson.build | 18 ++++++++++--------
>  rust/hw/timer/hpet/meson.build | 16 ++++++++--------
>  2 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/rust/hw/char/pl011/meson.build
> b/rust/hw/char/pl011/meson.build
> index 33b91f21911..9c0e8290e9a 100644
> --- a/rust/hw/char/pl011/meson.build
> +++ b/rust/hw/char/pl011/meson.build
> @@ -28,20 +28,22 @@ _libpl011_rs = static_library(
>    ),
>    override_options: ['rust_std=2021', 'build.rust_std=2021'],
>    rust_abi: 'rust',
> +  link_with: [
> +    _util_rs,
> +    _migration_rs,
> +    _bql_rs,
> +    _qom_rs,
> +    _chardev_rs,
> +    _system_rs,
> +    _hwcore_rs,
> +    _trace_rs
> +  ],
>    dependencies: [
>      bilge_rs,
>      bilge_impl_rs,
>      bits_rs,
>      common_rs,
>      glib_sys_rs,
> -    util_rs,
> -    migration_rs,
> -    bql_rs,
> -    qom_rs,
> -    chardev_rs,
> -    system_rs,
> -    hwcore_rs,
> -    trace_rs
>    ],
>  )
>
> diff --git a/rust/hw/timer/hpet/meson.build
> b/rust/hw/timer/hpet/meson.build
> index bb64b96672e..7eb758ae347 100644
> --- a/rust/hw/timer/hpet/meson.build
> +++ b/rust/hw/timer/hpet/meson.build
> @@ -3,15 +3,15 @@ _libhpet_rs = static_library(
>    files('src/lib.rs'),
>    override_options: ['rust_std=2021', 'build.rust_std=2021'],
>    rust_abi: 'rust',
> -  dependencies: [
> -    common_rs,
> -    util_rs,
> -    migration_rs,
> -    bql_rs,
> -    qom_rs,
> -    system_rs,
> -    hwcore_rs,
> +  link_with: [
> +    _util_rs,
> +    _migration_rs,
> +    _bql_rs,
> +    _qom_rs,
> +    _system_rs,
> +    _hwcore_rs,
>    ],
> +  dependencies: [common_rs],
>  )
>
>  rust_devices_ss.add(when: 'CONFIG_X_HPET_RUST', if_true:
> [declare_dependency(
> --
> 2.51.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.