GNU bug report logs - #66055
[PATCH v3] syscalls: Add support for musl libc

Previous Next

Package: guix-patches;

Reported by: soeren <at> soeren-tempel.net

Date: Sun, 17 Sep 2023 15:23:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66055 in the body.
You can then email your comments to 66055 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#66055; Package guix-patches. (Sun, 17 Sep 2023 15:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to soeren <at> soeren-tempel.net:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 17 Sep 2023 15:23:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: soeren <at> soeren-tempel.net
To: guix-patches <at> gnu.org
Cc: 65486 <at> debbugs.gnu.org, ludo <at> gnu.org
Subject: [PATCH v3] syscalls: Add support for musl libc
Date: Sun, 17 Sep 2023 17:21:49 +0200
From: Sören Tempel <soeren <at> soeren-tempel.net>

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 <at> soeren-tempel.net>
---
 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))




Added blocking bug(s) 66525 Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 13 Oct 2023 15:54:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 66055 <at> debbugs.gnu.org and soeren <at> soeren-tempel.net Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 23 Oct 2023 10:13:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 20 Nov 2023 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 171 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.