From nobody Sun Sep 8 02:29:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682598146; cv=none; d=zohomail.com; s=zohoarc; b=OKErVLkZ657G6KGwPJ9cYCVhz2/tp0/uDKFbVza4Z303TZiU3u+Aq8fwV85JHH1G+1XwWz+gDMZMyMT9EJW1nfuMTh2wkdx51RXJPGynjNXYF39SVI8eQomum2UrGHIgwa1D0fwGoTpuEXyA7FitOIzba2N+7Q6lGVRp0AjF1vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682598146; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y3BrDf4hE9tnAwn6B5FK+GCBCsDBjN0LIcfzu1ro41E=; b=EQZFPAMzG3tLN/nFJnnGOxn9HDxzgVW+B2prcjHQtcjo9ehOye9q3AT6IySA09J5j5TQF8eIhYB05Eql6/xeotWxoflLDvy5Pzs6RFSCaRxokBqon0LsVZABLiqI1HQ4Gn7/IbiFdHfaau2RPfIcEXB5bMO0qWb90wd23G6Wp1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1682598146837159.198908398232; Thu, 27 Apr 2023 05:22:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-vr5nYPtyM8CcJQ1LKHs5_Q-1; Thu, 27 Apr 2023 08:22:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5E081C02D41; Thu, 27 Apr 2023 12:22:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDF572027043; Thu, 27 Apr 2023 12:22:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C968C1946A49; Thu, 27 Apr 2023 12:22:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E8CF41946A45 for ; Thu, 27 Apr 2023 12:22:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DC6F014152F6; Thu, 27 Apr 2023 12:22:19 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.225.151]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E615141511D for ; Thu, 27 Apr 2023 12:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682598145; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=y3BrDf4hE9tnAwn6B5FK+GCBCsDBjN0LIcfzu1ro41E=; b=ZKYGTglf+TJ11giAikG/orPbSrffJzYj3UXGSH2lppYHVyTVetoZhCJSzqQPrjjuzjKfmj DcZZehjFbUoPSh6mRQmSspHD5eO5dlw4qAE4L+oJ79qFVykyE9eRII5zAJoWuewUGoMA6r ubFtrxwrfuipucfgDxq+PQBPBnq5FpY= X-MC-Unique: vr5nYPtyM8CcJQ1LKHs5_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/1] meson: Check header usability Date: Thu, 27 Apr 2023 14:22:16 +0200 Message-Id: <20230427122216.76714-2-abologna@redhat.com> In-Reply-To: <20230427122216.76714-1-abologna@redhat.com> References: <20230427122216.76714-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682598147384100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- 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() =3D=3D 'freebsd' endif =20 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 =20 # check for kernel header required by src/util/virnetdevbridge.c if host_machine.system() =3D=3D '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 wit= h QEMU or LXC support') endif endif @@ -920,7 +920,7 @@ endif dlopen_use =3D host_machine.system() !=3D 'windows' dlopen_dep =3D 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 =20 - 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() =20 # Wireshark is installing ws_version.h since v2.9.0, but some distributi= ons # 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 =20 # 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 =3D dependency('xlutil') @@ -1755,7 +1755,7 @@ if conf.has('WITH_LIBVIRTD') fs_enable =3D false endif =20 - 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(' is required for the FS storage driver') else @@ -1962,7 +1962,7 @@ if not get_option('nss').disabled() endif endif =20 - 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 --=20 2.40.0