From patchwork Thu Apr 17 20:33:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Ziltener X-Patchwork-Id: 41747 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8A52427BC4B; Thu, 17 Apr 2025 21:42:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7FEE027BC49 for ; Thu, 17 Apr 2025 21:42:23 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u5W3m-00012C-Cd; Thu, 17 Apr 2025 16:42:10 -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 1u5W3j-00011p-OC for guix-patches@gnu.org; Thu, 17 Apr 2025 16:42:07 -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 1u5W3j-0005dU-Co for guix-patches@gnu.org; Thu, 17 Apr 2025 16:42:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=x8jarDFs22g99j5s31Cr1YokBXxESmhRd3+UAXnBQPw=; b=YUo81v172bh+J1VACNndW1ojnDNAXNqAhI0CVKfGLP0Fh1D7JyPRgTDZz2yv35zC1JTwjUeB5/+RwYBYUrGMSgqjjKgmJIYpzYtF8DnpMfjh8DpwTiMAM7diFu9j3PZ9sKk+UafeqBOBV+nwin5CUSKlB2CFs/RR0oUf4Rx3Kr8qhDgzqIMwhJ1ovy8KYRrTaZpjY+vQZQJ/zD7zhwkp0uW4r+cR+xjpAERmEGOGiUaT8kn6IaBhpctyJFymN5jqD+O8GCfyMFEa+R04MZSHwxE+lX0H6CeCtCQtoQBMmN/DMXT/BzAAKkmIJDQlDYbeIyaqg+n+C499aSBDIspIpQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u5W3j-0001qs-4s for guix-patches@gnu.org; Thu, 17 Apr 2025 16:42:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77877] [PATCH] build-system: fix and future-proof Chicken build system. Resent-From: Daniel Ziltener Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 17 Apr 2025 20:42:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 77877 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77877@debbugs.gnu.org Cc: Daniel Ziltener X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17449224926788 (code B ref -1); Thu, 17 Apr 2025 20:42:05 +0000 Received: (at submit) by debbugs.gnu.org; 17 Apr 2025 20:41:32 +0000 Received: from localhost ([127.0.0.1]:48634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u5W35-0001kn-Nd for submit@debbugs.gnu.org; Thu, 17 Apr 2025 16:41:31 -0400 Received: from lists.gnu.org ([2001:470:142::17]:39680) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u5W2z-0001iu-Ca for submit@debbugs.gnu.org; Thu, 17 Apr 2025 16:41:25 -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 1u5W2q-0000q8-1G for guix-patches@gnu.org; Thu, 17 Apr 2025 16:41:12 -0400 Received: from 195-15-242-23.dc3-a.pub1.etik-cloud.com ([195.15.242.23] helo=lyrion.ch) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u5W2n-0005On-Mj for guix-patches@gnu.org; Thu, 17 Apr 2025 16:41:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyrion.ch; s=20230702; t=1744922059; h=from:from: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; bh=x8jarDFs22g99j5s31Cr1YokBXxESmhRd3+UAXnBQPw=; b=Fmtwn1qCZjmHUhuGTgnHaHlatKyC9S6Gaps92GYfq6pFulYS3VlN+f/bVMc4vniflhsZt6 IvFjS79XxKW2/wYDNSByQF9PG6kx8XqkoCjoValkGGRIUiwu7met/1+eLIlx/vi97ZSyJ7 bKf/WTDkZhUaQIISMQh/rhVKhY4ocxXZzkC6jCwO/OtNvRJb5ezU/ZWJhRSqilWQXWVy28 8I4cHfSEPy8pSyT66O86WATxfnLR0tvIgEfM/zN8lGfh6T62UQB1WHkGGbYButG+WJerzD v8ks8TDrFpTztg6F+57pdgdvJo74Or9bbc5Klf1HB/a5uwAoc/FXW0u/dK9wBw== Received: from ziltis-machine.fritz.box (cf597899.dynamic.tele-ag.de [207.89.120.153]) by lyrion.ch (OpenSMTPD) with ESMTPSA id 642f9233 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 17 Apr 2025 20:34:19 +0000 (UTC) Date: Thu, 17 Apr 2025 22:33:50 +0200 Message-ID: <20250417203400.29123-1-dziltener@lyrion.ch> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Received-SPF: pass client-ip=195.15.242.23; envelope-from=dziltener@lyrion.ch; helo=lyrion.ch X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, RDNS_DYNAMIC=0.982, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, TVD_RCVD_IP=0.001 autolearn=no 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: , Reply-to: Daniel Ziltener X-ACL-Warn: , Daniel Ziltener via Guix-patches X-Patchwork-Original-From: Daniel Ziltener via Guix-patches via From: Daniel Ziltener Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches --- guix/build-system/chicken.scm | 87 +++++++++++++++++++---------- guix/build/chicken-build-system.scm | 55 ++++++++++++------ 2 files changed, 96 insertions(+), 46 deletions(-) diff --git a/guix/build-system/chicken.scm b/guix/build-system/chicken.scm index e6fcfa7ee3..c5705018d1 100644 --- a/guix/build-system/chicken.scm +++ b/guix/build-system/chicken.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2020 raingloom ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2025 zilti ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,9 +24,12 @@ (define-module (guix build-system chicken) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) + #:use-module (guix download) #:use-module (guix search-paths) #:use-module (guix build-system) #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) #:use-module (guix packages) #:export (%chicken-build-system-modules chicken-build @@ -45,10 +49,10 @@ (define %chicken-build-system-modules ,@%default-gnu-imported-modules)) (define (default-chicken) + "Return the default Chicken package." ;; Lazily resolve the binding to avoid a circular dependency. - ;; TODO is this actually needed in every build system? (let ((chicken (resolve-interface '(gnu packages chicken)))) - (module-ref chicken 'chicken))) + (module-ref chicken 'chicken))) (define* (lower name #:key source inputs native-inputs outputs system target @@ -57,38 +61,55 @@ (define* (lower name #:rest arguments) "Return a bag for NAME." (define private-keywords - '(#:target #:chicken #:inputs #:native-inputs)) + '(#:target #:inputs #:native-inputs #:outputs)) ;; TODO: cross-compilation support (and (not target) (bag (name name) (system system) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs + (host-inputs + `(,@(if source + `(("source" ,source)) + '()) + ,@inputs - ;; Keep the standard inputs of 'gnu-build-system', since - ;; Chicken compiles Scheme by using C as an intermediate - ;; language. - ,@(standard-packages))) + ;; Keep the standard inputs of 'gnu-build-system', since + ;; Chicken compiles Scheme by using C as an intermediate + ;; language. + ,@(standard-packages))) (build-inputs `(("chicken" ,chicken) ,@native-inputs)) (outputs outputs) (build chicken-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (arguments + (substitute-keyword-arguments + (strip-keyword-arguments private-keywords arguments) + ((#:extra-directories extra-directories) + `(list + ,@(append-map + (lambda (name) + (match (assoc name inputs) + ((_ pkg) + (match (package-transitive-propagated-inputs pkg) + (((propagated-names . _) ...) + (cons name propagated-names)))))) + extra-directories)))))))) (define* (chicken-build name inputs #:key + (chicken (default-chicken)) source + (tests? #t) + (parallel-build? #f) + (build-flags ''()) + (configure-flags ''()) + (extra-directories ''()) (phases '%standard-phases) - (outputs '("out")) + (outputs '("out" "static")) (search-paths '()) (egg-name "") (unpack-path "") - (build-flags ''()) - (tests? #t) (system (%current-system)) (guile #f) (imported-modules %chicken-build-system-modules) @@ -99,22 +120,28 @@ (define builder (with-imported-modules imported-modules #~(begin (use-modules #$@(sexp->gexp modules)) - (chicken-build #:name #$name - #:source #+source - #:system #$system - #:phases #$phases - #:outputs #$(outputs->gexp outputs) - #:search-paths '#$(sexp->gexp - (map search-path-specification->sexp - search-paths)) - #:egg-name #$egg-name - #:unpack-path #$unpack-path - #:build-flags #$build-flags - #:tests? #$tests? - #:inputs #$(input-tuples->gexp inputs))))) + (chicken-build + #:name #$name + #:chicken #$chicken + #:source #+source + #:system #$system + #:phases #$phases + #:configure-flags #$configure-flags + #:extra-directories #$extra-directories + #:parallel-build? #$parallel-build? + #:outputs #$(outputs->gexp outputs) + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:egg-name #$egg-name + #:unpack-path #$unpack-path + #:build-flags #$build-flags + #:tests? #$tests? + #:inputs #$(input-tuples->gexp inputs))))) - (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) - system #:graft? #f))) + (mlet %store-monad ((guile (package->derivation + (or guile (default-guile)) + system #:graft? #f))) (gexp->derivation name builder #:system system #:guile-for-build guile))) diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm index fd5a33fd22..b7c5ae4acd 100644 --- a/guix/build/chicken-build-system.scm +++ b/guix/build/chicken-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 raingloom +;;; Copyright © 2025 zilti ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,8 @@ (define-module (guix build chicken-build-system) #:use-module (guix build utils) #:use-module (ice-9 match) #:use-module (ice-9 ftw) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 popen) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (rnrs io ports) @@ -32,25 +35,45 @@ (define-module (guix build chicken-build-system) ;; CHICKEN_INSTALL_REPOSITORY is where dependencies are looked up ;; its first component is also where new eggs are installed. -;; TODO: deduplicate with go-build-system.scm ? -;; TODO: the binary version should be defined in one of the relevant modules -;; instead of being hardcoded everywhere. Tried to do that but got undefined -;; variable errors. - (define (chicken-package? name) (string-prefix? "chicken-" name)) -(define* (setup-chicken-environment #:key inputs outputs #:allow-other-keys) - (setenv "CHICKEN_INSTALL_REPOSITORY" - (string-concatenate - ;; see TODO item about binary version above - (append (list (assoc-ref outputs "out") "/var/lib/chicken/11/") - (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY"))) - (if oldenv - (list ":" oldenv) - '()))))) - (setenv "CHICKEN_EGG_CACHE" (getcwd)) - #t) +(define (chicken-binary-version chicken) + (let* ((port (open-pipe* + OPEN_READ + (string-append chicken "/bin/csi") + "-p" + "(begin (import (chicken pathname) (chicken platform)) (pathname-file (car (repository-path))))")) + (str (read-line port))) + (close-pipe port) + str)) + +(define (chicken-lib-dir chicken) + (string-append + chicken "/var/lib/chicken/" + (chicken-binary-version chicken) "/")) + +(define (egg-lib-dir chicken outputs) + (string-append + (assoc-ref outputs "out") "/var/lib/chicken/" + (chicken-binary-version chicken) "/")) + +(define* (setup-chicken-environment #:key inputs outputs chicken #:allow-other-keys) + (let ((chickenlibdir (chicken-lib-dir chicken)) + (egglibdir (egg-lib-dir chicken outputs))) + (setenv "CHICKEN_INSTALL_REPOSITORY" + (string-concatenate + (append `(,egglibdir) + (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY"))) + (if oldenv (list ":" oldenv) '()))))) + (setenv "CHICKEN_INSTALL_PREFIX" (assoc-ref outputs "out")) + (setenv "CHICKEN_REPOSITORY_PATH" + (string-concatenate + (append `(,egglibdir ":" ,chickenlibdir) + (let ((oldenv (getenv "CHICKEN_REPOSITORY_PATH"))) + (if oldenv (list ":" oldenv) '()))))) + (setenv "CHICKEN_EGG_CACHE" (getcwd)) + #t)) ;; This is copied from go-build-system.scm so it could probably be simplified. ;; I used it because the source of the egg needs to be unpacked into a directory