From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org,
marcandre.lureau@redhat.com,
Martin Kletzander <mkletzan@redhat.com>
Subject: Re: [PATCH 04/11] rust: Do not link qemuutil into Rust rlibs
Date: Wed, 17 Dec 2025 11:37:47 +0800 [thread overview]
Message-ID: <aUIli8Do+HM89mu8@intel.com> (raw)
In-Reply-To: <20251215075000.335043-5-pbonzini@redhat.com>
On Mon, Dec 15, 2025 at 08:49:53AM +0100, Paolo Bonzini wrote:
> Date: Mon, 15 Dec 2025 08:49:53 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 04/11] rust: Do not link qemuutil into Rust rlibs
> X-Mailer: git-send-email 2.52.0
>
> From: Martin Kletzander <mkletzan@redhat.com>
>
> Commit de037ab8d83d removed qemuutil dependency from chardev and util
> rust crates. However it stayed in the _util_rs static library. The
> dependency is also defined as `link_with`, which is fine for C targets,
> where the resulting archive gets linked as another parameter on the
> command line when it is a static library.
>
> However, when a C library is linked into a Rust rlib, rustc remembers
> the dependency into the metadata and adds the library to the linker
> command line.
>
> Unfortunately, static libraries are sensitive to their
> position on the command line and rustc does not always get it right.
> Fortunately, simply removing it from dependencies of any rust libraries
> and instead adding them into the dependencies of executables and
> doctests fixes the behaviour.
>
> Without this patch the error I get is:
>
> FAILED: [code=1] rust/tests/rust-integration
> ...
> = note: rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> rust-lld: error: unable to find library -l:libqemuutil.a
> rust-lld: error: unable to find library -l:libvhost-user-glib.a
> rust-lld: error: unable to find library -l:libvhost-user.a
> collect2: error: ld returned 1 exit status
>
> Meson could work around it itself by never adding these static libraries
> to the rlibs (after all, Meson tracks the transitive dependencies already
> and knows how to add them to dependents of those rlibs); at least for now,
> do it in QEMU: never link C libraries into Rust rlibs, and add them to the
> final build products only.
>
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> rust/chardev/meson.build | 2 +-
> rust/qom/meson.build | 2 +-
> rust/util/meson.build | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
next prev parent reply other threads:[~2025-12-17 3:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 7:49 [PATCH for 11.0 00/11] First batch of Meson/Rust build system changes Paolo Bonzini
2025-12-15 7:49 ` [PATCH 01/11] build: do not include @block.syms/@qemu.sys with modules disabled Paolo Bonzini
2025-12-15 7:49 ` [PATCH 02/11] tests/meson: do not reuse migration_files variable Paolo Bonzini
2025-12-15 7:49 ` [PATCH 04/11] rust: Do not link qemuutil into Rust rlibs Paolo Bonzini
2025-12-17 3:37 ` Zhao Liu [this message]
2025-12-15 7:49 ` [PATCH 05/11] rust: only link the Rust part of the code into devices Paolo Bonzini
2025-12-17 3:42 ` Zhao Liu
2025-12-15 7:49 ` [PATCH 06/11] rust: Meson now adds -Cdefault-linker-libraries Paolo Bonzini
2025-12-17 3:43 ` Zhao Liu
2025-12-15 7:49 ` [PATCH 07/11] meson: let Meson handle mixed-language linking of Rust and C objects Paolo Bonzini
2025-12-15 7:49 ` [PATCH 08/11] rust: skip compilation if there are no system emulators Paolo Bonzini
2025-12-17 3:55 ` Zhao Liu
2025-12-15 7:49 ` [PATCH 09/11] lcitool: enable Rust for Windows cross targets Paolo Bonzini
2025-12-15 13:01 ` Alex Bennée
2025-12-15 7:49 ` [PATCH 10/11] cirrus/macos: enable Rust Paolo Bonzini
2025-12-15 7:50 ` [PATCH 11/11] gitlab-ci: enable rust for msys2-64bit 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=aUIli8Do+HM89mu8@intel.com \
--to=zhao1.liu@intel.com \
--cc=marcandre.lureau@redhat.com \
--cc=mkletzan@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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).