Subject: [bug#65486] [PATCH] syscalls: Add support for musl libc

From: Ludovic Courtès <[email-masked]>
Date: Wed, 13 Sep 2023 22:39:50 +0200

Hi,

Sören Tempel <[email-masked]> skribis:

> Ludovic Courtès <[email-masked]> 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’.