[RFC PATCH v2 2/5] meson: move block.syms dependency out of libblock

Paolo Bonzini posted 5 patches 6 months ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Laurent Vivier <lvivier@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
[RFC PATCH v2 2/5] meson: move block.syms dependency out of libblock
Posted by Paolo Bonzini 6 months ago
In order to define libqemuutil symbols that are requested by block modules,
QEMU currently uses a combination of the "link_depends" argument of
libraries (which is propagated into dependencies, but not available in
dependencies) and the "link_args" argument of declare_dependency()
(which _is_ available in static_library, but probably not used for
historical reasons only).

Unfortunately the link_depends will not be propagated into the
"block" dependency if it is defined using
declare_dependency(objects: ...); and it is not possible to
add it directly to the dependency because the keyword argument
simply is not available.

The only solution, in order to switch to defining the dependency
without using "link_whole" (which has problems of its own, see
https://github.com/mesonbuild/meson/pull/8151#issuecomment-754796420),
is unfortunately to add the link_args and link_depends to the
executables directly; fortunately there is just four of them.

It is possible (and I will look into it) to add "link_depends"
to declare_dependency(), but it probably will be a while before
QEMU can use it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build                | 5 +++--
 storage-daemon/meson.build | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 92ddbd17c32..edaef6bca11 100644
--- a/meson.build
+++ b/meson.build
@@ -3719,12 +3719,10 @@ system_ss.add(migration)
 block_ss = block_ss.apply({})
 libblock = static_library('block', block_ss.sources() + genh,
                           dependencies: block_ss.dependencies(),
-                          link_depends: block_syms,
                           name_suffix: 'fa',
                           build_by_default: false)
 
 block = declare_dependency(link_whole: [libblock],
-                           link_args: '@block.syms',
                            dependencies: [crypto, io])
 
 blockdev_ss = blockdev_ss.apply({})
@@ -3993,10 +3991,13 @@ endif
 
 if have_tools
   qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
+             link_args: '@block.syms', link_depends: block_syms,
              dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
   qemu_io = executable('qemu-io', files('qemu-io.c'),
+             link_args: '@block.syms', link_depends: block_syms,
              dependencies: [block, qemuutil], install: true)
   qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
+               link_args: '@block.syms', link_depends: block_syms,
                dependencies: [blockdev, qemuutil, gnutls, selinux],
                install: true)
 
diff --git a/storage-daemon/meson.build b/storage-daemon/meson.build
index 46267b63e72..fd5e32f4b28 100644
--- a/storage-daemon/meson.build
+++ b/storage-daemon/meson.build
@@ -8,6 +8,7 @@ if have_tools
   qsd_ss = qsd_ss.apply({})
   qsd = executable('qemu-storage-daemon',
                    qsd_ss.sources(),
+                   link_args: '@block.syms', link_depends: block_syms,
                    dependencies: qsd_ss.dependencies(),
                    install: true)
 endif
-- 
2.45.1
Re: [RFC PATCH v2 2/5] meson: move block.syms dependency out of libblock
Posted by Akihiko Odaki 5 months, 3 weeks ago
 >On 2024/05/27 19:49, Paolo Bonzini wrote:
> In order to define libqemuutil symbols that are requested by block modules,
> QEMU currently uses a combination of the "link_depends" argument of
> libraries (which is propagated into dependencies, but not available in
> dependencies) and the "link_args" argument of declare_dependency()
> (which _is_ available in static_library, but probably not used for
> historical reasons only).
> 
> Unfortunately the link_depends will not be propagated into the
> "block" dependency if it is defined using
> declare_dependency(objects: ...); and it is not possible to
> add it directly to the dependency because the keyword argument
> simply is not available.
> 
> The only solution, in order to switch to defining the dependency
> without using "link_whole" (which has problems of its own, see
> https://github.com/mesonbuild/meson/pull/8151#issuecomment-754796420),
> is unfortunately to add the link_args and link_depends to the
> executables directly; fortunately there is just four of them.
> 
> It is possible (and I will look into it) to add "link_depends"
> to declare_dependency(), but it probably will be a while before
> QEMU can use it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

This is not ideal but I think is good enough.

Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>