From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id OErbGtQ4BGWdYQAAG6o9tA:P1 (envelope-from ) for ; Fri, 15 Sep 2023 12:58:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id OErbGtQ4BGWdYQAAG6o9tA (envelope-from ) for ; Fri, 15 Sep 2023 12:58:28 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1BA6451A47 for ; Fri, 15 Sep 2023 12:58:28 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b="qBcox/3j"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1694775508; a=rsa-sha256; cv=none; b=TQDD19SBBnpz1j2OviFM1HioXj+mSFUV5+uLNZIyMRVXQta8bFunAGRvd5etrPaMG56e76 xsnasFMbqx6oKd3ac0UFioJf9Qa8+Di4ATwrp8olY9/sF4KezXL+4SipITvEtOy2YBNqDM pzkrAILCXDkL0Xw+eW57D7ix5ojwvaFO0N3fY4SMoz97wbLauMvu99TTw8x5PNwcx4bhEp ijbbfdzoUuaATuFgk1ItX66XJNjwTK6HtET6fkFRc0wrXeFhxAHDyPT/U1KaRSTQdWD2ZO aVuWv+JtRKWLaa7qkpbk7McrF5+E5LICAb1QUhG8agdv3Dc2Zn40N2PmUN7HLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1694775508; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=TAB99xJ9dZ3gX7fIoI9gtl3obJCrj1XISxcGVZvPreo=; b=WoQD5nvFNs74mC3U8I9eSIu7i4AYhKH3PKLACBZBZkVOFPQ6fSMGUEilP/FiNptt5CO+g5 qNkDNFbw8i+MvBxYchLaIiAlSKBEZq0TWkHaxz+o+mzw92/dYciSTDIXh/Zz4kaoeyDY0i N68MG2/PEx60EVJrZlnQJU01INdIHBfYrQothAnleHJgXwGRtQ98hUymSBdi2OxVEmuJb5 GI1tJ1eN/RcwJqDn+HaxCbdkvAf4F+LReWdvpsSM/zgfs8jtu9IedOCN8T2fROaKtSTprT o1ZPa26JjZrnymxzXSuKaOlXdg+O2MZPUTRnXsiv63AM6YtK/agBpeA9jY24jA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b="qBcox/3j"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qh6WO-0004PB-1S; Fri, 15 Sep 2023 06:58:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qh6WK-0004O3-F6 for guix-patches@gnu.org; Fri, 15 Sep 2023 06:57:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qh6WK-0001d0-6J for guix-patches@gnu.org; Fri, 15 Sep 2023 06:57:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qh6WQ-0004Vi-Gd for guix-patches@gnu.org; Fri, 15 Sep 2023 06:58:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65486] [PATCH] syscalls: Add support for musl libc Resent-From: =?UTF-8?Q?S=C3=B6ren?= Tempel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 15 Sep 2023 10:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65486 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 65486@debbugs.gnu.org Received: via spool by 65486-submit@debbugs.gnu.org id=B65486.169477546717318 (code B ref 65486); Fri, 15 Sep 2023 10:58:02 +0000 Received: (at 65486) by debbugs.gnu.org; 15 Sep 2023 10:57:47 +0000 Received: from localhost ([127.0.0.1]:42241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh6WB-0004VF-7b for submit@debbugs.gnu.org; Fri, 15 Sep 2023 06:57:47 -0400 Received: from magnesium.8pit.net ([45.76.88.171]:24337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh6W8-0004V3-E9 for 65486@debbugs.gnu.org; Fri, 15 Sep 2023 06:57:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=/k1F3e2979 uofnMFoW8fNmXr0Fq1YFLseHixwvDlunA=; h=in-reply-to:references:from: subject:cc:to:date; d=soeren-tempel.net; b=qBcox/3jN621/2zGgMeEvjmTZM5 EG7VaahJhHNC56KPfcRh10OHsKY/x9xrJyh2i0cyToLhQ+fnqG49xb30dB2AegpvlKjYEE TzOQ2HwcoLtRdq2M4gys/bWFokOO/2TstdEm+p2u/IdPjeCOgOi/aXv1sBGWUAq8wyPFT/ r3dU= Received: from localhost (dynamic-002-247-251-213.2.247.pool.telefonica.de [2.247.251.213]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 139f614c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Fri, 15 Sep 2023 12:57:35 +0200 (CEST) Date: Fri, 15 Sep 2023 12:57:29 +0200 From: =?UTF-8?Q?S=C3=B6ren?= Tempel References: <20230824063303.7928-3-soeren@soeren-tempel.net> <20230909130548.31083-2-soeren@soeren-tempel.net> <87fs3kquwl.fsf_-_@gnu.org> <3DOVAMAK0VD13.2XDJ9MT35902D@8pit.net> <87cyylkdt5.fsf@gnu.org> In-Reply-To: <87cyylkdt5.fsf@gnu.org> Message-Id: <3V5VFSTNLLLHJ.3BBPH8V2N2EUI@8pit.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_58a1976d5c5e54cf7f90ab59_=_" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -5.11 X-Spam-Score: -5.11 X-Migadu-Queue-Id: 1BA6451A47 X-Migadu-Scanner: mx2.migadu.com X-TUID: o4CEen6YAxGO This is a multipart message in MIME format. ------_=_58a1976d5c5e54cf7f90ab59_=_ Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Ludovic, Ludovic Court=C3=A8s wrote: > You could call it =E2=80=98musl?=E2=80=99 instead, to (hopefully) convey = we=E2=80=99re > 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: >=20 > (or (false-if-exception (dynamic-func "readdir64" (dynamic-link))) > (dynamic-func "readdir" (dynamic-link))) >=20 > Of course, it=E2=80=99s not as simple as this because we=E2=80=99d rather= have it > integrated with =E2=80=98syscall->procedure=E2=80=99 (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=C3=B6ren ------_=_58a1976d5c5e54cf7f90ab59_=_ Content-Disposition: attachment; filename*0*=UTF-8''0002-syscalls-Add-support-for-musl-libc.patch Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =46rom b1d478defc7f3e794974be2b9665cd4a58030569 Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?S=3DC3=3DB6ren=3D20Tempel?=3D =44ate: Thu, 14 Sep 2023 12:35:38 +0000 =53ubject: [PATCH] syscalls: Add support for musl libc =0AThis commit allows using Guix on a foreign distro which uses musl libc, =66or example, Alpine Linux. Usage of musl libc is detected via a new =6Dusl-libc? variable using the Guile %host-type. =0AUsing the new musl-libc? variable, we can now implement musl-specific =71uirks. The two compatibility problems I encountered in this regard are =74hat musl dose not export a readdir64 and statfs64 symbol. On musl, =74hese two functions are implemented as CPP macros that expand to =72eaddir/statfs. To workaround that, a case-distinction was added. =0AThe existing linux? variable has been modified to return true if the =25host-system contains "linux-" in order to ensure it is true for both =6Cinux-gnu as well as linux-musl host systems. =0AThe patch has been tested on Alpine Linux and is already used for the =64ownstream Guix package shipped in Alpine Linux's package repository. =0A* guix/build/syscalls.scm (musl-libc?): New variable. =2A guix/build/syscalls.scm (linux?): Truth value on any linux system. =2A guix/build/syscalls.scm (readdir-procedure): Support musl libc. =2A guix/build/syscalls.scm (statfs): Support musl libc. =2D-- =20guix/build/syscalls.scm | 7 ++++--- =201 file changed, 4 insertions(+), 3 deletions(-) =0Adiff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm =69ndex c9c0bf594d..b845b8aab9 100644 =2D-- a/guix/build/syscalls.scm =2B++ b/guix/build/syscalls.scm =40@ -836,7 +836,8 @@ (define-record-type =20(define-syntax fsword ;fsword_t =20 (identifier-syntax long)) =20= =2D(define linux? (string-contains %host-type "linux-gnu")) =2B(define musl-libc? (string-contains %host-type "linux-musl")) =2B(define linux? (string-contains %host-type "linux-")) =20= =20(define-syntax define-statfs-flags =20 (syntax-rules (linux hurd) =40@ -905,7 +906,7 @@ (define-c-struct %statfs ; =20 (spare (array fsword 4))) =20= =20(define statfs =2D (let ((proc (syscall->procedure int "statfs64" '(* *)))) =2B (let ((proc (syscall->procedure int (if musl-libc? "statfs" "statfs64"= =29 '(* *)))) =20 (lambda (file) =20 "Return a data structure describing the file system =20mounted at FILE." =40@ -1232,7 +1233,7 @@ (define closedir* =20= =20(define (readdir-procedure name-field-offset sizeof-dirent-header =20 read-dirent-header) =2D (let ((proc (syscall->procedure '* "readdir64" '(*)))) =2B (let ((proc (syscall->procedure '* (if musl-libc? "readdir" "readdir64= =22) '(*)))) =20 (lambda* (directory #:optional (pointer->string pointer->string/utf-= =38)) =20 (let ((ptr (proc directory))) =20 (and (not (null-pointer? ptr)) ------_=_58a1976d5c5e54cf7f90ab59_=_--