[PATCH] meson: Work around too strict lld

Daniel P. Berrangé berrange at redhat.com
Mon Mar 20 14:19:01 UTC 2023


On Mon, Mar 20, 2023 at 02:54:11PM +0100, Michal Privoznik wrote:
> 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

Should we bother probing for the argument at all ?

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.project_source_root())
  if cc.has_link_argument('-Wl,--version-script=@0@'.format(test_file))
    version_script_flags = '-Wl,--version-script='
  else
    error('No supported version script link argument found.')
  endif
endif


In terms of our platforms, the 'else' clause is only impacting Linux and
FreeBSD. Don't both of those platforms support -Wl,--version-script=
since they both use ELF ?

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


More information about the libvir-list mailing list