From nobody Mon May 20 18:59:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685369596; cv=none; d=zohomail.com; s=zohoarc; b=mwXomnjXmAMHM5ECw9cOozq1F0ChsU0qh+W35IA5fqfxTw6/a1NIML2++du4Guv08a/zIxejap3ySEcdBT4PW/9RcvwX8yRR7RA6UIj0KcNI5VU0k0siJWIkOgaDsJ8Fr4ybyao4vaLe4+opIbr3IwaW0NTkoEudBWRbRuHAKL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685369596; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=0s8dZVcN+QaEMREYs2yDVB3nklRumXGYJlpyr0UixXY=; b=WA+mG0AUgJxzgeh7D8Co2Naqv5WcXyNNax2dLl+eGS0DHuwiELrtMSCaR22b8svcKzUW/9JXpjydePq66/m7Yz6FMBbJctiJzYMnL/GkJfKkCIe2EVqjV/fShEbxJ3Qxphodtb86s3lalXdRImDHMrtEWy0WuUO/QF+pXqSYlBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685369596572883.604071511136; Mon, 29 May 2023 07:13:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3dc2-0002Ct-L4; Mon, 29 May 2023 10:12:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3dbu-0002CW-Lk for qemu-devel@nongnu.org; Mon, 29 May 2023 10:12:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3dbs-0001md-8A for qemu-devel@nongnu.org; Mon, 29 May 2023 10:12:34 -0400 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-663--gV-zy_MMN2iPkEYp4Sy2Q-1; Mon, 29 May 2023 10:12:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1F253C0C880 for ; Mon, 29 May 2023 14:12:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C813C154D1 for ; Mon, 29 May 2023 14:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685369550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0s8dZVcN+QaEMREYs2yDVB3nklRumXGYJlpyr0UixXY=; b=ggOic34u/jPaUZtMN1WjcgLgUjL1fvI99txzdegZIskfhUDGRGoB5MLeM5iD3wupeBmCi2 fLe3lUNRh6eh0l50+d9RUYz22ruqN6bxiNZ4oyTEJmhhkY1xM1K2AQq82EdWsa6+ZPvQZS RBRpQ5osZdrebNQBZG6OrmG739ld3Ts= X-MC-Unique: -gV-zy_MMN2iPkEYp4Sy2Q-1 From: Michal Privoznik To: qemu-devel@nongnu.org Subject: [PATCH v2] meson: Avoid implicit declaration of functions Date: Mon, 29 May 2023 16:12:26 +0200 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mprivozn@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.16, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685369598163100003 Content-Type: text/plain; charset="utf-8" While detecting a presence of a function via 'cc.links()' gives desired result (i.e. detects whether function is present), it also produces a warning on systems where the function is not present (into meson-log.txt), e.g.: qemu.git/build/meson-private/tmph74x3p38/testfile.c:2:34: \ warning: implicit declaration of function 'malloc_trim' [-Wimplicit-funct= ion-declaration] We can check whether given function exists via 'cc.has_function()' or whether STATX_* macros exist via 'cc.has_header_symbol()'. Resolves: https://bugs.gentoo.org/898810 Signed-off-by: Michal Privoznik --- v2 of: https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg07138.html diff to v1: - Drop cc.links() as it's redundant meson.build | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index 2d48aa1e2e..21061b19d4 100644 --- a/meson.build +++ b/meson.build @@ -1797,8 +1797,7 @@ malloc =3D [] if get_option('malloc') =3D=3D 'system' has_malloc_trim =3D \ get_option('malloc_trim').allowed() and \ - cc.links('''#include - int main(void) { malloc_trim(0); return 0; }''') + cc.has_function('malloc_trim', prefix: '#include ') else has_malloc_trim =3D false malloc =3D cc.find_library(get_option('malloc'), required: true) @@ -1811,34 +1810,19 @@ if not has_malloc_trim and get_option('malloc_trim'= ).enabled() endif endif =20 -# Check whether the glibc provides statx() - gnu_source_prefix =3D ''' #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif ''' -statx_test =3D gnu_source_prefix + ''' - #include - int main(void) { - struct statx statxbuf; - statx(0, "", 0, STATX_BASIC_STATS, &statxbuf); - return 0; - }''' =20 -has_statx =3D cc.links(statx_test) +# Check whether the glibc provides STATX_BASIC_STATS + +has_statx =3D cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', pref= ix: gnu_source_prefix) =20 # Check whether statx() provides mount ID information =20 -statx_mnt_id_test =3D gnu_source_prefix + ''' - #include - int main(void) { - struct statx statxbuf; - statx(0, "", 0, STATX_BASIC_STATS | STATX_MNT_ID, &statxbuf); - return statxbuf.stx_mnt_id; - }''' - -has_statx_mnt_id =3D cc.links(statx_mnt_id_test) +has_statx_mnt_id =3D cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', pr= efix: gnu_source_prefix) =20 have_vhost_user_blk_server =3D get_option('vhost_user_blk_server') \ .require(targetos =3D=3D 'linux', --=20 2.39.3