mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
meson: Check header usability
This fixes cross-building in some scenarios. Specifically, when building for armv7l on x86_64, has_header() will see the x86_64 version of the linux/kmv.h header and consider it to be usable. Later, when an attempt is made to actually include it, the compiler will quickly realize that things can't quite work. The reason why we haven't hit this in our CI is that we only ever install the foreign version of header files. When building the Debian package, however, some of the Debian-specific tooling will bring in the native version of the Linux headers in addition to the foreign one, causing meson to misreport the header's availability status. Checking for actual usability, as opposed to mere presence, of headers is enough to make things work correctly in all cases. The meson documentation recommends using has_header() instead of check_header() whenever possible for performance reasons, but while testing this change on fairly old and underpowered hardware I haven't been able to measure any meaningful slowdown. https://bugs.debian.org/1024504 Suggested-by: Helmut Grohne <helmut@subdivi.de> Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a3cc0e9ceb
commit
0324adb647
16
meson.build
16
meson.build
@ -636,14 +636,14 @@ if host_machine.system() == 'freebsd'
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
foreach name : headers
|
foreach name : headers
|
||||||
if cc.has_header(name)
|
if cc.check_header(name)
|
||||||
conf.set('WITH_@0@'.format(name.underscorify().to_upper()), 1)
|
conf.set('WITH_@0@'.format(name.underscorify().to_upper()), 1)
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
# check for kernel header required by src/util/virnetdevbridge.c
|
# check for kernel header required by src/util/virnetdevbridge.c
|
||||||
if host_machine.system() == 'linux'
|
if host_machine.system() == 'linux'
|
||||||
if not cc.has_header('linux/sockios.h')
|
if not cc.check_header('linux/sockios.h')
|
||||||
error('You must install kernel-headers in order to compile libvirt with QEMU or LXC support')
|
error('You must install kernel-headers in order to compile libvirt with QEMU or LXC support')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -920,7 +920,7 @@ endif
|
|||||||
dlopen_use = host_machine.system() != 'windows'
|
dlopen_use = host_machine.system() != 'windows'
|
||||||
dlopen_dep = cc.find_library('dl', required: dlopen_use)
|
dlopen_dep = cc.find_library('dl', required: dlopen_use)
|
||||||
if dlopen_dep.found()
|
if dlopen_dep.found()
|
||||||
if not cc.has_header('dlfcn.h')
|
if not cc.check_header('dlfcn.h')
|
||||||
error('Unable to find dlfcn.h')
|
error('Unable to find dlfcn.h')
|
||||||
endif
|
endif
|
||||||
conf.set('WITH_DLFCN_H', 1)
|
conf.set('WITH_DLFCN_H', 1)
|
||||||
@ -1052,7 +1052,7 @@ if not get_option('nls').disabled()
|
|||||||
error('gettext() is required to build libvirt')
|
error('gettext() is required to build libvirt')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if cc.has_header('libintl.h')
|
if cc.check_header('libintl.h')
|
||||||
conf.set('WITH_LIBINTL_H', 1)
|
conf.set('WITH_LIBINTL_H', 1)
|
||||||
elif get_option('nls').enabled()
|
elif get_option('nls').enabled()
|
||||||
error('libintl.h is required to build libvirt')
|
error('libintl.h is required to build libvirt')
|
||||||
@ -1275,7 +1275,7 @@ if wireshark_dep.found()
|
|||||||
|
|
||||||
# Wireshark is installing ws_version.h since v2.9.0, but some distributions
|
# Wireshark is installing ws_version.h since v2.9.0, but some distributions
|
||||||
# are not shipping it.
|
# are not shipping it.
|
||||||
if cc.has_header('wireshark/ws_version.h')
|
if cc.check_header('wireshark/ws_version.h')
|
||||||
conf.set('WITH_WS_VERSION', 1)
|
conf.set('WITH_WS_VERSION', 1)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -1470,7 +1470,7 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# If building with libxl, use the libxl utility header and lib too
|
# If building with libxl, use the libxl utility header and lib too
|
||||||
if cc.has_header('libxlutil.h')
|
if cc.check_header('libxlutil.h')
|
||||||
conf.set('WITH_LIBXLUTIL_H', 1)
|
conf.set('WITH_LIBXLUTIL_H', 1)
|
||||||
endif
|
endif
|
||||||
xl_util_dep = dependency('xlutil')
|
xl_util_dep = dependency('xlutil')
|
||||||
@ -1755,7 +1755,7 @@ if conf.has('WITH_LIBVIRTD')
|
|||||||
fs_enable = false
|
fs_enable = false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if fs_enable and not cc.has_header('mntent.h')
|
if fs_enable and not cc.check_header('mntent.h')
|
||||||
if get_option('storage_fs').enabled()
|
if get_option('storage_fs').enabled()
|
||||||
error('<mntent.h> is required for the FS storage driver')
|
error('<mntent.h> is required for the FS storage driver')
|
||||||
else
|
else
|
||||||
@ -1962,7 +1962,7 @@ if not get_option('nss').disabled()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if use_nss and not cc.has_header('nss.h')
|
if use_nss and not cc.check_header('nss.h')
|
||||||
if get_option('nss').enabled()
|
if get_option('nss').enabled()
|
||||||
error('Can\'t build nss plugin without nss.h')
|
error('Can\'t build nss plugin without nss.h')
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user