[PATCH] build: suppress "ignoring duplicate libraries" warning on macOS

Laine Stump posted 1 patch 5 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20231103172247.540784-1-laine@redhat.com
meson.build       | 4 ++++
src/meson.build   | 1 +
tests/meson.build | 1 +
tools/meson.build | 1 +
4 files changed, 7 insertions(+)
[PATCH] build: suppress "ignoring duplicate libraries" warning on macOS
Posted by Laine Stump 5 months, 3 weeks ago
Xcode 15, which provides the compiler toolchain for building libvirt
on macOS has switched to a new linker that warns about duplicated
"-lblah" options on the ld commandline. In practice this is impossible
to prevent in a large project, and also harmless.

Fortunately the new ld command also has an option,
-no_warn_duplicate_libraries, that supresses this harmless/pointless
warning, meson has a simple way to check if that option is supported,
and libvirt's meson.build files already have examples of adding an
option to the ld commandline if it's available.

Signed-off-by: Laine Stump <laine@redhat.com>
---
 meson.build       | 4 ++++
 src/meson.build   | 1 +
 tests/meson.build | 1 +
 tools/meson.build | 1 +
 4 files changed, 7 insertions(+)

diff --git a/meson.build b/meson.build
index dc0969abcc..a39f942617 100644
--- a/meson.build
+++ b/meson.build
@@ -542,6 +542,10 @@ libvirt_no_indirect = cc.get_supported_link_arguments([
   '-Wl,--no-copy-dt-needed-entries',
 ])
 
+libvirt_no_warn_duplicate_libraries = cc.get_supported_link_arguments([
+  '-Wl,-no_warn_duplicate_libraries',
+])
+
 if host_machine.system() == 'windows'
   version_script_flags = '-Wl,'
 elif host_machine.system() == 'darwin'
diff --git a/src/meson.build b/src/meson.build
index 5fc4d03b4a..6538c43628 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -18,6 +18,7 @@ src_dep = declare_dependency(
   link_args: (
     libvirt_relro
     + libvirt_no_indirect
+    + libvirt_no_warn_duplicate_libraries
     + coverage_flags
     + driver_modules_flags
     + win32_link_flags
diff --git a/tests/meson.build b/tests/meson.build
index b235c5f4dd..e1cd57654a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -28,6 +28,7 @@ tests_dep = declare_dependency(
   ],
   link_args: (
     libvirt_export_dynamic
+    + libvirt_no_warn_duplicate_libraries
     + libvirt_flat_namespace
     + coverage_flags
   ),
diff --git a/tools/meson.build b/tools/meson.build
index f2d58cfdcb..c72f760a1d 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -16,6 +16,7 @@ tools_dep = declare_dependency(
     libvirt_relro
     + libvirt_no_indirect
     + libvirt_no_undefined
+    + libvirt_no_warn_duplicate_libraries
   ),
 )
 
-- 
2.41.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] build: suppress "ignoring duplicate libraries" warning on macOS
Posted by Andrea Bolognani 5 months, 3 weeks ago
On Fri, Nov 03, 2023 at 01:22:32PM -0400, Laine Stump wrote:
> Xcode 15, which provides the compiler toolchain for building libvirt
> on macOS has switched to a new linker that warns about duplicated
> "-lblah" options on the ld commandline. In practice this is impossible
> to prevent in a large project, and also harmless.
>
> Fortunately the new ld command also has an option,
> -no_warn_duplicate_libraries, that supresses this harmless/pointless
> warning, meson has a simple way to check if that option is supported,
> and libvirt's meson.build files already have examples of adding an
> option to the ld commandline if it's available.
>
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
>  meson.build       | 4 ++++
>  src/meson.build   | 1 +
>  tests/meson.build | 1 +
>  tools/meson.build | 1 +
>  4 files changed, 7 insertions(+)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] build: suppress "ignoring duplicate libraries" warning on macOS
Posted by Daniel P. Berrangé 5 months, 3 weeks ago
On Fri, Nov 03, 2023 at 01:22:32PM -0400, Laine Stump wrote:
> Xcode 15, which provides the compiler toolchain for building libvirt
> on macOS has switched to a new linker that warns about duplicated
> "-lblah" options on the ld commandline. In practice this is impossible
> to prevent in a large project, and also harmless.
> 
> Fortunately the new ld command also has an option,
> -no_warn_duplicate_libraries, that supresses this harmless/pointless
> warning, meson has a simple way to check if that option is supported,
> and libvirt's meson.build files already have examples of adding an
> option to the ld commandline if it's available.
> 
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
>  meson.build       | 4 ++++
>  src/meson.build   | 1 +
>  tests/meson.build | 1 +
>  tools/meson.build | 1 +
>  4 files changed, 7 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


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 :|
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org