[libvirt PATCH v2 1/1] meson: Check header usability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 meson.build | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index d35d5e076b..9a18767fbb 100644
--- a/meson.build
+++ b/meson.build
@@ -636,14 +636,14 @@ if host_machine.system() == 'freebsd'
 endif
 
 foreach name : headers
-  if cc.has_header(name)
+  if cc.check_header(name)
     conf.set('WITH_@0@'.format(name.underscorify().to_upper()), 1)
   endif
 endforeach
 
 # check for kernel header required by src/util/virnetdevbridge.c
 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')
   endif
 endif
@@ -920,7 +920,7 @@ endif
 dlopen_use = host_machine.system() != 'windows'
 dlopen_dep = cc.find_library('dl', required: dlopen_use)
 if dlopen_dep.found()
-  if not cc.has_header('dlfcn.h')
+  if not cc.check_header('dlfcn.h')
     error('Unable to find dlfcn.h')
   endif
   conf.set('WITH_DLFCN_H', 1)
@@ -1052,7 +1052,7 @@ if not get_option('nls').disabled()
     error('gettext() is required to build libvirt')
   endif
 
-  if cc.has_header('libintl.h')
+  if cc.check_header('libintl.h')
     conf.set('WITH_LIBINTL_H', 1)
   elif get_option('nls').enabled()
     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
   # 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)
   endif
 endif
@@ -1470,7 +1470,7 @@ if not get_option('driver_libxl').disabled() and conf.has('WITH_LIBVIRTD')
     endif
 
     # 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)
     endif
     xl_util_dep = dependency('xlutil')
@@ -1755,7 +1755,7 @@ if conf.has('WITH_LIBVIRTD')
       fs_enable = false
     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()
         error('<mntent.h> is required for the FS storage driver')
       else
@@ -1962,7 +1962,7 @@ if not get_option('nss').disabled()
     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()
       error('Can\'t build nss plugin without nss.h')
     else
-- 
2.40.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux