[PATCH] meson: Work around too strict lld

Michal Privoznik posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/02045cb3a67b7ab49dc073e8f265d12bf3892c76.1679320214.git.mprivozn@redhat.com
meson.build | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] meson: Work around too strict lld
Posted by Michal Privoznik 1 year, 1 month ago
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@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
Re: [PATCH] meson: Work around too strict lld
Posted by Daniel P. Berrangé 1 year, 1 month ago
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@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 :|
Re: [PATCH] meson: Work around too strict lld
Posted by Michal Prívozník 1 year, 1 month ago
On 3/20/23 15:19, Daniel P. Berrangé wrote:
> 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@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 ?

Yeah, I think we can drop the check completely and went with what you
suggests. V2 on its way.

Michal