all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: soeren@soeren-tempel.net
Cc: 65486@debbugs.gnu.org
Subject: [bug#65486] [PATCH] syscalls: Add support for musl libc
Date: Mon, 11 Sep 2023 23:09:30 +0200	[thread overview]
Message-ID: <87fs3kquwl.fsf_-_@gnu.org> (raw)
In-Reply-To: <20230909130548.31083-2-soeren@soeren-tempel.net> (soeren@soeren-tempel.net's message of "Sat, 9 Sep 2023 15:04:28 +0200")

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’.




  reply	other threads:[~2023-09-11 21:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Ludovic Courtès [this message]
2023-09-13 10:23     ` [bug#65486] [PATCH] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fs3kquwl.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=65486@debbugs.gnu.org \
    --cc=soeren@soeren-tempel.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.