[libvirt PATCH] meson: Check usability of linux/kvm.h

[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 header and consider it usable.
Later, when an attempt is made to actually use 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 its actual usability, as opposed to mere presence,
is enough to make things work correctly in all cases.

https://bugs.debian.org/1024504

Suggested-by: Helmut Grohne <helmut@xxxxxxxxxx>
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 meson.build | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index d35d5e076b..21a4bd5b37 100644
--- a/meson.build
+++ b/meson.build
@@ -614,7 +614,6 @@ headers = [
   'asm/hwcap.h',
   'ifaddrs.h',
   'libtasn1.h',
-  'linux/kvm.h',
   'mntent.h',
   'net/ethernet.h',
   'net/if.h',
@@ -635,12 +634,24 @@ if host_machine.system() == 'freebsd'
   headers += 'libutil.h'
 endif
 
+# headers for which we need to check actual usability. in most
+# cases, checking for presence is enough (and it's way faster)
+check_headers = [
+  'linux/kvm.h',
+]
+
 foreach name : headers
   if cc.has_header(name)
     conf.set('WITH_@0@'.format(name.underscorify().to_upper()), 1)
   endif
 endforeach
 
+foreach name : check_headers
+  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')
-- 
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