aboutsummaryrefslogtreecommitdiff
path: root/gdbstub
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@daynix.com>2024-05-24 17:00:22 +0900
committerPaolo Bonzini <pbonzini@redhat.com>2024-07-03 18:41:25 +0200
commit414b180d42315dc77c02170f1eee8db58c9fe052 (patch)
tree20e57fbcc0b675d53878c37ac993f3779cc3d5b1 /gdbstub
parent0082475e26430297ef65e598db5b67c8ac182620 (diff)
meson: Pass objects and dependencies to declare_dependency()
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>
Diffstat (limited to 'gdbstub')
-rw-r--r--gdbstub/meson.build4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdbstub/meson.build b/gdbstub/meson.build
index da5721d845..c56b54eae7 100644
--- a/gdbstub/meson.build
+++ b/gdbstub/meson.build
@@ -28,9 +28,9 @@ libgdb_system = static_library('gdb_system',
name_suffix: 'fa',
build_by_default: false)
-gdb_user = declare_dependency(link_whole: libgdb_user)
+gdb_user = declare_dependency(objects: libgdb_user.extract_all_objects(recursive: false))
user_ss.add(gdb_user)
-gdb_system = declare_dependency(link_whole: libgdb_system)
+gdb_system = declare_dependency(objects: libgdb_system.extract_all_objects(recursive: false))
system_ss.add(gdb_system)
common_ss.add(files('syscalls.c'))