From patchwork Fri Jan 5 16:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 58387 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 DDFA127BBEA; Fri, 5 Jan 2024 16:42:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 A2D7A27BBE9 for ; Fri, 5 Jan 2024 16:42:33 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLnGt-00087H-O0; Fri, 05 Jan 2024 11:42:11 -0500 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 1rLnGi-00082I-HF for guix-patches@gnu.org; Fri, 05 Jan 2024 11:42:03 -0500 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 1rLnGf-00036P-Nj; Fri, 05 Jan 2024 11:41:59 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLnGk-0003vY-23; Fri, 05 Jan 2024 11:42:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68266] [PATCH 6/7] gnu: Memozise cross-libc results. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, guix-patches@gnu.org Resent-Date: Fri, 05 Jan 2024 16:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68266 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68266@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 68266-submit@debbugs.gnu.org id=B68266.170447286314991 (code B ref 68266); Fri, 05 Jan 2024 16:42:02 +0000 Received: (at 68266) by debbugs.gnu.org; 5 Jan 2024 16:41:03 +0000 Received: from localhost ([127.0.0.1]:57730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFm-0003tU-FI for submit@debbugs.gnu.org; Fri, 05 Jan 2024 11:41:03 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFh-0003sA-Tp for 68266@debbugs.gnu.org; Fri, 05 Jan 2024 11:40:59 -0500 Received: from localhost (unknown [217.155.61.229]) by mira.cbaines.net (Postfix) with ESMTPSA id 7241827BBED for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:52 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id d5431592 for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:51 +0000 (UTC) From: Christopher Baines Date: Fri, 5 Jan 2024 16:40:48 +0000 Message-ID: <64ae83ce361b2883e9bdf4bcdaacb03a4fbd9611.1704472849.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <13f83a0db585e81572240e35dfef473aa73fe996.1704472849.git.mail@cbaines.net> References: <13f83a0db585e81572240e35dfef473aa73fe996.1704472849.git.mail@cbaines.net> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches To ensure that it just returns a single package record for some given arguments, as this helps to avoid poor performance of the store connection object cache. * gnu/packages/cross-base.scm (cross-libc*): Move code to cross-libc/implementation and call it. (cross-libc/implementation) New procedure. Change-Id: I72f430136860e5d1fd9edeb3274678186b896bd4 --- gnu/packages/cross-base.scm | 165 +++++++++++++++++++----------------- 1 file changed, 85 insertions(+), 80 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 6c6c6e7636..8a40211456 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -651,10 +651,22 @@ (define cross-kernel-headers/implementation (_ xlinux-headers)))) (define* (cross-libc . args) + "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS +and the cross tool chain. If TARGET doesn't have a standard C library #f is +returned." (if (or (= (length args) 1) (contains-keyword? args)) (apply cross-libc* args) (apply cross-libc/deprecated args))) +(define* (cross-libc* target + #:key + (libc (libc-for-target target)) + (xgcc (cross-gcc target)) + (xbinutils (cross-binutils target)) + (xheaders (cross-kernel-headers target))) + (cross-libc/implementation target libc + xgcc xbinutils xheaders)) + (define* (cross-libc/deprecated target #:optional (libc (libc-for-target target)) @@ -668,88 +680,81 @@ (define* (cross-libc/deprecated target #:xbinutils xbinutils #:xheaders xheaders)) -(define* (cross-libc* target - #:key - (libc (libc-for-target target)) - (xgcc (cross-gcc target)) - (xbinutils (cross-binutils target)) - (xheaders (cross-kernel-headers target))) - "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS -and the cross tool chain. If TARGET doesn't have a standard C library #f is -returned." - (match target - ((? target-mingw?) - (let ((machine (substring target 0 (string-index target #\-)))) - (make-mingw-w64 machine - #:xgcc xgcc - #:xbinutils xbinutils))) - ((or (? target-linux?) (? target-hurd?)) - (package - (inherit libc) - (name (string-append "glibc-cross-" target)) - (arguments - (substitute-keyword-arguments - `(;; Disable stripping (see above.) - #:strip-binaries? #f - - ;; This package is used as a target input, but it should not have - ;; the usual cross-compilation inputs since that would include - ;; itself. - #:implicit-cross-inputs? #f - - ;; We need SRFI 26. - #:modules ((guix build gnu-build-system) - (guix build utils) - (srfi srfi-26)) - - ,@(package-arguments libc)) - ((#:configure-flags flags) - `(cons ,(string-append "--host=" target) - ,(if (target-hurd? target) - `(append (list "--disable-werror" - ,@%glibc/hurd-configure-flags) - ,flags) - flags))) - ((#:phases phases) - `(modify-phases ,phases - (add-before 'configure 'set-cross-kernel-headers-path - (lambda* (#:key inputs #:allow-other-keys) - (let* ((kernel (assoc-ref inputs "kernel-headers")) - (cpath (string-append kernel "/include"))) - (for-each (cut setenv <> cpath) - ',%gcc-cross-include-paths) - (setenv "CROSS_LIBRARY_PATH" +(define cross-libc/implementation + (mlambda (target libc xgcc xbinutils xheaders) + (match target + ((? target-mingw?) + (let ((machine (substring target 0 (string-index target #\-)))) + (make-mingw-w64 machine + #:xgcc xgcc + #:xbinutils xbinutils))) + ((or (? target-linux?) (? target-hurd?)) + (package + (inherit libc) + (name (string-append "glibc-cross-" target)) + (arguments + (substitute-keyword-arguments + `(;; Disable stripping (see above.) + #:strip-binaries? #f + + ;; This package is used as a target input, but it should not have + ;; the usual cross-compilation inputs since that would include + ;; itself. + #:implicit-cross-inputs? #f + + ;; We need SRFI 26. + #:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-26)) + + ,@(package-arguments libc)) + ((#:configure-flags flags) + `(cons ,(string-append "--host=" target) + ,(if (target-hurd? target) + `(append (list "--disable-werror" + ,@%glibc/hurd-configure-flags) + ,flags) + flags))) + ((#:phases phases) + `(modify-phases ,phases + (add-before 'configure 'set-cross-kernel-headers-path + (lambda* (#:key inputs #:allow-other-keys) + (let* ((kernel (assoc-ref inputs "kernel-headers")) + (cpath (string-append kernel "/include"))) + (for-each (cut setenv <> cpath) + ',%gcc-cross-include-paths) + (setenv "CROSS_LIBRARY_PATH" (string-append kernel "/lib")) ; for Hurd's libihash #t))) - ,@(if (target-hurd? target) - '((add-after 'install 'augment-libc.so - (lambda* (#:key outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out"))) - (substitute* (string-append out "/lib/libc.so") - (("/[^ ]+/lib/libc.so.0.3") - (string-append out "/lib/libc.so.0.3" - " libmachuser.so libhurduser.so")))) - #t))) - '()))))) - - ;; Shadow the native "kernel-headers" because glibc's recipe expects the - ;; "kernel-headers" input to point to the right thing. - (propagated-inputs `(("kernel-headers" ,xheaders))) - - (native-inputs `(("cross-gcc" ,xgcc) - ("cross-binutils" ,xbinutils) - ,@(if (target-hurd? target) - `(("cross-mig" - ,(cross-mig target - #:xgcc xgcc - #:xbinutils xbinutils))) - '()) - ,@(package-inputs libc) ;FIXME: static-bash - ,@(package-native-inputs libc))))) - ((? target-avr?) - (make-avr-libc #:xbinutils xbinutils - #:xgcc xgcc)) - (else #f))) + ,@(if (target-hurd? target) + '((add-after 'install 'augment-libc.so + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out"))) + (substitute* (string-append out "/lib/libc.so") + (("/[^ ]+/lib/libc.so.0.3") + (string-append out "/lib/libc.so.0.3" + " libmachuser.so libhurduser.so")))) + #t))) + '()))))) + + ;; Shadow the native "kernel-headers" because glibc's recipe expects the + ;; "kernel-headers" input to point to the right thing. + (propagated-inputs `(("kernel-headers" ,xheaders))) + + (native-inputs `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(if (target-hurd? target) + `(("cross-mig" + ,(cross-mig target + #:xgcc xgcc + #:xbinutils xbinutils))) + '()) + ,@(package-inputs libc) ;FIXME: static-bash + ,@(package-native-inputs libc))))) + ((? target-avr?) + (make-avr-libc #:xbinutils xbinutils + #:xgcc xgcc)) + (else #f)))) (define* (cross-gcc-toolchain/implementation target #:key