[PATCH] meson: Work around too strict lld

Michal Privoznik mprivozn at redhat.com
Mon Mar 20 13:54:11 UTC 2023


With its version 16.0, the LLVM's linker turned on
--no-undefined-version by default [1]. This breaks how we detect
--version-script= detection, because at the compile time there's
no library built yet that we can use to make --version-script=
happy. To cancel their choice of defaults, pass
--undefined-version. Unfortunately, this flag is LLVM's invention
and is not supported by GNU's ld.

This all could be avoided if meson provided proper detection of
supported linker arguments, but we are far away from that [2].

1: https://reviews.llvm.org/D135402
2: https://github.com/mesonbuild/meson/issues/3047

Resolves: https://bugs.gentoo.org/902211
Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---

Compile Libvirt? Absolutely Not Gonna.

The choice of defaults for LLVM and related subprojects continues
to surprise me.

 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index c35823a79a..df0d75449a 100644
--- a/meson.build
+++ b/meson.build
@@ -535,9 +535,13 @@ elif host_machine.system() == 'darwin'
   version_script_flags = ''
 else
   test_file = '@0@/src/libvirt_qemu.syms'.format(meson.project_source_root())
+  version_script_flags = ''
   if cc.has_link_argument('-Wl,--version-script=@0@'.format(test_file))
     version_script_flags = '-Wl,--version-script='
-  else
+  elif cc.has_multi_link_arguments('-Wl,--undefined-version', '-Wl,--version-script=@0@'.format(test_file))
+    version_script_flags = '-Wl,--version-script='
+  endif
+  if version_script_flags == ''
     error('No supported version script link argument found.')
   endif
 endif
-- 
2.39.2



More information about the libvir-list mailing list