[Top][All Lists]

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

Re: [PATCH] meson: Propagate gnutls dependency

From: Paolo Bonzini
Subject: Re: [PATCH] meson: Propagate gnutls dependency
Date: Sat, 2 Jan 2021 20:43:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

On 02/01/21 14:25, Peter Maydell wrote:
Question to Paolo -- it seems pretty fragile to have to explicitly
list "these source files need these extra CFLAGS" in half a dozen
meson.build files, because it's pretty non-obvious that adding
eg '#include "block/nbd.h"' to a .c file means that you also
need to update the meson.build file to say "and now it needs these
extra CFLAGS". Isn't there some way we can just have the CFLAGS
added more globally so that if we use gnutls.h directly or
indirectly from more .c files in future it Just Works ?

If the build failed for the common Linux case then it would be
at least more obvious that you needed to update the meson.build
files. I think it's better to avoid "you need to do this special
thing that you'll only notice you're missing if you happen to test
on a somewhat obscure host configuration" where we can.

(We don't want to link helper binaries etc against gnutls if
they don't need it, but that's LDFLAGS, not CFLAGS.)

The gnutls dependency will already propagate from

if 'CONFIG_GNUTLS' in config_host


libcrypto = static_library('crypto', crypto_ss.sources() + genh,
                          dependencies: [crypto_ss.dependencies()], ...)
crypto = declare_dependency(link_whole: libcrypto,
                            dependencies: [authz, qom])

That is, Meson does know that everything that needs crypto needs gnutls (see get_dependencies in mesonbuild/build.py if you're curious).

I think the issue is that dependencies are listed too late---in the declare_dependency rather than the static_library. Take io/ for example:

libio = static_library('io', io_ss.sources() + genh,
                       dependencies: [io_ss.dependencies()],
                       link_with: libqemuutil,
                       name_suffix: 'fa',
                       build_by_default: false)
io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])

Listing "crypto" in io's declare_dependency is enough to propagate the gnutls LDFLAGS down to the executables, but it does not add the CFLAGS to io/ files itself. So for the io/ files we aren't telling meson that they need crypto (and thus in turn gnutls on the include path).

The fix should be pretty simple and localized to the "Library dependencies" section of meson.build. For the two libraries above, the fixed version would look like:

crypto_ss.add(authz, qom)
libcrypto = ... # same as above
crypto = declare_dependency(link_whole: libcrypto)

io_ss.add(crypto, qom)
libio = ... # same as above
io = declare_dependency(link_whole: libio)

(Roman, feel free to plunder the above if you want to turn it into a commit message, and if it's correct of course).



reply via email to

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