[PATCH v2] Fix linkage to libutil and libkvm on FreeBSD 11

Daniel P. Berrangé berrange at redhat.com
Thu Sep 10 11:52:52 UTC 2020


We are currently adding -lutil and -lkvm to the linker using the
add_project_link_arguments method. On FreeBSD 11.4, this results in
build errors because the args appear too early in the command line.

We need to pass the libraries as dependencies so that they get placed
at the same point in the linker args as other dependencies.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 meson.build           | 17 ++++++++---------
 src/bhyve/meson.build |  2 ++
 src/util/meson.build  |  2 ++
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/meson.build b/meson.build
index 33eaa9ff56..bcb978292b 100644
--- a/meson.build
+++ b/meson.build
@@ -1086,7 +1086,8 @@ endif
 # Check for BSD kvm (kernel memory interface)
 if host_machine.system() == 'freebsd'
   kvm_dep = cc.find_library('kvm')
-  add_project_link_arguments('-lkvm', language: 'c')
+else
+  kvm_dep = dependency('', required: false)
 endif
 
 libiscsi_version = '1.18.0'
@@ -1203,11 +1204,10 @@ have_gnu_gettext_tools = false
 if not get_option('nls').disabled()
   have_gettext = cc.has_function('gettext')
   if not have_gettext
-    intl_lib = cc.find_library('intl', required: false)
-    have_gettext = intl_lib.found()
-    if have_gettext
-      add_project_link_arguments('-lintl', language: 'c')
-    endif
+    intl_dep = cc.find_library('intl', required: false)
+    have_gettext = intl_dep.found()
+  else
+    intl_dep = dependency('', required: false)
   endif
   if not have_gettext and get_option('nls').enabled()
     error('gettext() is required to build libvirt')
@@ -1235,6 +1235,8 @@ if not get_option('nls').disabled()
       have_gnu_gettext_tools = true
     endif
   endif
+else
+  intl_dep = dependency('', required: false)
 endif
 
 numactl_dep = cc.find_library('numa', required: get_option('numactl'))
@@ -1402,9 +1404,6 @@ if udev_dep.found()
 endif
 
 util_dep = cc.find_library('util', required: false)
-if util_dep.found()
-  add_project_link_arguments('-lutil', language: 'c')
-endif
 
 if not get_option('virtualport').disabled()
   if cc.has_header_symbol('linux/if_link.h', 'IFLA_PORT_MAX')
diff --git a/src/bhyve/meson.build b/src/bhyve/meson.build
index 7d54718820..975f93a9c0 100644
--- a/src/bhyve/meson.build
+++ b/src/bhyve/meson.build
@@ -21,7 +21,9 @@ if conf.has('WITH_BHYVE')
     ],
     dependencies: [
       access_dep,
+      kvm_dep,
       src_dep,
+      util_dep,
     ],
     include_directories: [
       conf_inc_dir,
diff --git a/src/util/meson.build b/src/util/meson.build
index f7092cc3f1..bf556e7ae6 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -187,12 +187,14 @@ virt_util_lib = static_library(
     dbus_dep,
     devmapper_dep,
     gnutls_dep,
+    intl_dep,
     libnl_dep,
     m_dep,
     numactl_dep,
     secdriver_dep,
     src_dep,
     thread_dep,
+    util_dep,
     win32_dep,
     yajl_dep,
   ],
-- 
2.26.2




More information about the libvir-list mailing list