From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: akihiko.odaki@daynix.com
Subject: Re: [RFC PATCH v2 3/5] meson: Pass objects and dependencies to declare_dependency()
Date: Thu, 6 Jun 2024 14:53:11 +0200 [thread overview]
Message-ID: <f13e7f01-3058-463f-b74f-9f6369fa484c@linaro.org> (raw)
In-Reply-To: <20240527104937.30443-4-pbonzini@redhat.com>
On 27/5/24 12:49, Paolo Bonzini wrote:
> From: Akihiko Odaki <akihiko.odaki@daynix.com>
>
> We used to request declare_dependency() to link_whole static libraries.
> If a static library is a thin archive, GNU ld keeps all object files
> referenced by the archive open, and sometimes exceeds the open file limit.
>
> Another problem with link_whole is that suboptimal handling of nested
> dependencies.
>
> link_whole by itself does not propagate dependencies. In particular,
> gnutls, a dependency of crypto, is not propagated to its users, and we
> currently workaround the issue by declaring gnutls as a dependency for
> each crypto user. On the other hand, if you write something like
>
> libfoo = static_library('foo', 'foo.c', dependencies: gnutls)
> foo = declare_dependency(link_whole: libfoo)
>
> libbar = static_library('bar', 'bar.c', dependencies: foo)
> bar = declare_dependency(link_whole: libbar, dependencies: foo)
> executable('prog', sources: files('prog.c'), dependencies: [foo, bar])
>
> hoping to propagate the gnutls dependency into bar.c, you'll see a
> linking failure for "prog", because the foo.c.o object file is included in
> libbar.a and therefore it is linked twice into "prog": once from libfoo.a
> and once from libbar.a. Here Meson does not see the duplication, it
> just asks the linker to link all of libfoo.a and libbar.a into "prog".
>
> Instead of using link_whole, extract objects included in static libraries
> and pass them to declare_dependency(); and then the dependencies can be
> added as well so that they are propagated, because object files on the
> linker command line are always deduplicated.
>
> This requires Meson 1.1.0 or later.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Message-ID: <20240524-objects-v1-1-07cbbe96166b@daynix.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> docs/devel/build-system.rst | 3 ++-
> meson.build | 44 +++++++++++++++++++---------------
> gdbstub/meson.build | 4 ++--
> pythondeps.toml | 2 +-
> tcg/meson.build | 6 +++--
> tests/qtest/libqos/meson.build | 2 +-
> 6 files changed, 35 insertions(+), 26 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2024-06-06 12:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 10:49 [RFC PATCH v2 0/5] meson: Pass objects to declare_dependency() Paolo Bonzini
2024-05-27 10:49 ` [RFC PATCH v2 1/5] meson: move shared_module() calls where modules are already walked Paolo Bonzini
2024-06-02 6:06 ` Akihiko Odaki
2024-06-06 12:51 ` Philippe Mathieu-Daudé
2024-05-27 10:49 ` [RFC PATCH v2 2/5] meson: move block.syms dependency out of libblock Paolo Bonzini
2024-06-02 6:10 ` Akihiko Odaki
2024-05-27 10:49 ` [RFC PATCH v2 3/5] meson: Pass objects and dependencies to declare_dependency() Paolo Bonzini
2024-06-06 12:53 ` Philippe Mathieu-Daudé [this message]
2024-05-27 10:49 ` [RFC PATCH v2 4/5] Revert "meson: Propagate gnutls dependency" Paolo Bonzini
2024-06-06 12:54 ` Philippe Mathieu-Daudé
2024-05-27 10:49 ` [RFC PATCH v2 5/5] meson: Drop the .fa library suffix 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=f13e7f01-3058-463f-b74f-9f6369fa484c@linaro.org \
--to=philmd@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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).