From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 IN0HKOEZB2VOdgEA9RJhRA:P1 (envelope-from ) for ; Sun, 17 Sep 2023 17:23:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IN0HKOEZB2VOdgEA9RJhRA (envelope-from ) for ; Sun, 17 Sep 2023 17:23:13 +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 600B85BBAE for ; Sun, 17 Sep 2023 17:23:13 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=eRt7HdBo; 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=1694964193; a=rsa-sha256; cv=none; b=RYQDqlpSSnU0/ZLZnv7bRX5pAj5FdqLfFZKLCyx5Yo5wq38TwegIDHuyqfNgZwgwORjUS5 ngMgg7F8Vc7HRrdvmtDsanIySJhamQYO3ErMUpmEcpT+3ofCM/Ig1lnQvzI7T/PD9ZJX3Z L8sd0hdL0Cji/QiHMia4jeb6ISRCFW95RqEDxgOsGjDhz3qQQV4TzKB96b5wGI8KfmUvtW XAeMD2fvr368VBixt/ch9qJFNxu4uLdbCvxHIOk9D2rtJ1lDXOHQiqkg+W5RweyNaAjzeF ZHo0mrnpZrHtenP5ypO4sX0FCnZ+Fme+suee6kzqP7EpIrZuUZ2QbYn/Xi7g7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1694964193; 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: content-transfer-encoding:content-transfer-encoding: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=2UaVWHsW474xEj3vHEOdZ2g9LeAY20IlU/nvYihxEJY=; b=GWy7tpGe3e/ca+nqPW/BlTkSvMQMN6FOzR0nds1SF6RMeo07yznlmkGvbNo2qRfzs/Hq/r YTY/rbDyd6NXkI3rSHZ2V+MyT+ckdrVNfPq+K9uADQB3tE3svgLywFb/CEcFvtG3ZFyuEo z0/rv0iSlWnS6mi7QAj794TF57ybmMnlijV48hMoCpoxobOl08enY0CsWC4dJQme/wbdXz 2aq9bWvW1TFOOO1Gezv/dSmVlS39f1S9PqEBUcPPt4HsKeWJx2uGsULDfDA6tDBeyVG8kx H1GLN78VuINAiaxICy9ETbb0yLtLizw3SxeouvDBAnFI01JlmwZRmIn4gnDBOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=eRt7HdBo; 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 1qhtbw-0006FL-9T; Sun, 17 Sep 2023 11:23: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 1qhtbs-0006Ed-QB for guix-patches@gnu.org; Sun, 17 Sep 2023 11:22: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 1qhtbs-0003ps-Hp for guix-patches@gnu.org; Sun, 17 Sep 2023 11:22:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qhtc0-0000h8-67 for guix-patches@gnu.org; Sun, 17 Sep 2023 11:23:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65486] [PATCH v3] syscalls: Add support for musl libc Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 17 Sep 2023 15:23:04 +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: To: 65486@debbugs.gnu.org Cc: ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Cc: 65486@debbugs.gnu.org, ludo@gnu.org Received: via spool by 65486-submit@debbugs.gnu.org id=B65486.16949641422554 (code B ref 65486); Sun, 17 Sep 2023 15:23:04 +0000 Received: (at 65486) by debbugs.gnu.org; 17 Sep 2023 15:22:22 +0000 Received: from localhost ([127.0.0.1]:51173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qhtbK-0000f7-FC for submit@debbugs.gnu.org; Sun, 17 Sep 2023 11:22:22 -0400 Received: from magnesium.8pit.net ([45.76.88.171]:22415) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qhtbD-0000eA-P5; Sun, 17 Sep 2023 11:22:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=fp6dfzRq/g DQwuotX9I6Gg0Qbx07ZXvPoJC7op9GSNY=; h=references:in-reply-to:date: subject:cc:to:from; d=soeren-tempel.net; b=eRt7HdBoTKhChsmVgUrkYG2FLCx fo5r0JrT79aSqzMf5a9StKHP27qENvNcmOpy+CM+A4ZE5784/vx/soNhWKOmboDlMsHTsq Y/61IGX2Odk+LEu5bOTzFlTj1N2zYZY6/sj7fx3p0L3sdX+dsR01iIE1GmnwRsDGWxfc/K /Nog= Received: from localhost (ip-078-094-021-002.um19.pools.vodafone-ip.de [78.94.21.2]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 64276c78 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sun, 17 Sep 2023 17:21:56 +0200 (CEST) From: soeren@soeren-tempel.net Date: Sun, 17 Sep 2023 17:21:49 +0200 Message-ID: <20230917152149.8587-2-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917152149.8587-1-soeren@soeren-tempel.net> References: <87il89yugy.fsf@gnu.org> <20230917152149.8587-1-soeren@soeren-tempel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: -2.60 X-Spam-Score: -2.60 X-Migadu-Queue-Id: 600B85BBAE X-Migadu-Scanner: mx2.migadu.com X-TUID: 7nuPXaTblEDe From: Sören Tempel 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. * guix/build/syscalls.scm (linux?): Truth value on any linux system. * guix/build/syscalls.scm (readdir-procedure): Support musl libc. * guix/build/syscalls.scm (statfs): Support musl libc. Signed-off-by: Sören Tempel --- 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 c9c0bf594d..b845b8aab9 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -836,7 +836,8 @@ (define-record-type (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 @@ (define-c-struct %statfs ; (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 data structure describing the file system mounted at FILE." @@ -1232,7 +1233,7 @@ (define closedir* (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))