Received: (at submit) by debbugs.gnu.org; 17 Sep 2023 15:22:24 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 17 11:22:24 2023 Received: from localhost ([127.0.0.1]:51179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qhtbL-0000fO-SW for submit <at> debbugs.gnu.org; Sun, 17 Sep 2023 11:22:24 -0400 Received: from lists.gnu.org ([2001:470:142::17]:38074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <soeren@HIDDEN>) id 1qhtbJ-0000eR-6z for submit <at> debbugs.gnu.org; Sun, 17 Sep 2023 11:22:21 -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 <soeren@HIDDEN>) id 1qhtb5-00061R-11 for guix-patches@HIDDEN; Sun, 17 Sep 2023 11:22:07 -0400 Received: from magnesium.8pit.net ([2001:19f0:6c01:4ae:5400:ff:fe66:af9d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <soeren@HIDDEN>) id 1qhtb2-0003ea-Oc; Sun, 17 Sep 2023 11:22:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=fp6dfzRq/g DQwuotX9I6Gg0Qbx07ZXvPoJC7op9GSNY=; h=references:in-reply-to:date: subject:cc:to:from; d=soeren-tempel.net; b=eRt7HdBoTKhChsmVgUrkYG2FLCx fo5r0JrT79aSqzMf5a9StKHP27qENvNcmOpy+CM+A4ZE5784/vx/soNhWKOmboDlMsHTsq Y/61IGX2Odk+LEu5bOTzFlTj1N2zYZY6/sj7fx3p0L3sdX+dsR01iIE1GmnwRsDGWxfc/K /Nog= Received: from localhost (ip-078-094-021-002.um19.pools.vodafone-ip.de [78.94.21.2]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 64276c78 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sun, 17 Sep 2023 17:21:56 +0200 (CEST) From: soeren@HIDDEN To: guix-patches@HIDDEN Subject: [PATCH v3] syscalls: Add support for musl libc Date: Sun, 17 Sep 2023 17:21:49 +0200 Message-ID: <20230917152149.8587-2-soeren@HIDDEN> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917152149.8587-1-soeren@HIDDEN> References: <87il89yugy.fsf@HIDDEN> <20230917152149.8587-1-soeren@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:19f0:6c01:4ae:5400:ff:fe66:af9d; envelope-from=soeren@HIDDEN; 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-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: 65486 <at> debbugs.gnu.org, ludo@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) From: Sören Tempel <soeren@HIDDEN> This commit allows using Guix on a foreign distro which uses musl libc, for example, Alpine Linux. Usage of musl libc is detected via a new musl-libc? variable using the Guile %host-type. Using the new musl-libc? variable, we can now implement musl-specific quirks. The two compatibility problems I encountered in this regard are that musl dose not export a readdir64 and statfs64 symbol. On musl, these two functions are implemented as CPP macros that expand to readdir/statfs. To workaround that, a case-distinction was added. The existing linux? variable has been modified to return true if the %host-system contains "linux-" in order to ensure it is true for both linux-gnu as well as linux-musl host 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 (musl-libc?): New variable. * guix/build/syscalls.scm (linux?): Truth value on any linux system. * guix/build/syscalls.scm (readdir-procedure): Support musl libc. * guix/build/syscalls.scm (statfs): Support musl libc. Signed-off-by: Sören Tempel <soeren@HIDDEN> --- guix/build/syscalls.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index c9c0bf594d..b845b8aab9 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -836,7 +836,8 @@ (define-record-type <file-system> (define-syntax fsword ;fsword_t (identifier-syntax long)) -(define linux? (string-contains %host-type "linux-gnu")) +(define musl-libc? (string-contains %host-type "linux-musl")) +(define linux? (string-contains %host-type "linux-")) (define-syntax define-statfs-flags (syntax-rules (linux hurd) @@ -905,7 +906,7 @@ (define-c-struct %statfs ;<bits/statfs.h> (spare (array fsword 4))) (define statfs - (let ((proc (syscall->procedure int "statfs64" '(* *)))) + (let ((proc (syscall->procedure int (if musl-libc? "statfs" "statfs64") '(* *)))) (lambda (file) "Return a <file-system> data structure describing the file system mounted at FILE." @@ -1232,7 +1233,7 @@ (define closedir* (define (readdir-procedure name-field-offset sizeof-dirent-header read-dirent-header) - (let ((proc (syscall->procedure '* "readdir64" '(*)))) + (let ((proc (syscall->procedure '* (if musl-libc? "readdir" "readdir64") '(*)))) (lambda* (directory #:optional (pointer->string pointer->string/utf-8)) (let ((ptr (proc directory))) (and (not (null-pointer? ptr))
soeren@HIDDEN
:guix-patches@HIDDEN
.
Full text available.guix-patches@HIDDEN
:bug#66055
; Package guix-patches
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.