From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ACrbBIlu/GTpfgEAG6o9tA:P1 (envelope-from ) for ; Sat, 09 Sep 2023 15:09:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id ACrbBIlu/GTpfgEAG6o9tA (envelope-from ) for ; Sat, 09 Sep 2023 15:09:29 +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 A8EE9674EE for ; Sat, 9 Sep 2023 15:09:28 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=fWPryGHm; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1694264969; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=vmpN9BAcw/KPJofohbfl7OqakCYta6B7z+R2Zpwg76M=; b=nDF5eaLZaYQClcI0GiO4NElwEkFp2/kkTL0zeW85M9ONgfXGB2unBP1vGoXbdaoJSo/Slb 5CYbktZyx6NqkfpxTddKvjDITY4ExDduZlc2NLT+yETRFdpI8nWd7o+Tkp/vdGbrtiFCR8 S+b+N1oJR+Jjtht3UZVbdETsserppCqOly4ZzoLWWZ64WcTe6VZZY/oxVZqLPeK+AYuXlB G2KBsq+u6DQ5RNmezHjN4v1whAXMk3TZQCuRGar34L1vNpRrNkCmVkaK5/OsxseXLV71YQ kgqUX0mpxVJitBOdPdUoOJ0NVv/HmcR0MypeU4kvT/MT5NaSqH9lFxSplAYTkg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=fWPryGHm; 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=1694264969; a=rsa-sha256; cv=none; b=b+n5Beg9he11aZpdBeWYRk60g95tvJd+Q0OuRVDWdiicS8p1ll5XYijNfxlX/Bw2AlqaPv C6IQ28rYHMo6I6GU1zdZtJIfD2NakOfKIdUtlobfJ1l22CMDiftjMisHlPqNtucGoOKAGG CcGkn8f0yXQWNLABIvzGO7nLdbX9U6MK3iBX2tz951ZImCC7orD5RRljyDupPwCytQXToB 7OouZ1foVVSoU5/XqWF2LNXJGt+Gv2jnsB3+zD4zs1AonMix4DPoFS/VQ+gMhXvpYYRBrB GNqSTOJ72vQdup0KsSh0Pakx0zRN4yuja2eDLRkIVbgDteJMnB7IKdDGijuoVg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qexfz-0007wH-Cy; Sat, 09 Sep 2023 09:07:03 -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 1qexfw-0007on-UB for guix-patches@gnu.org; Sat, 09 Sep 2023 09:07:00 -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 1qexfv-0003iS-Bu for guix-patches@gnu.org; Sat, 09 Sep 2023 09:07:00 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qexfy-0001Kq-5m for guix-patches@gnu.org; Sat, 09 Sep 2023 09:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65486] [PATCH v2] syscalls: Add support for musl libc Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 09 Sep 2023 13:07: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: 65486@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Cc: 65486@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16942647995101 (code B ref -1); Sat, 09 Sep 2023 13:07:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Sep 2023 13:06:39 +0000 Received: from localhost ([127.0.0.1]:46396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qexfb-0001KD-Bs for submit@debbugs.gnu.org; Sat, 09 Sep 2023 09:06:39 -0400 Received: from lists.gnu.org ([2001:470:142::17]:43740) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qexfY-0001K0-Vn for submit@debbugs.gnu.org; Sat, 09 Sep 2023 09:06:38 -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 1qexfQ-0006pj-AM for guix-patches@gnu.org; Sat, 09 Sep 2023 09:06:28 -0400 Received: from magnesium.8pit.net ([45.76.88.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qexfN-0003eZ-GE; Sat, 09 Sep 2023 09:06:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=d2mUpqragy YMXxnQCP3XHrMMgnVvknHJQhys+K4welY=; h=references:in-reply-to:date: subject:cc:to:from; d=soeren-tempel.net; b=fWPryGHmjCSihhCG9Tut5+S/Y4y XvsdbU7ryO8zmkf1oEwRQnwP4hDC0OYKgCJZms07jahgcnQ36+yVr8pVeRT0NperkVH+eh JPaJEweSDaK2deX5u/yaga73ArqDHFh4rCBWjip6oLrz+6SMoCwa7qbUGOwHKBacMZHCcd iwwQ= Received: from localhost (dynamic-2a02-3102-49da-001b-a1f5-aaf2-6701-ddb5.310.pool.telefonica.de [2a02:3102:49da:1b:a1f5:aaf2:6701:ddb5]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 6d6ccb73 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sat, 9 Sep 2023 15:06:20 +0200 (CEST) From: soeren@soeren-tempel.net Date: Sat, 9 Sep 2023 15:04:28 +0200 Message-ID: <20230909130548.31083-2-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230824063303.7928-3-soeren@soeren-tempel.net> References: <20230824063303.7928-3-soeren@soeren-tempel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=45.76.88.171; envelope-from=soeren@soeren-tempel.net; helo=magnesium.8pit.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-Queue-Id: A8EE9674EE X-Migadu-Spam: Yes X-Spam: Yes X-Migadu-Scanner: mx1.migadu.com X-Migadu-Spam-Score: 8.27 X-Spam-Score: 8.27 X-TUID: xtNskkK+XkZt From: Sören Tempel 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. * guix/build/syscalls.scm (linux-gnu?): New variable. * guix/build/syscalls.scm (linux-musl?): New variable. * guix/build/syscalls.scm (linux?): Truth value on musl or GNU Linux. * guix/build/syscalls.scm (readdir-procedure): Support musl libc. * guix/build/syscalls.scm (statfs): Support musl libc. Signed-off-by: Sören Tempel --- Changes since v1: Also add special handling for musl libc to the statfs procedure. Instead of checking the %host-type, it may also be possible to the lack of statfs64/readdir64 symbols during ./configure time. guix/build/syscalls.scm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index d947b010d3..416fdc768c 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -836,7 +836,9 @@ (define-record-type (define-syntax fsword ;fsword_t (identifier-syntax long)) -(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 ; (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"))) + '(* *)))) (lambda (file) "Return a data structure describing the file system mounted at FILE." @@ -1232,7 +1238,12 @@ (define closedir* (define (readdir-procedure name-field-offset sizeof-dirent-header read-dirent-header) - (let ((proc (syscall->procedure '* "readdir64" '(*)))) + (let ((proc (syscall->procedure '* + (cond + (linux-gnu? "readdir64") + (linux-musl? "readdir") + (else (error "unknown linux variant"))) + '(*)))) (lambda* (directory #:optional (pointer->string pointer->string/utf-8)) (let ((ptr (proc directory))) (and (not (null-pointer? ptr))