2023-05-23 09:22:36 +03:00
|
|
|
if not get_option('tcg').allowed()
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
2021-03-08 23:04:33 +03:00
|
|
|
tcg_ss = ss.source_set()
|
|
|
|
|
|
|
|
tcg_ss.add(files(
|
|
|
|
'optimize.c',
|
2021-03-10 01:24:14 +03:00
|
|
|
'region.c',
|
2021-03-08 23:04:33 +03:00
|
|
|
'tcg.c',
|
|
|
|
'tcg-common.c',
|
|
|
|
'tcg-op.c',
|
2023-05-15 09:13:46 +03:00
|
|
|
'tcg-op-ldst.c',
|
2021-03-08 23:04:33 +03:00
|
|
|
'tcg-op-gvec.c',
|
|
|
|
'tcg-op-vec.c',
|
|
|
|
))
|
2021-03-18 21:46:44 +03:00
|
|
|
|
|
|
|
if get_option('tcg_interpreter')
|
|
|
|
libffi = dependency('libffi', version: '>=3.0', required: true,
|
2022-07-14 15:56:58 +03:00
|
|
|
method: 'pkg-config')
|
2023-05-23 09:22:36 +03:00
|
|
|
tcg_ss.add(libffi)
|
|
|
|
tcg_ss.add(files('tci.c'))
|
2021-03-18 21:46:44 +03:00
|
|
|
endif
|
2021-03-08 23:04:33 +03:00
|
|
|
|
2024-01-25 08:46:30 +03:00
|
|
|
tcg_ss.add(when: libdw, if_true: files('debuginfo.c'))
|
|
|
|
if host_os == 'linux'
|
|
|
|
tcg_ss.add(files('perf.c'))
|
|
|
|
endif
|
|
|
|
|
2023-08-30 12:52:43 +03:00
|
|
|
tcg_ss = tcg_ss.apply({})
|
2023-05-23 09:22:36 +03:00
|
|
|
|
|
|
|
libtcg_user = static_library('tcg_user',
|
|
|
|
tcg_ss.sources() + genh,
|
2024-05-24 11:54:50 +03:00
|
|
|
dependencies: tcg_ss.dependencies(),
|
2023-05-23 09:22:36 +03:00
|
|
|
c_args: '-DCONFIG_USER_ONLY',
|
2023-09-27 16:48:31 +03:00
|
|
|
build_by_default: false)
|
2023-05-23 09:22:36 +03:00
|
|
|
|
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>
2024-05-24 11:00:22 +03:00
|
|
|
tcg_user = declare_dependency(objects: libtcg_user.extract_all_objects(recursive: false),
|
|
|
|
dependencies: tcg_ss.dependencies())
|
2023-05-23 09:22:36 +03:00
|
|
|
user_ss.add(tcg_user)
|
|
|
|
|
2023-10-04 12:06:20 +03:00
|
|
|
libtcg_system = static_library('tcg_system',
|
2023-05-23 09:22:36 +03:00
|
|
|
tcg_ss.sources() + genh,
|
2024-05-24 11:54:50 +03:00
|
|
|
dependencies: tcg_ss.dependencies(),
|
2023-05-23 09:22:36 +03:00
|
|
|
c_args: '-DCONFIG_SOFTMMU',
|
2023-09-27 16:48:31 +03:00
|
|
|
build_by_default: false)
|
2023-05-23 09:22:36 +03:00
|
|
|
|
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>
2024-05-24 11:00:22 +03:00
|
|
|
tcg_system = declare_dependency(objects: libtcg_system.extract_all_objects(recursive: false),
|
|
|
|
dependencies: tcg_ss.dependencies())
|
2023-10-04 12:06:20 +03:00
|
|
|
system_ss.add(tcg_system)
|