From b05dfcdfcb18e3657e919f4e66adcf107966ed46 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 5 May 2022 15:29:00 +0200 Subject: [PATCH] meson: Don't attempt to use version scripts on macOS macOS libraries don't support symbol versioning, so the only result that we achieve by passing additional flags to the linker is a bunch of messages like ld: warning: ignoring file .../libvirt/build/src/libvirt.syms, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x23 0x20 0x57 0x41 ... ) being produced during the build. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- meson.build | 3 +++ src/admin/meson.build | 14 ++++++++------ src/meson.build | 42 ++++++++++++++++++++++++------------------ tools/nss/meson.build | 18 ++++++++++++------ 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/meson.build b/meson.build index 17cc829543..5787397dcd 100644 --- a/meson.build +++ b/meson.build @@ -510,6 +510,9 @@ libvirt_no_indirect = cc.get_supported_link_arguments([ if host_machine.system() == 'windows' version_script_flags = '-Wl,' +elif host_machine.system() == 'darwin' + # macOS libraries don't support symbol versioning + version_script_flags = '' else test_file = '@0@/src/libvirt_qemu.syms'.format(meson.source_root()) if cc.has_link_argument('-Wl,--version-script=@0@'.format(test_file)) diff --git a/src/admin/meson.build b/src/admin/meson.build index cacd6feb25..692cc128a3 100644 --- a/src/admin/meson.build +++ b/src/admin/meson.build @@ -92,14 +92,16 @@ endif libvirt_admin_link_args = [ libvirt_nodelete, - '@0@@1@'.format( +] +libvirt_admin_link_depends = [] + +if version_script_flags != '' + libvirt_admin_link_args += '@0@@1@'.format( version_script_flags, libvirt_admin_syms_path, - ), -] -libvirt_admin_link_depends = [ - libvirt_admin_syms_file, -] + ) + libvirt_admin_link_depends += libvirt_admin_syms_file +endif if conf.has('WITH_REMOTE') admin_driver_lib = static_library( diff --git a/src/meson.build b/src/meson.build index ca0e756e5c..88a6f15760 100644 --- a/src/meson.build +++ b/src/meson.build @@ -379,14 +379,16 @@ libvirt_link_args = [ libvirt_flat_namespace, libvirt_no_undefined, libvirt_nodelete, - '@0@@1@'.format( +] +libvirt_link_depends = [] + +if version_script_flags != '' + libvirt_link_args += '@0@@1@'.format( version_script_flags, libvirt_syms_path, - ), -] -libvirt_link_depends = [ - libvirt_syms_file, -] + ) + libvirt_link_depends += libvirt_syms_file +endif libvirt_lib = shared_library( 'virt', @@ -431,14 +433,16 @@ endif libvirt_qemu_link_args = [ libvirt_nodelete, - '@0@@1@'.format( +] +libvirt_qemu_link_depends = [] + +if version_script_flags != '' + libvirt_qemu_link_args += '@0@@1@'.format( version_script_flags, libvirt_qemu_syms_path, - ), -] -libvirt_qemu_link_depends = [ - libvirt_qemu_syms_file, -] + ) + libvirt_qemu_link_depends += libvirt_qemu_syms_file +endif libvirt_qemu_sources = files( 'libvirt-qemu.c', @@ -488,14 +492,16 @@ endif libvirt_lxc_link_args = [ libvirt_nodelete, - '@0@@1@'.format( +] +libvirt_lxc_link_depends = [] + +if version_script_flags != '' + libvirt_lxc_link_args += '@0@@1@'.format( version_script_flags, libvirt_lxc_syms_path, - ), -] -libvirt_lxc_link_depends = [ - libvirt_lxc_syms_file, -] + ) + libvirt_lxc_link_depends += libvirt_lxc_syms_file +endif libvirt_lxc_sources = files( 'libvirt-lxc.c', diff --git a/tools/nss/meson.build b/tools/nss/meson.build index c827b865b3..85e2838fb7 100644 --- a/tools/nss/meson.build +++ b/tools/nss/meson.build @@ -55,11 +55,14 @@ nss_libvirt_syms_path = nss_libvirt_syms_file nss_libvirt_link_args = [ libvirt_export_dynamic, coverage_flags, - '@0@@1@'.format( +] + +if version_script_flags != '' + nss_libvirt_link_args += '@0@@1@'.format( version_script_flags, nss_libvirt_syms_path, - ), -] + ) +endif nss_libvirt_lib = shared_library( 'nss_libvirt', @@ -79,11 +82,14 @@ nss_libvirt_guest_syms_path = nss_libvirt_guest_syms_file nss_libvirt_guest_link_args = [ libvirt_export_dynamic, coverage_flags, - '@0@@1@'.format( +] + +if version_script_flags != '' + nss_libvirt_guest_link_args += '@0@@1@'.format( version_script_flags, nss_libvirt_guest_syms_path, - ), -] + ) +endif nss_libvirt_guest_lib = shared_library( 'nss_libvirt_guest',