From patchwork Fri Jan 5 16:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 58384 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 9588527BBE9; Fri, 5 Jan 2024 16:41:27 +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=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 82E5F27BBE2 for ; Fri, 5 Jan 2024 16:41:26 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLnFk-0006oW-C4; Fri, 05 Jan 2024 11:41:00 -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 1rLnFi-0006nD-ON for guix-patches@gnu.org; Fri, 05 Jan 2024 11:40:58 -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-0002hE-49; 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-0003tT-FM; Fri, 05 Jan 2024 11:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68266] [PATCH 2/7] gnu: Memozise cross-binutils 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.170447286114940 (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]:57725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFk-0003si-64 for submit@debbugs.gnu.org; Fri, 05 Jan 2024 11:41:00 -0500 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:57531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFg-0003rx-EC 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 37E7C27BBE9 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 8ed7c751 for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:51 +0000 (UTC) From: Christopher Baines Date: Fri, 5 Jan 2024 16:40:44 +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-binutils*): Move code to cross-binutils/implementation and call it. (cross-binutils/implementation) New procedure. (cross-binutils/deprecated): Call cross-binutils/implementation. Change-Id: Ic7a493177026c7a699108ab6d75482ff3c189340 --- gnu/packages/cross-base.scm | 92 +++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 6ee7b315d8..a04e4f9c9e 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -89,56 +89,60 @@ (define (contains-keyword? args) (find keyword? args)) (define* (cross-binutils . args) + "Return a cross-Binutils for TARGET using BINUTILS." (if (or (= (length args) 1) (contains-keyword? args)) (apply cross-binutils* args) (apply cross-binutils/deprecated args))) +(define* (cross-binutils* target #:key (binutils binutils)) + (cross-binutils/implementation target binutils)) + (define* (cross-binutils/deprecated target #:optional (binutils binutils)) (warning (G_ "'cross-binutils' must be used with keyword arguments~%")) - (cross-binutils* target #:binutils binutils)) - -(define* (cross-binutils* target #:key (binutils binutils)) - "Return a cross-Binutils for TARGET using BINUTILS." - (let ((binutils (package - (inherit binutils) - (arguments - (substitute-keyword-arguments (package-arguments - binutils) - ((#:configure-flags flags) - ;; Build with `--with-sysroot' so that ld honors - ;; DT_RUNPATH entries when searching for a needed - ;; library. This works because as a side effect - ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells - ;; elf32.em to use DT_RUNPATH in its search list. - ;; See . - ;; - ;; In theory choosing / as the sysroot could lead ld - ;; to pick up native libs instead of target ones. In - ;; practice the RUNPATH of target libs only refers to - ;; target libs, not native libs, so this is safe. - `(cons "--with-sysroot=/" ,flags))))))) - - ;; For Xtensa, apply Qualcomm's patch. - (cross (cond ((string-prefix? "xtensa-" target) - (package-with-patches binutils - (search-patches - "ath9k-htc-firmware-binutils.patch"))) - ((target-mingw? target) - (package-with-extra-patches - (package-with-extra-configure-variable - ;; mingw binutils does not work correctly when configured - ;; with `--enable-compressed-debug-sections`. An error - ;; like the following will occur whenever you try to link: - ;; - ;; x86_64-w64-mingw32-ld: final link failed: bad value - ;; - ;; TODO: This seems like a deeper problem that warrants - ;; deeper investigation. - binutils "--enable-compressed-debug-sections" "no") - (search-patches "binutils-mingw-w64-timestamp.patch" - "binutils-mingw-w64-deterministic.patch"))) - (else binutils)) - target))) + (cross-binutils/implementation target binutils)) + +(define cross-binutils/implementation + (mlambda (target binutils) + (let ((binutils (package + (inherit binutils) + (arguments + (substitute-keyword-arguments (package-arguments + binutils) + ((#:configure-flags flags) + ;; Build with `--with-sysroot' so that ld honors + ;; DT_RUNPATH entries when searching for a needed + ;; library. This works because as a side effect + ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells + ;; elf32.em to use DT_RUNPATH in its search list. + ;; See . + ;; + ;; In theory choosing / as the sysroot could lead ld + ;; to pick up native libs instead of target ones. In + ;; practice the RUNPATH of target libs only refers to + ;; target libs, not native libs, so this is safe. + `(cons "--with-sysroot=/" ,flags))))))) + + ;; For Xtensa, apply Qualcomm's patch. + (cross (cond ((string-prefix? "xtensa-" target) + (package-with-patches binutils + (search-patches + "ath9k-htc-firmware-binutils.patch"))) + ((target-mingw? target) + (package-with-extra-patches + (package-with-extra-configure-variable + ;; mingw binutils does not work correctly when configured + ;; with `--enable-compressed-debug-sections`. An error + ;; like the following will occur whenever you try to link: + ;; + ;; x86_64-w64-mingw32-ld: final link failed: bad value + ;; + ;; TODO: This seems like a deeper problem that warrants + ;; deeper investigation. + binutils "--enable-compressed-debug-sections" "no") + (search-patches "binutils-mingw-w64-timestamp.patch" + "binutils-mingw-w64-deterministic.patch"))) + (else binutils)) + target)))) (define (cross-gcc-arguments target xgcc libc) "Return build system arguments for a cross-gcc for TARGET, using XGCC as the