qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] meson: Propagate gnutls dependency


From: Roman Bolshakov
Subject: Re: [PATCH] meson: Propagate gnutls dependency
Date: Thu, 7 Jan 2021 18:56:27 +0300

On Thu, Jan 07, 2021 at 12:41:40PM +0100, Paolo Bonzini wrote:
> On 05/01/21 15:37, Roman Bolshakov wrote:
> > Does it work if you do:
> > 
> > crypto_ss.add(authz, qom)
> > libcrypto = static_library('crypto', crypto_ss.sources() + genh,
> >                             dependencies: crypto_ss.dependencies(),
> >                             ...)
> > crypto = declare_dependency(link_whole: libcrypto,
> >                              dependencies: crypto_ss.dependencies())
> 
> Ok, so the final attempt is a mix of the three :)  Keep the link_whole
> dependencies in the declare_dependency, and add the sourceset dependencies
> there too.

Hi Paolo,

Thanks for the patch but unfortunately it doesn't resolve the issue.
io and other libraries can't still find gnutls.

I've also tried your meson trans-deps branch and wonder if it's supposed
to fix the issue without any changes to qemu build files?
Do you need any help with meson changes?

IMO duplication of dependencies shouldn't be needed for a build system.
Meta build system should allow private and public dependencies. Different
rules are applied to them. Private dependency is not propagated beyond a
target that uses it, public dependency is propagated. There's also
declare_dependency that has to be always public because it serves no
purpose on it's own. declare_dependency is like INTERFACE library in
CMake.

If a project specifies a dependency that is public, it should be
transitively passed downstream. Build system shouldn't obscurely hide
flags a dependency provides on case-by-case basis.

Right now it seems that meson is missing the notion of public and
private dependencies and that's where the problem arises. The post [1] (and
the related issue) summarizes what I'm trying to say.

If we resolve the issue, then we just specify gnutls as a public
dependency of crypto and all users of crypto would get gnutls headers.

Here's an example how clearly CMake approaches the issue [2][3]:

add_library(crypto OBJECT crypto-file1.c ...)
target_link_libraries(crypto PRIVATE aninternaldep
                             PUBLIC  gnutls
                                     anotherpublicdep)

1. https://github.com/mesonbuild/meson/issues/495#issuecomment-206178570
2. 
https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries
3. 
https://cmake.org/cmake/help/latest/command/target_link_libraries.html#libraries-for-a-target-and-or-its-dependents

Regards,
Roman

> 
> diff --git a/meson.build b/meson.build
> index e9bf290966..774df4db8e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1904,7 +1904,8 @@ libqom = static_library('qom', qom_ss.sources() +
> genh,
>                          dependencies: [qom_ss.dependencies()],
>                          name_suffix: 'fa')
> 
> -qom = declare_dependency(link_whole: libqom)
> +qom = declare_dependency(link_whole: libqom,
> +                         dependencies: [qom_ss.dependencies()])
> 
>  authz_ss = authz_ss.apply(config_host, strict: false)
>  libauthz = static_library('authz', authz_ss.sources() + genh,
> @@ -1913,7 +1914,7 @@ libauthz = static_library('authz', authz_ss.sources()
> + genh,
>                            build_by_default: false)
> 
>  authz = declare_dependency(link_whole: libauthz,
> -                           dependencies: qom)
> +                          dependencies: [authz_ss.dependencies(), qom])
> 
>  crypto_ss = crypto_ss.apply(config_host, strict: false)
>  libcrypto = static_library('crypto', crypto_ss.sources() + genh,
> @@ -1922,7 +1923,7 @@ libcrypto = static_library('crypto',
> crypto_ss.sources() + genh,
>                             build_by_default: false)
> 
>  crypto = declare_dependency(link_whole: libcrypto,
> -                            dependencies: [authz, qom])
> +                            dependencies: [crypto_ss.dependencies(), authz,
> qom])
> 
>  io_ss = io_ss.apply(config_host, strict: false)
>  libio = static_library('io', io_ss.sources() + genh,
> @@ -1931,13 +1932,14 @@ libio = static_library('io', io_ss.sources() + genh,
>                         name_suffix: 'fa',
>                         build_by_default: false)
> 
> -io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
> +io = declare_dependency(link_whole: libio,
> +                        dependencies: [io_ss.dependencies(), crypto, qom])
> 
>  libmigration = static_library('migration', sources: migration_files + genh,
>                                name_suffix: 'fa',
>                                build_by_default: false)
>  migration = declare_dependency(link_with: libmigration,
> -                               dependencies: [zlib, qom, io])
> +                               dependencies: [qom, io])
>  softmmu_ss.add(migration)
> 
>  block_ss = block_ss.apply(config_host, strict: false)
> @@ -1949,7 +1951,7 @@ libblock = static_library('block', block_ss.sources()
> + genh,
> 
>  block = declare_dependency(link_whole: [libblock],
>                             link_args: '@block.syms',
> -                           dependencies: [crypto, io])
> +                           dependencies: [block_ss.dependencies(), crypto,
> io])
> 
>  blockdev_ss = blockdev_ss.apply(config_host, strict: false)
>  libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
> @@ -1958,7 +1960,7 @@ libblockdev = static_library('blockdev',
> blockdev_ss.sources() + genh,
>                               build_by_default: false)
> 
>  blockdev = declare_dependency(link_whole: [libblockdev],
> -                              dependencies: [block])
> +                              dependencies: [blockdev_ss.dependencies(),
> block])
> 
>  qmp_ss = qmp_ss.apply(config_host, strict: false)
>  libqmp = static_library('qmp', qmp_ss.sources() + genh,
> @@ -1966,7 +1968,8 @@ libqmp = static_library('qmp', qmp_ss.sources() +
> genh,
>                          name_suffix: 'fa',
>                          build_by_default: false)
> 
> -qmp = declare_dependency(link_whole: [libqmp])
> +qmp = declare_dependency(link_whole: [libqmp],
> +                         dependencies: qmp_ss.dependencies())
> 
>  libchardev = static_library('chardev', chardev_ss.sources() + genh,
>                              name_suffix: 'fa',
> diff --git a/migration/meson.build b/migration/meson.build
> index 9645f44005..e1f237b5db 100644
> --- a/migration/meson.build
> +++ b/migration/meson.build
> @@ -9,6 +9,7 @@ migration_files = files(
>  )
>  softmmu_ss.add(migration_files)
> 
> +softmmu_ss.add(zlib)
>  softmmu_ss.add(files(
>    'block-dirty-bitmap.c',
>    'channel.c',
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]