From patchwork Fri Jan 5 16:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 58383 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 4D92327BBE2; Fri, 5 Jan 2024 16:41:25 +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 autolearn=unavailable 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 327FF27BBE9 for ; Fri, 5 Jan 2024 16:41:24 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLnFl-0006p6-5x; Fri, 05 Jan 2024 11:41:01 -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 1rLnFj-0006nX-Q6 for guix-patches@gnu.org; Fri, 05 Jan 2024 11:40:59 -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 1rLnFi-0002hL-H9; Fri, 05 Jan 2024 11:40:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLnFm-0003tb-RL; Fri, 05 Jan 2024 11:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68266] [PATCH 3/7] gnu: Memozise cross-gcc 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:41: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.170447286114953 (code B ref 68266); Fri, 05 Jan 2024 16:41:02 +0000 Received: (at 68266) by debbugs.gnu.org; 5 Jan 2024 16:41:01 +0000 Received: from localhost ([127.0.0.1]:57727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFk-0003sv-Tz for submit@debbugs.gnu.org; Fri, 05 Jan 2024 11:41:01 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFg-0003ry-Fo for 68266@debbugs.gnu.org; Fri, 05 Jan 2024 11:40:58 -0500 Received: from localhost (unknown [217.155.61.229]) by mira.cbaines.net (Postfix) with ESMTPSA id 4344327BBEA for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:51 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id e46cabc2 for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:51 +0000 (UTC) From: Christopher Baines Date: Fri, 5 Jan 2024 16:40:45 +0000 Message-ID: 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-gcc): Move code to cross-gcc/implementation and call it. (cross-gcc/implementation) New procedure. Change-Id: Ibeafaa4d652fc1d6fd27870b82a309c177b66a05 --- gnu/packages/cross-base.scm | 183 +++++++++++++++++++----------------- 1 file changed, 95 insertions(+), 88 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index a04e4f9c9e..a4e361b476 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -301,6 +301,97 @@ (define (cross-gcc-search-paths target) ,(string-append target "/include"))))))) %gcc-cross-include-paths))) +(define cross-gcc/implementation + (mlambda (target xgcc xbinutils libc) + (package + (inherit xgcc) + (name (string-append "gcc-cross-" + (if libc "" "sans-libc-") + target)) + (source + (origin + (inherit + (package-source xgcc)) + (patches + (append + (origin-patches (package-source xgcc)) + (append (cond + ((version>=? (package-version xgcc) "12.0") + (search-patches "gcc-12-cross-environment-variables.patch" + "gcc-cross-gxx-include-dir.patch")) + ((version>=? (package-version xgcc) "10.0") + (search-patches "gcc-10-cross-environment-variables.patch" + "gcc-cross-gxx-include-dir.patch")) + ((version>=? (package-version xgcc) "8.0") + (search-patches "gcc-8-cross-environment-variables.patch")) + ((version>=? (package-version xgcc) "6.0") + (search-patches "gcc-7-cross-toolexeclibdir.patch" + "gcc-6-cross-environment-variables.patch")) + (else + (search-patches "gcc-cross-environment-variables.patch"))) + (cross-gcc-patches xgcc target)))) + (modules '((guix build utils))) + (snippet + (cross-gcc-snippet target)))) + + (outputs '("out" "lib")) + + (arguments + `(#:implicit-inputs? #f + #:imported-modules ((gnu build cross-toolchain) + ,@%gnu-build-system-modules) + #:modules ((guix build gnu-build-system) + (guix build utils) + (gnu build cross-toolchain) + (srfi srfi-1) + (srfi srfi-26) + (ice-9 regex)) + + ,@(cross-gcc-arguments target xgcc libc))) + + (native-inputs + `(("ld-wrapper-cross" ,(make-ld-wrapper + (string-append "ld-wrapper-" target) + #:target (const target) + #:binutils xbinutils)) + ("binutils-cross" ,xbinutils) + + ,@(let ((inputs (append (package-inputs xgcc) + (fold alist-delete (%final-inputs) + '("libc" "libc:static")) + + ;; Call it differently so that the builder can + ;; check whether the "libc" input is #f. + `(("libc-native" + ,@(assoc-ref (%final-inputs) "libc")) + ("libc-native:static" + ,@(assoc-ref (%final-inputs) + "libc:static")))))) + (cond + ((target-mingw? target) + (if libc + `(,@inputs + ("libc" ,libc)) + `(,@inputs + ("mingw-source" ,(package-source mingw-w64))))) + ((and libc (target-avr? target)) + `(,@inputs + ("libc" ,libc))) + (libc + `(,@inputs + ("libc" ,libc) + ("libc:static" ,libc "static") + ("xkernel-headers" ;the target headers + ,@(assoc-ref (package-propagated-inputs libc) + "kernel-headers")))) + (else inputs))))) + + (inputs '()) + + ;; Only search target inputs, not host inputs. + (search-paths (cross-gcc-search-paths target)) + (native-search-paths '())))) + (define* (cross-gcc target #:key (xgcc %xgcc) @@ -310,94 +401,10 @@ (define* (cross-gcc target XGCC as the base compiler. Use XBINUTILS as the associated cross-Binutils. If LIBC is false, then build a GCC that does not target a libc; otherwise, target that libc." - (package - (inherit xgcc) - (name (string-append "gcc-cross-" - (if libc "" "sans-libc-") - target)) - (source - (origin - (inherit - (package-source xgcc)) - (patches - (append - (origin-patches (package-source xgcc)) - (append (cond - ((version>=? (package-version xgcc) "12.0") - (search-patches "gcc-12-cross-environment-variables.patch" - "gcc-cross-gxx-include-dir.patch")) - ((version>=? (package-version xgcc) "10.0") - (search-patches "gcc-10-cross-environment-variables.patch" - "gcc-cross-gxx-include-dir.patch")) - ((version>=? (package-version xgcc) "8.0") - (search-patches "gcc-8-cross-environment-variables.patch")) - ((version>=? (package-version xgcc) "6.0") - (search-patches "gcc-7-cross-toolexeclibdir.patch" - "gcc-6-cross-environment-variables.patch")) - (else - (search-patches "gcc-cross-environment-variables.patch"))) - (cross-gcc-patches xgcc target)))) - (modules '((guix build utils))) - (snippet - (cross-gcc-snippet target)))) - - (outputs '("out" "lib")) - - (arguments - `(#:implicit-inputs? #f - #:imported-modules ((gnu build cross-toolchain) - ,@%gnu-build-system-modules) - #:modules ((guix build gnu-build-system) - (guix build utils) - (gnu build cross-toolchain) - (srfi srfi-1) - (srfi srfi-26) - (ice-9 regex)) - - ,@(cross-gcc-arguments target xgcc libc))) - - (native-inputs - `(("ld-wrapper-cross" ,(make-ld-wrapper - (string-append "ld-wrapper-" target) - #:target (const target) - #:binutils xbinutils)) - ("binutils-cross" ,xbinutils) - - ,@(let ((inputs (append (package-inputs xgcc) - (fold alist-delete (%final-inputs) - '("libc" "libc:static")) - - ;; Call it differently so that the builder can - ;; check whether the "libc" input is #f. - `(("libc-native" - ,@(assoc-ref (%final-inputs) "libc")) - ("libc-native:static" - ,@(assoc-ref (%final-inputs) - "libc:static")))))) - (cond - ((target-mingw? target) - (if libc - `(,@inputs - ("libc" ,libc)) - `(,@inputs - ("mingw-source" ,(package-source mingw-w64))))) - ((and libc (target-avr? target)) - `(,@inputs - ("libc" ,libc))) - (libc - `(,@inputs - ("libc" ,libc) - ("libc:static" ,libc "static") - ("xkernel-headers" ;the target headers - ,@(assoc-ref (package-propagated-inputs libc) - "kernel-headers")))) - (else inputs))))) - - (inputs '()) - - ;; Only search target inputs, not host inputs. - (search-paths (cross-gcc-search-paths target)) - (native-search-paths '()))) + (cross-gcc/implementation target + xgcc + xbinutils + libc)) (define* (cross-kernel-headers . args) (if (or (= (length args) 1) (contains-keyword? args))