GNU bug report logs -
#65486
[PATCH] syscalls: Add support for musl libc
Previous Next
Reported by: soeren <at> soeren-tempel.net
Date: Thu, 24 Aug 2023 06:35:01 UTC
Severity: normal
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 17 Sep 2023 12:14:05 +0200
with message-id <87o7i1yumq.fsf <at> gnu.org>
and subject line Re: bug#65486: [PATCH] syscalls: Add support for musl libc
has caused the debbugs.gnu.org bug report #65486,
regarding [PATCH] syscalls: Add support for musl libc
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
65486: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65486
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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. 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 <at> 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))
[Message part 3 (message/rfc822, inline)]
Hi,
Sören Tempel <soeren <at> soeren-tempel.net> skribis:
> From b1d478defc7f3e794974be2b9665cd4a58030569 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git <at> soeren-tempel.net>
> Date: Thu, 14 Sep 2023 12:35:38 +0000
> Subject: [PATCH] syscalls: Add support for musl libc
>
> 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.
This version LGTM. Applied, thanks!
Ludo’.
This bug report was last modified 1 year and 270 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.