From nobody Fri Apr 19 05:49:54 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=1683912048; cv=none; d=zohomail.com; s=zohoarc; b=WZyF2BDmbFgqFA33efK35FCbltciKer+dwHH6naaiFypRHHV4VQWSfs/aVmPOaFZu3rfnyF0LBgzK0/EySGSL0YWrfTBt4o+wYRAS/yB/hVa0qLyG8xeklCMF/ELjKxeRmu5lW9rKbfBnKjJrfETIDasXQZCt4k9wrapen7+d4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683912048; h=Content-Type: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=kJ9qCXeH7DO4VFQUlndDJn1bMS5NPO3x1Jo/ONG6hnA=; b=U3R7I56c+GJgVdcxjKxoJLLIMUdF3xxg37f4Ya9Z9dtU7+0zc4VqwIhy/kwVP5xPnbBY0fR+/WZLKGo2HJ8VlNGhykbeh6KIDYOiWRRAdYvhMdcFLTN3ieTVLiQloMnGuOIS2Y24eCZgFbyfYesLTcynMPc+WPiAd4DzWuryS5Y= 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 1683912048759453.39774883157804; Fri, 12 May 2023 10:20:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-80-mT1k_fUkMnyA6hIrCx6J3w-1; Fri, 12 May 2023 13:20:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12BE0857E0C; Fri, 12 May 2023 17:20:43 +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 5EDB840C6EC4; Fri, 12 May 2023 17:20:40 +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 11B6419451E4; Fri, 12 May 2023 17:20:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 30D2319451E3 for ; Fri, 12 May 2023 17:20:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0C40763F8A; Fri, 12 May 2023 17:20:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93FC863F8B for ; Fri, 12 May 2023 17:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683912047; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kJ9qCXeH7DO4VFQUlndDJn1bMS5NPO3x1Jo/ONG6hnA=; b=eUQB3cKKwUr+4Ugq2xYGdOUONwBXisDtf8vOm1u4qXZEmhxkgDks4zwp+0m/4OrDq+9dpY +PgUIVPipJub+1o0zf+f0mlDeuUPCq5ZpKqtr4U++3Wl3v0s1KWZ6g2ZQx1p5ASmdcrtuD QAqZZBc8Wff92wHaWD8hnF8RI/37yDE= X-MC-Unique: mT1k_fUkMnyA6hIrCx6J3w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virmockstathelpers: Adapt to musl-1.2.4 Date: Fri, 12 May 2023 19:20:35 +0200 Message-Id: <1a98a153083c8a93a02429cbf544c6aa71dd3006.1683912035.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.2 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: 1683912049296100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With musl-1.2.3: I get the following macros defined (from $builddir/meson-config.h): #define WITH_LSTAT 1 #define WITH_LSTAT64 1 #define WITH_LSTAT_DECL 1 #define WITH_STAT 1 #define WITH_STAT64 1 #define WITH_STAT_DECL 1 #define WITH___LXSTAT 1 #define WITH___LXSTAT64 1 #define WITH___XSTAT 1 #define WITH___XSTAT64 1 which in turn means the virmockstathelpers.c ends up defining: MOCK_STAT64 MOCK_LSTAT64 But with musl-1.2.4 everything changes and the set of defined macros gets simplified to: #define WITH_LSTAT 1 #define WITH_LSTAT_DECL 1 #define WITH_STAT 1 #define WITH_STAT_DECL 1 #define WITH___LXSTAT 1 #define WITH___XSTAT 1 which results in no MOCK_* macros defined in virmockstathelpers.c, i.e. no stat() mocking, nada. The reason for this simplification are thess musl commits [1][2] which removed all 64 bit aliases. And that's not what our logic for deciding what flavor of stat() to mock counted with. Nevertheless, we do build with Alpine Linux in our CI, so how come we don't see this problem there? Well, simply because Alpine Linux maintainers decided to revert the commits [3][4]. But on distributions that use vanilla musl, this problem can be seen easily. 1: https://git.musl-libc.org/cgit/musl/commit/?id=3D246f1c811448f37a44b41cd= 8df8d0ef9736d95f4 2: https://git.musl-libc.org/cgit/musl/commit/?id=3D25e6fee27f4a293728dd15b= 659170e7b9c7db9bc 3: https://git.alpinelinux.org/aports/commit/main/musl?id=3D6a5563fbb45b3d9= d60678d7bbf60dbb312a2d481 4: https://git.alpinelinux.org/aports/commit/main/musl?id=3Da089bd852f89836= 23fa85e0f5755a3e25bf53c72 Resolves: https://bugs.gentoo.org/906167 Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- tests/virmockstathelpers.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 5b1f3b08a7..a02ee04503 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -64,6 +64,10 @@ * building on Apple Silicon (aarch64) those functions are missing * from the header altogether and should not be mocked. * + * Starting from 1.2.4, the musl library dropped 64-bit aliases, i.e. ther= e's + * no stat64() only stat(). BTW: while musl implements __xstat(), it's nev= er + * declared. And even the implementation is but a direct call to stat(). + * * With all this in mind the list of functions we have to mock will depend * on several factors * @@ -82,7 +86,9 @@ #if !defined(__APPLE__) # if !defined(WITH___XSTAT_DECL) # if defined(WITH_STAT) -# if !defined(WITH___XSTAT) && !defined(WITH_STAT64) +# if (!defined(WITH___XSTAT) && !defined(WITH_STAT64)) || \ + (defined(WITH_STAT) && defined(WITH_STAT_DECL) && !defined(WITH_STAT64= ) && \ + !defined(WITH___XSTAT64)) /* glibc || musl */ # define MOCK_STAT # endif # endif @@ -99,7 +105,9 @@ # endif /* WITH___XSTAT_DECL */ # if !defined(WITH___LXSTAT_DECL) # if defined(WITH_LSTAT) -# if !defined(WITH___LXSTAT) && !defined(WITH_LSTAT64) +# if (!defined(WITH___LXSTAT) && !defined(WITH_LSTAT64)) || \ + (defined(WITH_LSTAT) && defined(WITH_LSTAT_DECL) && !defined(WITH_LSTA= T64) \ + && !defined(WITH___LXSTAT64)) /* glibc || musl */ # define MOCK_LSTAT # endif # endif --=20 2.39.3