On 2024/05/22 22:45, Paolo Bonzini wrote:
On Wed, May 22, 2024 at 12:49 PM Akihiko Odaki <[email protected]> wrote:
The non-standard .fa library prefix breaks the link source
de-duplication done by Meson so drop it.
Can you show the difference in the command lines?
Without this patch:
clang -o qemu-io qemu-io.p/qemu-io.c.o -Werror -flto -Wl,--as-needed
-Wl,--no-undefined -pie -Wl,--whole-archive libblock.fa libcrypto.fa
libauthz.fa libqom.fa libio.fa libevent-loop-base.fa
-Wl,--no-whole-archive -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 libblock.fa libcrypto.fa
libauthz.fa libqom.fa libio.fa libevent-loop-base.fa @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
/usr/lib64/libzstd.so /usr/lib64/libz.so /usr/lib64/libcurl.so
/usr/lib64/libssh.so -lbz2 -lpam -Wl,--end-group
With this patch:
clang -o qemu-io qemu-io.p/qemu-io.c.o -Werror -flto -Wl,--as-needed
-Wl,--no-undefined -pie -Wl,--whole-archive -Wl,--start-group libblock.a
libcrypto.a libauthz.a libqom.a libio.a libevent-loop-base.a
-Wl,--no-whole-archive -fsanitize=cfi-icall
-fsanitize-cfi-icall-generalize-pointers -fsanitize=undefined
-fsanitize=address -fstack-protector-strong -Wl,-z,relro -Wl,-z,now
-fuse-ld=lld 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
/usr/lib64/libzstd.so /usr/lib64/libz.so /usr/lib64/libcurl.so
/usr/lib64/libssh.so -lbz2 -lpam -Wl,--end-group
One possibility to force de-duplication of objects is to change
"link_whole: foo" to "objects: foo.extract_all_objects(recursive:
false)" in all the declare_dependency() invocations that involve a
'fa' archive.
This completely gets rid of the archives, which now become just a
dummy target. I have gotten reports of "ld" exhausting the limit of
open files when using thin archives (thin archives contain "symbolic
links" to the files with the actual object code, thus reducing disk
usage), and this would also be fixed.
The disadvantage is requiring a bump to Meson 1.1.x as the minimum
required version (the recommended version is 1.2.x because earlier
versions are incompatible with recent macOS). It could be done before
this patch (because then this patch is a total no-op), or after too to
fix the immediate issue with sanitizer builds.
I wrote such a change and applied after this patch, but it caused
dependencies to be ignored. Please see "[PATCH RFC 0/2] meson: Pass
objects to declare_dependency()", which I sent earlier.
Regards,
Akihiko Odaki