Fix linkage to libutil and libkvm on FreeBSD 11

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.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-09-04 12:52:13 +01:00
parent 2f64aa1c8d
commit 863fce796e
3 changed files with 12 additions and 9 deletions

View File

@ -1086,7 +1086,8 @@ endif
# Check for BSD kvm (kernel memory interface) # Check for BSD kvm (kernel memory interface)
if host_machine.system() == 'freebsd' if host_machine.system() == 'freebsd'
kvm_dep = cc.find_library('kvm') kvm_dep = cc.find_library('kvm')
add_project_link_arguments('-lkvm', language: 'c') else
kvm_dep = dependency('', required: false)
endif endif
libiscsi_version = '1.18.0' libiscsi_version = '1.18.0'
@ -1203,11 +1204,10 @@ have_gnu_gettext_tools = false
if not get_option('nls').disabled() if not get_option('nls').disabled()
have_gettext = cc.has_function('gettext') have_gettext = cc.has_function('gettext')
if not have_gettext if not have_gettext
intl_lib = cc.find_library('intl', required: false) intl_dep = cc.find_library('intl', required: false)
have_gettext = intl_lib.found() have_gettext = intl_dep.found()
if have_gettext else
add_project_link_arguments('-lintl', language: 'c') intl_dep = dependency('', required: false)
endif
endif endif
if not have_gettext and get_option('nls').enabled() if not have_gettext and get_option('nls').enabled()
error('gettext() is required to build libvirt') error('gettext() is required to build libvirt')
@ -1235,6 +1235,8 @@ if not get_option('nls').disabled()
have_gnu_gettext_tools = true have_gnu_gettext_tools = true
endif endif
endif endif
else
intl_dep = dependency('', required: false)
endif endif
numactl_dep = cc.find_library('numa', required: get_option('numactl')) numactl_dep = cc.find_library('numa', required: get_option('numactl'))
@ -1402,9 +1404,6 @@ if udev_dep.found()
endif endif
util_dep = cc.find_library('util', required: false) 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 not get_option('virtualport').disabled()
if cc.has_header_symbol('linux/if_link.h', 'IFLA_PORT_MAX') if cc.has_header_symbol('linux/if_link.h', 'IFLA_PORT_MAX')

View File

@ -21,7 +21,9 @@ if conf.has('WITH_BHYVE')
], ],
dependencies: [ dependencies: [
access_dep, access_dep,
kvm_dep,
src_dep, src_dep,
util_dep,
], ],
include_directories: [ include_directories: [
conf_inc_dir, conf_inc_dir,

View File

@ -187,12 +187,14 @@ virt_util_lib = static_library(
dbus_dep, dbus_dep,
devmapper_dep, devmapper_dep,
gnutls_dep, gnutls_dep,
intl_dep,
libnl_dep, libnl_dep,
m_dep, m_dep,
numactl_dep, numactl_dep,
secdriver_dep, secdriver_dep,
src_dep, src_dep,
thread_dep, thread_dep,
util_dep,
win32_dep, win32_dep,
yajl_dep, yajl_dep,
], ],