Skip to contentSkip to conversation

meson: Pass objects to declare_dependency()

RFC PATCH In review Akihiko Odaki 3 participants 5 messages May 24, 2024 – May 27, 2024

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

RFC PATCH 1/2 meson: Pass objects to declare_dependency()

In reply to Akihiko Odaki

We used to request declare_dependency() to link_whole static libraries. If a static library is a thin archive, GNU ld needs to open all object files referenced by the archieve, and sometimes reaches to the open file limit.

Another problem with link_whole is that it 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.

Instead of using link_whole, extract objects included in static libraries and pass them to declare_dependency(). This requires Meson 1.1.0 or later.

---
 docs/devel/build-system.rst           |  2 +-
 meson.build                           | 27 ++++++++++++++-------------
 gdbstub/meson.build                   |  4 ++--
 subprojects/libvhost-user/meson.build |  2 +-
 tests/qtest/libqos/meson.build        |  2 +-
 5 files changed, 19 insertions(+), 18 deletions(-)
docs/devel/build-system.rst +1 -1
index 5baf027b7614..36ad40c76d2a 100644
@@ -238,7 +238,7 @@ Subsystem sourcesets:
     libchardev = static_library('chardev', chardev_ss.sources(),
                                 build_by_default: false)
 
-    chardev = declare_dependency(link_whole: libchardev)
+    chardev = declare_dependency(objects: libchardev.extract_all_objects(recursive: false))
 
 Target-independent emulator sourcesets:
   Various general purpose helper code is compiled only once and
meson.build +14 -13
index d6549722b50d..0e6fa2e4b777 100644
@@ -1,4 +1,4 @@
-project('qemu', ['c'], meson_version: '>=0.63.0',
+project('qemu', ['c'], meson_version: '>=1.1.0',
         default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
                           'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'],
         version: files('VERSION'))
@@ -3456,20 +3456,20 @@ subdir('gdbstub')
 
 if enable_modules
   libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
-  modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
+  modulecommon = declare_dependency(objects: libmodulecommon.extract_all_objects(recursive: false), compile_args: '-DBUILD_DSO')
 endif
 
 qom_ss = qom_ss.apply({})
 libqom = static_library('qom', qom_ss.sources() + genh,
                         dependencies: [qom_ss.dependencies()],
                         build_by_default: false)
-qom = declare_dependency(link_whole: libqom)
+qom = declare_dependency(objects: libqom.extract_all_objects(recursive: false))
 
 event_loop_base = files('event-loop-base.c')
 event_loop_base = static_library('event-loop-base',
                                  sources: event_loop_base + genh,
                                  build_by_default: false)
-event_loop_base = declare_dependency(link_whole: event_loop_base,
+event_loop_base = declare_dependency(objects: event_loop_base.extract_all_objects(recursive: false),
                                      dependencies: [qom])
 
 stub_ss = stub_ss.apply({})
@@ -3703,7 +3703,7 @@ libauthz = static_library('authz', authz_ss.sources() + genh,
                           dependencies: [authz_ss.dependencies()],
                           build_by_default: false)
 
-authz = declare_dependency(link_whole: libauthz,
+authz = declare_dependency(objects: libauthz.extract_all_objects(recursive: false),
                            dependencies: qom)
 
 crypto_ss = crypto_ss.apply({})
@@ -3711,7 +3711,7 @@ libcrypto = static_library('crypto', crypto_ss.sources() + genh,
                            dependencies: [crypto_ss.dependencies()],
                            build_by_default: false)
 
-crypto = declare_dependency(link_whole: libcrypto,
+crypto = declare_dependency(objects: libcrypto.extract_all_objects(recursive: false),
                             dependencies: [authz, qom])
 
 io_ss = io_ss.apply({})
@@ -3720,7 +3720,8 @@ libio = static_library('io', io_ss.sources() + genh,
                        link_with: libqemuutil,
                        build_by_default: false)
 
-io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
+io = declare_dependency(objects: libio.extract_all_objects(recursive: false),
+                        dependencies: [crypto, qom])
 
 libmigration = static_library('migration', sources: migration_files + genh,
                               build_by_default: false)
@@ -3734,7 +3735,7 @@ libblock = static_library('block', block_ss.sources() + genh,
                           link_depends: block_syms,
                           build_by_default: false)
 
-block = declare_dependency(link_whole: [libblock],
+block = declare_dependency(objects: libblock.extract_all_objects(recursive: false),
                            link_args: '@block.syms',
                            dependencies: [crypto, io])
 
@@ -3743,7 +3744,7 @@ libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
                              dependencies: blockdev_ss.dependencies(),
                              build_by_default: false)
 
-blockdev = declare_dependency(link_whole: [libblockdev],
+blockdev = declare_dependency(objects: libblockdev.extract_all_objects(recursive: false),
                               dependencies: [block, event_loop_base])
 
 qmp_ss = qmp_ss.apply({})
@@ -3751,18 +3752,18 @@ libqmp = static_library('qmp', qmp_ss.sources() + genh,
                         dependencies: qmp_ss.dependencies(),
                         build_by_default: false)
 
-qmp = declare_dependency(link_whole: [libqmp])
+qmp = declare_dependency(objects: libqmp.extract_all_objects(recursive: false))
 
 libchardev = static_library('chardev', chardev_ss.sources() + genh,
                             dependencies: chardev_ss.dependencies(),
                             build_by_default: false)
 
-chardev = declare_dependency(link_whole: libchardev)
+chardev = declare_dependency(objects: libchardev.extract_all_objects(recursive: false))
 
 hwcore_ss = hwcore_ss.apply({})
 libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
                            build_by_default: false)
-hwcore = declare_dependency(link_whole: libhwcore)
+hwcore = declare_dependency(objects: libhwcore.extract_all_objects(recursive: false))
 common_ss.add(hwcore)
 
 ###########
@@ -3774,7 +3775,7 @@ foreach m : block_mods + system_mods
   emulator_modules += shared_module(m.name(),
                 build_by_default: true,
                 name_prefix: '',
-                link_whole: m,
+                objects: m.extract_all_objects(recursive: false),
                 install: true,
                 install_dir: qemu_moddir)
 endforeach
gdbstub/meson.build +2 -2
index c91e398ae726..dff741ddd4d7 100644
@@ -26,9 +26,9 @@ libgdb_system = static_library('gdb_system',
                                 gdb_system_ss.sources() + genh,
                                 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'))
subprojects/libvhost-user/meson.build +1 -1
index a18014e7f26f..b3a2a3abf6be 100644
@@ -17,7 +17,7 @@ vhost_user = static_library('vhost-user',
                             c_args: '-D_GNU_SOURCE')
 
 executable('link-test', files('link-test.c'),
-           link_whole: vhost_user)
+           objects: vhost_user.extract_all_objects(recursive: false))
 
 vhost_user_glib = static_library('vhost-user-glib',
                                  files('libvhost-user-glib.c'),
tests/qtest/libqos/meson.build +1 -1
index 45b81c83ade3..5b18aa4eaeb9 100644
@@ -70,4 +70,4 @@ endif
 libqos = static_library('qos', libqos_srcs + genh,
                         build_by_default: false)
 
-qos = declare_dependency(link_whole: libqos)
+qos = declare_dependency(objects: libqos.extract_all_objects(recursive: false))
Signature · 1 line
2.45.1
#0 lore raw

cover meson: Pass objects to declare_dependency()

Based-on: <[email protected]> ("[PATCH v4 0/4] Fix sanitizer errors with clang 18.1.1")

This is changes suggested by Paolo Bonzini at:
https://lore.kernel.org/all/CABgObfYoEFZsW-H4WJ7xW0B85OqFi932d3-DmNAb6zTohFn=Og@mail.gmail.com/

Unfortunately it broke builds on my system. Below are the errors I observed:

clang -o qemu-img libauthz.a.p/authz_base.c.o libauthz.a.p/authz_list.c.o libauthz.a.p/authz_listfile.c.o libauthz.a.p/authz_simple.c.o libauthz.a.p/authz_pamacct.c.o libqom.a.p/qom_container.c.o libqom.a.p/qom_object.c.o libqom.a.p/qom_object_interfaces.c.o libqom.a.p/qom_qom-qobject.c.o libblock.a.p/block.c.o libblock.a.p/blockjob.c.o libblock.a.p/job.c.o libblock.a.p/qemu-io-cmds.c.o libblock.a.p/replication.c.o libblock.a.p/nbd_client.c.o libblock.a.p/nbd_client-connection.c.o libblock.a.p/nbd_common.c.o libblock.a.p/scsi_utils.c.o libblock.a.p/scsi_pr-manager.c.o libblock.a.p/scsi_pr-manager-helper.c.o libblock.a.p/block_accounting.c.o libblock.a.p/block_aio_task.c.o libblock.a.p/block_amend.c.o libblock.a.p/block_backup.c.o libblock.a.p/block_blkdebug.c.o libblock.a.p/block_blklogwrites.c.o libblock.a.p/block_blkverify.c.o libblock.a.p/block_block-backend.c.o libblock.a.p/block_block-copy.c.o libblock.a.p/block_commit.c.o libblock.a.p/block_copy-before-write.c.o libblock.a.p/block_copy-on-read.c.o libblock.a.p/block_create.c.o libblock.a.p/block_crypto.c.o libblock.a.p/block_dirty-bitmap.c.o libblock.a.p/block_filter-compress.c.o libblock.a.p/block_graph-lock.c.o libblock.a.p/block_io.c.o libblock.a.p/block_mirror.c.o libblock.a.p/block_nbd.c.o libblock.a.p/block_null.c.o libblock.a.p/block_preallocate.c.o libblock.a.p/block_progress_meter.c.o libblock.a.p/block_qapi.c.o libblock.a.p/block_qcow2.c.o libblock.a.p/block_qcow2-bitmap.c.o libblock.a.p/block_qcow2-cache.c.o libblock.a.p/block_qcow2-cluster.c.o libblock.a.p/block_qcow2-refcount.c.o libblock.a.p/block_qcow2-snapshot.c.o libblock.a.p/block_qcow2-threads.c.o libblock.a.p/block_quorum.c.o libblock.a.p/block_raw-format.c.o libblock.a.p/block_reqlist.c.o libblock.a.p/block_snapshot.c.o libblock.a.p/block_snapshot-access.c.o libblock.a.p/block_throttle.c.o libblock.a.p/block_throttle-groups.c.o libblock.a.p/block_write-threshold.c.o libblock.a.p/block_qcow.c.o libblock.a.p/block_vdi.c.o libblock.a.p/block_vhdx-endian.c.o libblock.a.p/block_vhdx-log.c.o libblock.a.p/block_vhdx.c.o libblock.a.p/block_vmdk.c.o libblock.a.p/block_vpc.c.o libblock.a.p/block_cloop.c.o libblock.a.p/block_bochs.c.o libblock.a.p/block_vvfat.c.o libblock.a.p/block_dmg.c.o libblock.a.p/block_qed-check.c.o libblock.a.p/block_qed-cluster.c.o libblock.a.p/block_qed-l2-cache.c.o libblock.a.p/block_qed-table.c.o libblock.a.p/block_qed.c.o libblock.a.p/block_parallels.c.o libblock.a.p/block_parallels-ext.c.o libblock.a.p/block_file-posix.c.o libblock.a.p/block_nvme.c.o libblock.a.p/block_replication.c.o libblock.a.p/block_stream.c.o libblock.a.p/block_monitor_bitmap-qmp-cmds.c.o libblock.a.p/block_curl.c.o libblock.a.p/block_ssh.c.o libblock.a.p/block_dmg-bz2.c.o libblock.a.p/meson-generated_.._block_block-gen.c.o libcrypto.a.p/crypto_afsplit.c.o libcrypto.a.p/crypto_akcipher.c.o libcrypto.a.p/crypto_block-luks.c.o libcrypto.a.p/crypto_block-qcow.c.o libcrypto.a.p/crypto_block.c.o libcrypto.a.p/crypto_cipher.c.o libcrypto.a.p/crypto_der.c.o libcrypto.a.p/crypto_hash.c.o libcrypto.a.p/crypto_hmac.c.o libcrypto.a.p/crypto_ivgen-essiv.c.o libcrypto.a.p/crypto_ivgen-plain.c.o libcrypto.a.p/crypto_ivgen-plain64.c.o libcrypto.a.p/crypto_ivgen.c.o libcrypto.a.p/crypto_pbkdf.c.o libcrypto.a.p/crypto_secret_common.c.o libcrypto.a.p/crypto_secret.c.o libcrypto.a.p/crypto_tlscreds.c.o libcrypto.a.p/crypto_tlscredsanon.c.o libcrypto.a.p/crypto_tlscredspsk.c.o libcrypto.a.p/crypto_tlscredsx509.c.o libcrypto.a.p/crypto_tlssession.c.o libcrypto.a.p/crypto_rsakey.c.o libcrypto.a.p/crypto_hash-gnutls.c.o libcrypto.a.p/crypto_hmac-gnutls.c.o libcrypto.a.p/crypto_pbkdf-gnutls.c.o libcrypto.a.p/crypto_secret_keyring.c.o libio.a.p/io_channel-buffer.c.o libio.a.p/io_channel-command.c.o libio.a.p/io_channel-file.c.o libio.a.p/io_channel-null.c.o libio.a.p/io_channel-socket.c.o libio.a.p/io_channel-tls.c.o libio.a.p/io_channel-util.c.o libio.a.p/io_channel-watch.c.o libio.a.p/io_channel-websock.c.o libio.a.p/io_channel.c.o libio.a.p/io_dns-resolver.c.o libio.a.p/io_net-listener.c.o libio.a.p/io_task.c.o libevent-loop-base.a.p/event-loop-base.c.o qemu-img.p/qemu-img.c.o -Werror -flto -Wl,--as-needed -Wl,--no-undefined -pie -fsanitize=cfi-icall -fsanitize-cfi-icall-generalize-pointers -fsanitize=undefined -fsanitize=address -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -fuse-ld=lld -Wl,--start-group libqemuutil.a subprojects/libvhost-user/libvhost-user-glib.a subprojects/libvhost-user/libvhost-user.a @block.syms /usr/lib64/libgio-2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libglib-2.0.so /usr/lib64/libgmodule-2.0.so -pthread /usr/lib64/libgnutls.so -lm /usr/lib64/libpixman-1.so -Wl,--end-group ld.lld: error: undefined symbol: pam_start

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by pamacct.c:40 (/home/me/q/var/qemu/build/../authz/pamacct.c:40)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)

ld.lld: error: undefined symbol: pam_strerror

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by pamacct.c:45 (/home/me/q/var/qemu/build/../authz/pamacct.c:45)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)
referenced by pamacct.c:53 (/home/me/q/var/qemu/build/../authz/pamacct.c:53)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)

ld.lld: error: undefined symbol: pam_acct_mgmt

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by pamacct.c:50 (/home/me/q/var/qemu/build/../authz/pamacct.c:50)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)

ld.lld: error: undefined symbol: pam_end

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by pamacct.c:51 (/home/me/q/var/qemu/build/../authz/pamacct.c:51)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)

ld.lld: error: undefined symbol: ZSTD_createCCtx

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:203 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:203)
qemu-img.lto.o:(qcow2_zstd_compress.cfi)

ld.lld: error: undefined symbol: ZSTD_compressStream2

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:225 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:225)
qemu-img.lto.o:(qcow2_zstd_compress.cfi)

ld.lld: error: undefined symbol: ZSTD_freeCCtx

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:240 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:240)
qemu-img.lto.o:(qcow2_zstd_compress.cfi)

ld.lld: error: undefined symbol: deflateInit2_

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by qcow2-threads.c:101 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:101)
qemu-img.lto.o:(qcow2_zlib_compress.cfi)
referenced by qcow.c:1081 (/home/me/q/var/qemu/build/../block/qcow.c:1081)
qemu-img.lto.o:(qcow_co_pwritev_compressed.cfi)

ld.lld: error: undefined symbol: deflate

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by qcow2-threads.c:116 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:116)
qemu-img.lto.o:(qcow2_zlib_compress.cfi)
referenced by qcow.c:1094 (/home/me/q/var/qemu/build/../block/qcow.c:1094)
qemu-img.lto.o:(qcow_co_pwritev_compressed.cfi)

ld.lld: error: undefined symbol: deflateEnd

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

referenced by qcow2-threads.c:123 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:123)
qemu-img.lto.o:(qcow2_zlib_compress.cfi)
referenced by qcow.c:1102 (/home/me/q/var/qemu/build/../block/qcow.c:1102)
qemu-img.lto.o:(qcow_co_pwritev_compressed.cfi)
referenced by qcow.c:1096 (/home/me/q/var/qemu/build/../block/qcow.c:1096)
qemu-img.lto.o:(qcow_co_pwritev_compressed.cfi)

ld.lld: error: undefined symbol: ZSTD_createDCtx

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:271 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:271)
qemu-img.lto.o:(qcow2_zstd_decompress.cfi)

ld.lld: error: undefined symbol: ZSTD_decompressStream

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:291 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:291)
qemu-img.lto.o:(qcow2_zstd_decompress.cfi)

ld.lld: error: undefined symbol: ZSTD_isError

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by qcow2-threads.c:293 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:293)
qemu-img.lto.o:(qcow2_zstd_decompress.cfi)

ld.lld: error: undefined symbol: ZSTD_freeDCtx

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by qcow2-threads.c:322 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:322)
qemu-img.lto.o:(qcow2_zstd_decompress.cfi)
referenced by qcow2-threads.c:322 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:322)
qemu-img.lto.o:(qcow2_zstd_decompress.cfi)

ld.lld: error: undefined symbol: inflateInit2_

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

referenced by qcow2-threads.c:152 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:152)
qemu-img.lto.o:(qcow2_zlib_decompress.cfi)
referenced by qcow.c:581 (/home/me/q/var/qemu/build/../block/qcow.c:581)
qemu-img.lto.o:(decompress_cluster)

ld.lld: error: undefined symbol: inflate

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

referenced by qcow2-threads.c:157 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:157)
qemu-img.lto.o:(qcow2_zlib_decompress.cfi)
referenced by qcow.c:584 (/home/me/q/var/qemu/build/../block/qcow.c:584)
qemu-img.lto.o:(decompress_cluster)
referenced by cloop.c:244 (/home/me/q/var/qemu/build/../block/cloop.c:244)
qemu-img.lto.o:(cloop_read_block)
referenced 3 more times

ld.lld: error: undefined symbol: inflateEnd

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

referenced by qcow2-threads.c:169 (/home/me/q/var/qemu/build/../block/qcow2-threads.c:169)
qemu-img.lto.o:(qcow2_zlib_decompress.cfi)
referenced by qcow.c:0 (/home/me/q/var/qemu/build/../block/qcow.c:0)
qemu-img.lto.o:(decompress_cluster)
referenced by qcow.c:0 (/home/me/q/var/qemu/build/../block/qcow.c:0)
qemu-img.lto.o:(decompress_cluster)
referenced 2 more times

ld.lld: error: undefined symbol: uncompress

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by vmdk.c:1958 (/home/me/q/var/qemu/build/../block/vmdk.c:1958)
qemu-img.lto.o:(vmdk_read_extent)

ld.lld: error: undefined symbol: compress

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by vmdk.c:1865 (/home/me/q/var/qemu/build/../block/vmdk.c:1865)
qemu-img.lto.o:(vmdk_write_extent)

ld.lld: error: undefined symbol: inflateReset

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

referenced by cloop.c:240 (/home/me/q/var/qemu/build/../block/cloop.c:240)
qemu-img.lto.o:(cloop_read_block)
referenced by cloop.c:240 (/home/me/q/var/qemu/build/../block/cloop.c:240)
qemu-img.lto.o:(cloop_read_block)
referenced by dmg.c:658 (/home/me/q/var/qemu/build/../block/dmg.c:658)

              qemu-img.lto.o:(dmg_read_chunk)

referenced 1 more times

ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

---
Akihiko Odaki (2):
meson: Pass objects to declare_dependency()
Revert "meson: Propagate gnutls dependency"

 docs/devel/build-system.rst           |  2 +-
 meson.build                           | 31 ++++++++++++++++---------------
 block/meson.build                     |  2 +-
 gdbstub/meson.build                   |  4 ++--
 io/meson.build                        |  2 +-
 storage-daemon/meson.build            |  2 +-
 subprojects/libvhost-user/meson.build |  2 +-
 tests/qtest/libqos/meson.build        |  2 +-
 ui/meson.build                        |  2 +-
 9 files changed, 25 insertions(+), 24 deletions(-)

---
base-commit: 4a207ef32de97bc785ced1987eacab7665b49420
change-id: 20240524-objects-3dc07e485b7f

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#3 lore raw

RFC PATCH 2/2 Revert "meson: Propagate gnutls dependency"

This reverts commit 3eacf70bb5a83e4775ad8003cbca63a40f70c8c2.

---
 meson.build                | 4 ++--
 block/meson.build          | 2 +-
 io/meson.build             | 2 +-
 storage-daemon/meson.build | 2 +-
 ui/meson.build             | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
meson.build +2 -2
index 0e6fa2e4b777..cd5a24807ec8 100644
@@ -3518,7 +3518,7 @@ if have_block
     'blockdev-nbd.c',
     'iothread.c',
     'job-qmp.c',
-  ), gnutls)
+  ))
 
   # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
   # os-win32.c does not
@@ -4008,7 +4008,7 @@ if have_tools
   qemu_io = executable('qemu-io', files('qemu-io.c'),
              dependencies: [block, qemuutil], install: true)
   qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
-               dependencies: [blockdev, qemuutil, gnutls, selinux],
+               dependencies: [blockdev, qemuutil, selinux],
                install: true)
 
   subdir('storage-daemon')
block/meson.build +1 -1
index e1f03fd773e9..0165ac178370 100644
@@ -39,7 +39,7 @@ block_ss.add(files(
   'throttle.c',
   'throttle-groups.c',
   'write-threshold.c',
-), zstd, zlib, gnutls)
+), zstd, zlib)
 
 system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
 system_ss.add(files('block-ram-registrar.c'))
io/meson.build +1 -1
index 283b9b2bdbdf..1164812f9126 100644
@@ -13,4 +13,4 @@ io_ss.add(files(
   'dns-resolver.c',
   'net-listener.c',
   'task.c',
-), gnutls)
+))
storage-daemon/meson.build +1 -1
index 46267b63e72b..b955949fd6f3 100644
@@ -1,6 +1,6 @@
 qsd_ss = ss.source_set()
 qsd_ss.add(files('qemu-storage-daemon.c'))
-qsd_ss.add(blockdev, chardev, qmp, qom, qemuutil, gnutls)
+qsd_ss.add(blockdev, chardev, qmp, qom, qemuutil)
 
 subdir('qapi')
 
ui/meson.build +1 -1
index a5ce22a678ba..9358439ceeed 100644
@@ -43,7 +43,7 @@ vnc_ss.add(files(
   'vnc-jobs.c',
   'vnc-clipboard.c',
 ))
-vnc_ss.add(zlib, jpeg, gnutls)
+vnc_ss.add(zlib, jpeg)
 vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
 system_ss.add_all(when: [vnc, pixman], if_true: vnc_ss)
 system_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
Signature · 1 line
2.45.1
#4 lore raw
In reply to Akihiko Odaki
Quoted 4 lines · Akihiko Odaki

Based-on: <[email protected]> ("[PATCH v4 0/4] Fix sanitizer errors with clang 18.1.1")

Quoted 9 lines

This is changes suggested by Paolo Bonzini at:
https://lore.kernel.org/all/CABgObfYoEFZsW-H4WJ7xW0B85OqFi932d3-DmNAb6zTohFn=Og@mail.gmail.com/

Unfortunately it broke builds on my system. Below are the errors I observed:

ld.lld: error: undefined symbol: pam_start

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by pamacct.c:40 (/home/me/q/var/qemu/build/../authz/pamacct.c:40)
qemu-img.lto.o:(qauthz_pam_is_allowed.cfi)

Thanks Akihiko for putting together the RFC! This is simply because dependencies need to be added to the declare_dependency(). I'll post the full series once I finish testing it.

Paolo

#2 lore raw
In reply to Akihiko Odaki
Quoted 3 lines · Akihiko Odaki

We used to request declare_dependency() to link_whole static libraries. If a static library is a thin archive, GNU ld needs to open all object files referenced by the archieve, and sometimes reaches to the open

"archive"

Quoted 19 lines

file limit.

Another problem with link_whole is that it 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.

Instead of using link_whole, extract objects included in static libraries and pass them to declare_dependency(). This requires Meson 1.1.0 or later.

---
  docs/devel/build-system.rst           |  2 +-
  meson.build                           | 27 ++++++++++++++-------------
  gdbstub/meson.build                   |  4 ++--
  subprojects/libvhost-user/meson.build |  2 +-
  tests/qtest/libqos/meson.build        |  2 +-
  5 files changed, 19 insertions(+), 18 deletions(-)