* [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
* [bug#65486] [PATCH v2] syscalls: Add support for musl libc
2023-08-24 6:33 [bug#65486] [PATCH] syscalls: Add support for musl libc soeren
@ 2023-09-09 13:04 ` soeren
2023-09-11 21:09 ` [bug#65486] [PATCH] " Ludovic Courtès
0 siblings, 1 reply; 14+ messages in thread
From: soeren @ 2023-09-09 13:04 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 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. For this reason, a case-distinction was added.
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.
* guix/build/syscalls.scm (statfs): Support musl libc.
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
---
Changes since v1: Also add special handling for musl libc to the statfs
procedure. Instead of checking the %host-type, it may also be possible to
the lack of statfs64/readdir64 symbols during ./configure time.
guix/build/syscalls.scm | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index d947b010d3..416fdc768c 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)
@@ -905,7 +907,11 @@ (define-c-struct %statfs ;<bits/statfs.h>
(spare (array fsword 4)))
(define statfs
- (let ((proc (syscall->procedure int "statfs64" '(* *))))
+ (let ((proc (syscall->procedure int (cond
+ (linux-gnu? "statfs64")
+ (linux-musl? "statfs")
+ (else (error "unknown linux variant")))
+ '(* *))))
(lambda (file)
"Return a <file-system> data structure describing the file system
mounted at FILE."
@@ -1232,7 +1238,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
* [bug#65486] [PATCH] syscalls: Add support for musl libc
2023-09-09 13:04 ` [bug#65486] [PATCH v2] " soeren
@ 2023-09-11 21:09 ` Ludovic Courtès
2023-09-13 10:23 ` Sören Tempel
0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2023-09-11 21:09 UTC (permalink / raw)
To: soeren; +Cc: 65486
Hi,
soeren@soeren-tempel.net skribis:
> 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 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. For this reason, a case-distinction was added.
>
> 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.
[...]
> -(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)
> @@ -905,7 +907,11 @@ (define-c-struct %statfs ;<bits/statfs.h>
> (spare (array fsword 4)))
>
> (define statfs
> - (let ((proc (syscall->procedure int "statfs64" '(* *))))
> + (let ((proc (syscall->procedure int (cond
> + (linux-gnu? "statfs64")
> + (linux-musl? "statfs")
> + (else (error "unknown linux variant")))
I think this is misleading because this has to do with the C library,
not with the kernel (“linux variant”).
For example, GNU/Hurd uses the same C library as GNU/Linux, and both
should use “statfs64”, “readdir64”, etc. So what we want to check is
whether we’re using the GNU libc or Musl, regardless of the kernel.
Now, instead of checking the libc’s identity, we could check whether
“statfs64” is available, and if not, fall back to “statfs”.
WDYT?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
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
0 siblings, 1 reply; 14+ messages in thread
From: Sören Tempel @ 2023-09-13 10:23 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 65486
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> wrote:
> I think this is misleading because this has to do with the C library,
> not with the kernel (“linux variant”).
>
> For example, GNU/Hurd uses the same C library as GNU/Linux, and both
> should use “statfs64”, “readdir64”, etc.
Oh, right! I totally forgot about GNU/Hurd, thanks for pointing that out.
> So what we want to check is whether we’re using the GNU libc or Musl,
> regardless of the kernel.
Keep in mind that—contrary to glibc—musl only supports Linux and not
GNU/Hurd. Therefore, it should be sufficient to simply check for a
linux-musl host and then use statfs/readdir over statfs64/readdir64:
(let ((proc (syscall->procedure (if linux-musl?
"readdir"
"readdir64"))))
........
Would that be acceptable?
> Now, instead of checking the libc’s identity, we could check whether
> “statfs64” is available, and if not, fall back to “statfs”.
You mean using a GNU ./configure check? That would be possible. However,
I think we also need to check somehow that readdir/statfs return values
are struct-layout compatible with the readdir64/statfs64 versions used
by glibc.
Unfortunately, I am not deeply familiar with GNU autotools. Is there a
similar feature-check in the Guile code base already that I could use as
a source of inspiration? Maybe the if expression outlined above would
be sufficient for now and we can improve upon that later?
Greetings,
Sören
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
2023-09-13 10:23 ` Sören Tempel
@ 2023-09-13 20:39 ` Ludovic Courtès
2023-09-15 10:57 ` Sören Tempel
0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2023-09-13 20:39 UTC (permalink / raw)
To: Sören Tempel; +Cc: 65486
Hi,
Sören Tempel <tempel@uni-bremen.de> skribis:
> Ludovic Courtès <ludo@gnu.org> wrote:
[...]
>> So what we want to check is whether we’re using the GNU libc or Musl,
>> regardless of the kernel.
>
> Keep in mind that—contrary to glibc—musl only supports Linux and not
> GNU/Hurd. Therefore, it should be sufficient to simply check for a
> linux-musl host and then use statfs/readdir over statfs64/readdir64:
>
> (let ((proc (syscall->procedure (if linux-musl?
> "readdir"
> "readdir64"))))
> ........
>
> Would that be acceptable?
You could call it ‘musl?’ instead, to (hopefully) convey we’re
interested in the C library specifically.
>> Now, instead of checking the libc’s identity, we could check whether
>> “statfs64” is available, and if not, fall back to “statfs”.
>
> You mean using a GNU ./configure check?
No no, I meant something like:
(or (false-if-exception (dynamic-func "readdir64" (dynamic-link)))
(dynamic-func "readdir" (dynamic-link)))
Of course, it’s not as simple as this because we’d rather have it
integrated with ‘syscall->procedure’ (maybe by adding an
#:alternative-name argument for the Musl name?), but you get the idea.
HTH!
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
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
0 siblings, 2 replies; 14+ messages in thread
From: Sören Tempel @ 2023-09-15 10:57 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 65486
[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> wrote:
> You could call it ‘musl?’ instead, to (hopefully) convey we’re
> interested in the C library specifically.
I used musl-libc? instead to make it more clear that we are interested
in the C library for this case-distinction. This is implemented in the
attached git-format-patch(1). Would that be suitable for inclusion in
Guix?
> No no, I meant something like:
>
> (or (false-if-exception (dynamic-func "readdir64" (dynamic-link)))
> (dynamic-func "readdir" (dynamic-link)))
>
> Of course, it’s not as simple as this because we’d rather have it
> integrated with ‘syscall->procedure’ (maybe by adding an
> #:alternative-name argument for the Musl name?), but you get the idea.
Also this check doesn't ensure struct layout compatibility, e.g. if
readdir uses 32-bit types so not sure if this is necessarily better
than the musl libc check I proposed above.
Let me know what you think.
Greetings
Sören
[-- Attachment #2: 0002-syscalls-Add-support-for-musl-libc.patch --]
[-- Type: text/plain, Size: 2891 bytes --]
From b1d478defc7f3e794974be2b9665cd4a58030569 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@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.
---
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))
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#65486: [PATCH] syscalls: Add support for musl libc
2023-09-15 10:57 ` Sören Tempel
@ 2023-09-17 10:14 ` Ludovic Courtès
2023-09-17 10:17 ` [bug#65486] " Ludovic Courtès
1 sibling, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2023-09-17 10:14 UTC (permalink / raw)
To: Sören Tempel; +Cc: 65486-done
Hi,
Sören Tempel <soeren@soeren-tempel.net> skribis:
> From b1d478defc7f3e794974be2b9665cd4a58030569 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@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’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
2023-09-15 10:57 ` Sören Tempel
2023-09-17 10:14 ` bug#65486: " Ludovic Courtès
@ 2023-09-17 10:17 ` Ludovic Courtès
2023-09-17 11:38 ` Christopher Baines
` (3 more replies)
1 sibling, 4 replies; 14+ messages in thread
From: Ludovic Courtès @ 2023-09-17 10:17 UTC (permalink / raw)
To: Sören Tempel; +Cc: 65486, Christopher Baines
Oooh, now I remember why I ended up not applying the previous
syscalls.scm patch: OpenJDK and a bunch of other things depend on it, so
changing syscalls.scm entails lots of rebuilds. (Really, they shouldn’t
depend on it in the first place, IMO.)
So we need bordeaux.guix to build everything ahead of time.
To do that, can you resend both syscalls.scm patch (with ‘git
send-email’) here? Then we’ll check qa.guix to ensure it builds things.
Chris, how does that sound?
Ludo’.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
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
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Christopher Baines @ 2023-09-17 11:38 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 65486
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> So we need bordeaux.guix to build everything ahead of time.
>
> To do that, can you resend both syscalls.scm patch (with ‘git
> send-email’) here? Then we’ll check qa.guix to ensure it builds things.
>
> Chris, how does that sound?
This probably falls under the core team (although ./etc/teams.scm says
it doesn't fall under any team), so I'd suggest putting it on a branch.
That way, we can collect some other similar changes together before
merging.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH v3] syscalls: Consistently use existing linux? definition
2023-09-17 10:17 ` [bug#65486] " Ludovic Courtès
2023-09-17 11:38 ` Christopher Baines
@ 2023-09-17 15:21 ` 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-23 10:11 ` Ludovic Courtès
3 siblings, 1 reply; 14+ messages in thread
From: soeren @ 2023-09-17 15:21 UTC (permalink / raw)
To: 65486; +Cc: ludo
From: Sören Tempel <soeren@soeren-tempel.net>
Instead of duplicating this existing logic across the source file. This
will make it easier to add additional linux targets (e.g. linux-musl) in
the future.
* guix/build/syscalls.scm (readdir*): Use linux? constant.
* guix/build/syscalls.scm (write-socket-address!): Use linux? constant.
* guix/build/syscalls.scm (read-socket-address): Use linux? constant.
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
---
guix/build/syscalls.scm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index d947b010d3..c9c0bf594d 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -1244,7 +1244,7 @@ (define (readdir-procedure name-field-offset sizeof-dirent-header
(define readdir*
;; Decide at run time which one must be used.
- (if (string-contains %host-type "linux-gnu")
+ (if linux?
(readdir-procedure (c-struct-field-offset %struct-dirent-header/linux
name)
sizeof-dirent-header/linux
@@ -1664,7 +1664,7 @@ (define (write-socket-address!/hurd sockaddr bv index)
(error "unsupported socket address" sockaddr)))))
(define write-socket-address!
- (if (string-contains %host-type "linux-gnu")
+ (if linux?
write-socket-address!/linux
write-socket-address!/hurd))
@@ -1696,7 +1696,7 @@ (define* (read-socket-address/hurd bv #:optional (index 0))
(vector family)))))
(define read-socket-address
- (if (string-contains %host-type "linux-gnu")
+ (if linux?
read-socket-address/linux
read-socket-address/hurd))
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH v3] syscalls: Add support for musl libc
2023-09-17 15:21 ` [bug#65486] [PATCH v3] syscalls: Consistently use existing linux? definition soeren
@ 2023-09-17 15:21 ` soeren
0 siblings, 0 replies; 14+ messages in thread
From: soeren @ 2023-09-17 15:21 UTC (permalink / raw)
To: 65486; +Cc: ludo
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. 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@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))
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
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-30 10:16 ` Sören Tempel
2023-10-10 17:15 ` Christopher Baines
2023-10-23 10:11 ` Ludovic Courtès
3 siblings, 1 reply; 14+ messages in thread
From: Sören Tempel @ 2023-09-30 10:16 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 65486, Christopher Baines
Hi,
Ludovic Courtès <ludo@gnu.org> wrote:
> To do that, can you resend both syscalls.scm patch (with ‘git
> send-email’) here? Then we’ll check qa.guix to ensure it builds things.
Did I resend the patches correctly? I noticed that the QA status is
still unknown on issues.guix.gnu.org. Is it required to open a new
thread instead of replying to the existing one?
Greetings,
Sören
^ permalink raw reply [flat|nested] 14+ messages in thread
* [bug#65486] [PATCH] syscalls: Add support for musl libc
2023-09-17 10:17 ` [bug#65486] " Ludovic Courtès
` (2 preceding siblings ...)
2023-09-30 10:16 ` [bug#65486] [PATCH] " Sören Tempel
@ 2023-10-23 10:11 ` Ludovic Courtès
3 siblings, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2023-10-23 10:11 UTC (permalink / raw)
To: Sören Tempel; +Cc: 65486-done, Christopher Baines
Hello,
Ludovic Courtès <ludo@gnu.org> skribis:
> Oooh, now I remember why I ended up not applying the previous
> syscalls.scm patch: OpenJDK and a bunch of other things depend on it, so
> changing syscalls.scm entails lots of rebuilds. (Really, they shouldn’t
> depend on it in the first place, IMO.)
This is now fixed (see <https://issues.guix.gnu.org/66525>), and I’m
happy to report that your patches have finally been pushed!
Thanks,
Ludo’.
^ permalink raw reply [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).