unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#65486] [PATCH] syscalls: Add support for musl libc
@ 2023-08-24  6:33 soeren
  2023-09-09 13:04 ` [bug#65486] [PATCH v2] " soeren
  0 siblings, 1 reply; 14+ messages in thread
From: soeren @ 2023-08-24  6:33 UTC (permalink / raw)
  To: 65486

From: Sören Tempel <soeren@soeren-tempel.net>

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 <soeren@soeren-tempel.net>
---
 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 <file-system>
 (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))




^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-10-23 10:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24  6:33 [bug#65486] [PATCH] syscalls: Add support for musl libc soeren
2023-09-09 13:04 ` [bug#65486] [PATCH v2] " soeren
2023-09-11 21:09   ` [bug#65486] [PATCH] " Ludovic Courtès
2023-09-13 10:23     ` Sören Tempel
2023-09-13 20:39       ` Ludovic Courtès
2023-09-15 10:57         ` Sören Tempel
2023-09-17 10:14           ` bug#65486: " Ludovic Courtès
2023-09-17 10:17           ` [bug#65486] " Ludovic Courtès
2023-09-17 11:38             ` Christopher Baines
2023-09-17 15:21             ` [bug#65486] [PATCH v3] syscalls: Consistently use existing linux? definition soeren
2023-09-17 15:21               ` [bug#65486] [PATCH v3] syscalls: Add support for musl libc soeren
2023-09-30 10:16             ` [bug#65486] [PATCH] " Sören Tempel
2023-10-10 17:15               ` Christopher Baines
2023-10-23 10:11             ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).