[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
11/12: syscalls: Add support for musl libc.
From: |
guix-commits |
Subject: |
11/12: syscalls: Add support for musl libc. |
Date: |
Mon, 23 Oct 2023 05:58:51 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 54e6788267c0dac43ec9cb234c711eaa73a3d92b
Author: Sören Tempel <soeren@soeren-tempel.net>
AuthorDate: Sun Sep 17 17:21:49 2023 +0200
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.
(linux?): Truth value on any linux system.
(statfs, readdir-procedure): Support musl libc.
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Change-Id: Icc4101a062381240f977f4550344bde696513c52
---
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 d947b010d3..e02ed07cd4 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -836,7 +836,8 @@ fdatasync(2) on the underlying file descriptor."
(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 @@ fdatasync(2) on the underlying file descriptor."
(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 @@ system to PUT-OLD."
(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))
- branch master updated (25043e01b6 -> dae956e796), guix-commits, 2023/10/23
- 02/12: gnu: python-ipykernel: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 01/12: gnu: mutter: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 04/12: gnu: python-dbusmock: Rewrite phases as a gexp., guix-commits, 2023/10/23
- 05/12: gnu: python-dbusmock: Use ‘search-input-file’., guix-commits, 2023/10/23
- 08/12: build-system/ant: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 09/12: build-system/android-ndk: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 07/12: gnu: public-inbox: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 10/12: build-system/dub: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 11/12: syscalls: Add support for musl libc.,
guix-commits <=
- 12/12: syscalls: Consistently use existing linux? definition., guix-commits, 2023/10/23
- 03/12: gnu: python-dbusmock: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23
- 06/12: gnu: polkit: Remove dependency on (guix build syscalls)., guix-commits, 2023/10/23