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
Message #14 received at 65486 <at> debbugs.gnu.org (full text, mbox):
Hi,
soeren <at> soeren-tempel.net skribis:
> 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 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’.
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.