From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id vyqvAiH65mRAlgAASxT56A (envelope-from ) for ; Thu, 24 Aug 2023 08:35:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id oDcXAiH65mQjCgEA9RJhRA (envelope-from ) for ; Thu, 24 Aug 2023 08:35:13 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9B2A941CAB for ; Thu, 24 Aug 2023 08:35:12 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=I8+UkETJ; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1692858912; 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:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=1v2c+JCax1hVP+zwyl4PxUSRNrUVV18DEAHwuzcYaKo=; b=OVYCzWuepszp4jf7z5BfshO+SLKumTDkkdWFQHaFnGOpe9bU02dF198EHlFk5iQ6yRoIsa SM65gblnWzzCYdeSkbABvPLMGQQ+IJO9gJZJlkmpANsIBynb3p9GZ2vbH8lXja9ALHTptj ANwJZ6og6n4GEnhc/6aivTC21WTcq9PdcgLTaYd2a0TwKd2cRSN2UdhpJUijDVqRbK4vtT 9wE3hIcPcXAqPA7wQ7YhDtCytRsTAFY/LZEaHpvh805yj/gynMYnuA0GKuLJt2nhmkjzXz wFzQoavh0OdGsPTvZikrk2Dv2RUeii+Aol+rV/072URrw4jluU283412oGYKvw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692858912; a=rsa-sha256; cv=none; b=LBMDHbs5PibHNg4lt0c8b/l1VbkaD75NnhVIDj3qkfm0gHHqCdOlvE252f2dz6VYMFuqVN JwPeuNC8/buY72oipgBuUj8Ps4RI16+AxIihCeoGDmMQOeyD6EV7nF24OkpSe2eCruCPUV 94vXr58c4S1xR4S2fS+1vvTnjJoPcEgBlApxGpjyv+l+45noApfNBrx6SAC2sHV46W+/vV K/I3zsBuFVk5cD41s6IlxEjbYHgpW1pwUaS9LJ7N4CQo1uzuyXiZ0k3656beAC5GEbw+/b ZcCIey0gL+5T8DZrjo6snXfQvzUoSkBPT7k/r5HlpVyYub3ga4om9nA3GxtlRA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=I8+UkETJ; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ3vo-0000bT-9Y; Thu, 24 Aug 2023 02:35:00 -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 1qZ3vn-0000bK-0F for guix-patches@gnu.org; Thu, 24 Aug 2023 02:34:59 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZ3vm-0000Lx-OD for guix-patches@gnu.org; Thu, 24 Aug 2023 02:34:58 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZ3vq-00007w-2R for guix-patches@gnu.org; Thu, 24 Aug 2023 02:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65486] [PATCH] syscalls: Add support for musl libc Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 24 Aug 2023 06:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65486 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65486@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1692858856407 (code B ref -1); Thu, 24 Aug 2023 06:35:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Aug 2023 06:34:16 +0000 Received: from localhost ([127.0.0.1]:35980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ3v5-00006S-Qo for submit@debbugs.gnu.org; Thu, 24 Aug 2023 02:34:16 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ3uz-000068-VT for submit@debbugs.gnu.org; Thu, 24 Aug 2023 02:34:14 -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 1qZ3up-00072J-Gx for guix-patches@gnu.org; Thu, 24 Aug 2023 02:33:59 -0400 Received: from magnesium.8pit.net ([45.76.88.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZ3ul-0000Hn-ID; Thu, 24 Aug 2023 02:33:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=FTSMDA9n59 JCXXL4KvmHbSYBo8rWI/zoBNPQP45qVks=; h=date:subject:to:from; d=soeren-tempel.net; b=I8+UkETJejDlXgdQC0VkHdwis1ediBFxBraGolzC8PXkviO cPP2z4eX0YK0arN4Uz4OprLh1GNC4bI4efHh+K0m0ioe5EDjiGjIfqWwV4ripvOfU2Mw1i Cnt9x4OQXx1Lmo0+BV6pIQCHy9NmexYZSUfjuUqa+bfVin+h6ThS5Y= Received: from localhost (dynamic-2a02-3102-49da-001b-8471-2294-2cf4-4d1a.310.pool.telefonica.de [2a02:3102:49da:1b:8471:2294:2cf4:4d1a]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 7b3c79d8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Thu, 24 Aug 2023 08:33:44 +0200 (CEST) From: soeren@soeren-tempel.net Date: Thu, 24 Aug 2023 08:33:05 +0200 Message-ID: <20230824063303.7928-3-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=45.76.88.171; envelope-from=soeren@soeren-tempel.net; helo=magnesium.8pit.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.11 X-Spam-Score: -4.11 X-Migadu-Queue-Id: 9B2A941CAB X-Migadu-Scanner: mx1.migadu.com X-TUID: gaA58HjAVKRs From: Sören Tempel This commit allows using Guix on a foreign distro which uses musl libc, for example, Alpine Linux. Such a distro is detected via the new linux-musl? variable based on the %host-type. Using the new linux-musl? variable, we can now implement musl-specific quirks. The only problem I encountered in this regard so far is that musl does not export a readdir64 symbol. On musl, readdir64 is a CPP macro that expands to readdir. For this reason, readdir-procedure now uses readdir over readdir64 if the host-system uses musl libc. The existing linux? variable is now set to a truth value if the host-system is either a linux-gnu or a linux-musl. A new linux-gnu? variable can be used to detect linux-gnu systems. The patch has been tested on Alpine Linux and is already used for the downstream Guix package shipped in Alpine Linux's package repository. * guix/build/syscalls.scm (linux-gnu?): New variable. * guix/build/syscalls.scm (linux-musl?): New variable. * guix/build/syscalls.scm (linux?): Truth value on musl or GNU Linux. * guix/build/syscalls.scm (readdir-procedure): Support musl libc. Signed-off-by: Sören Tempel --- guix/build/syscalls.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index d947b010d3..a690e8da0b 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -836,7 +836,9 @@ (define-record-type (define-syntax fsword ;fsword_t (identifier-syntax long)) -(define linux? (string-contains %host-type "linux-gnu")) +(define linux-gnu? (string-contains %host-type "linux-gnu")) +(define linux-musl? (string-contains %host-type "linux-musl")) +(define linux? (or linux-gnu? linux-musl?)) (define-syntax define-statfs-flags (syntax-rules (linux hurd) @@ -1232,7 +1234,12 @@ (define closedir* (define (readdir-procedure name-field-offset sizeof-dirent-header read-dirent-header) - (let ((proc (syscall->procedure '* "readdir64" '(*)))) + (let ((proc (syscall->procedure '* + (cond + (linux-gnu? "readdir64") + (linux-musl? "readdir") + (else (error "unknown linux variant"))) + '(*)))) (lambda* (directory #:optional (pointer->string pointer->string/utf-8)) (let ((ptr (proc directory))) (and (not (null-pointer? ptr))