From patchwork Fri Jan 5 16:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 58382 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 E93B827BBEA; Fri, 5 Jan 2024 16:41:08 +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 E6DF727BBE2 for ; Fri, 5 Jan 2024 16:41:07 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLnFk-0006nt-3x; 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-0006nA-MZ 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 1rLnFh-0002h4-OU; Fri, 05 Jan 2024 11:40:57 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLnFm-0003tM-1d; Fri, 05 Jan 2024 11:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68266] [PATCH 1/7] gnu: Memozise make-ld-wrapper results. References: <87plyfrb2x.fsf@cbaines.net> In-Reply-To: <87plyfrb2x.fsf@cbaines.net> 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.170447286014927 (code B ref 68266); Fri, 05 Jan 2024 16:41:02 +0000 Received: (at 68266) by debbugs.gnu.org; 5 Jan 2024 16:41:00 +0000 Received: from localhost ([127.0.0.1]:57723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFj-0003sO-0f 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]:50159) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLnFg-0003rw-EA for 68266@debbugs.gnu.org; Fri, 05 Jan 2024 11:40:57 -0500 Received: from localhost (unknown [217.155.61.229]) by mira.cbaines.net (Postfix) with ESMTPSA id 2BEF927BBE2 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 019e4bde for <68266@debbugs.gnu.org>; Fri, 5 Jan 2024 16:40:50 +0000 (UTC) From: Christopher Baines Date: Fri, 5 Jan 2024 16:40:43 +0000 Message-ID: <13f83a0db585e81572240e35dfef473aa73fe996.1704472849.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 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/base.scm (make-ld-wrapper): Move code to make-ld-wrapper/implementation and call it. (make-ld-wrapper/implementation) New procedure. Change-Id: Id6fc805a4a7ffbc5ff0a5174eafcdf2c7c46854d --- gnu/packages/base.scm | 126 ++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 60 deletions(-) base-commit: 5279bd453f354cbbaafff44e46c6fa03a39bc10a diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 8b25af6a5e..929bf9f422 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -66,6 +66,7 @@ (define-module (gnu packages base) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix download) + #:use-module (guix memoization) #:use-module (guix git-download) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) @@ -715,68 +716,73 @@ (define* (make-ld-wrapper name #:key wrapper for the cross-linker for that target, called 'TARGET-ld'. To use a different linker than the default \"ld\", such as \"ld.gold\" the linker name can be provided via the LINKER argument." - ;; Note: #:system->target-triplet is a procedure so that the evaluation of - ;; its result can be delayed until the 'arguments' field is evaluated, thus - ;; in a context where '%current-system' is accurate. - (package - (name name) - (version "0") - (source #f) - (build-system trivial-build-system) - (inputs `(("binutils" ,binutils) - ("guile" ,guile) - ("bash" ,bash) - ("wrapper" ,(search-path %load-path - "gnu/packages/ld-wrapper.in")))) - (arguments - (let ((target (target (%current-system)))) - `(#:guile ,guile-for-build - #:modules ((guix build utils)) - #:builder (begin - (use-modules (guix build utils) - (system base compile)) - - (let* ((out (assoc-ref %outputs "out")) - (bin (string-append out "/bin")) - (ld ,(if target - `(string-append bin "/" ,target "-" - ,linker) - `(string-append bin "/" ,linker))) - (go (string-append ld ".go"))) - - (setvbuf (current-output-port) - (cond-expand (guile-2.0 _IOLBF) - (else 'line))) - (format #t "building ~s/bin/ld wrapper in ~s~%" - (assoc-ref %build-inputs "binutils") - out) - - (mkdir-p bin) - (copy-file (assoc-ref %build-inputs "wrapper") ld) - (substitute* ld - (("@SELF@") - ld) - (("@GUILE@") - (string-append (assoc-ref %build-inputs "guile") - "/bin/guile")) - (("@BASH@") - (string-append (assoc-ref %build-inputs "bash") - "/bin/bash")) - (("@LD@") - (string-append (assoc-ref %build-inputs "binutils") - ,(if target - (string-append "/bin/" - target "-" linker) - (string-append "/bin/" linker))))) - (chmod ld #o555) - (compile-file ld #:output-file go)))))) - (synopsis "The linker wrapper") - (description - "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any + (make-ld-wrapper/implementation name target binutils linker + guile bash guile-for-build)) + +(define make-ld-wrapper/implementation + (mlambda (name target binutils linker guile bash guile-for-build) + ;; Note: #:system->target-triplet is a procedure so that the evaluation of + ;; its result can be delayed until the 'arguments' field is evaluated, + ;; thus in a context where '%current-system' is accurate. + (package + (name name) + (version "0") + (source #f) + (build-system trivial-build-system) + (inputs `(("binutils" ,binutils) + ("guile" ,guile) + ("bash" ,bash) + ("wrapper" ,(search-path %load-path + "gnu/packages/ld-wrapper.in")))) + (arguments + (let ((target (target (%current-system)))) + `(#:guile ,guile-for-build + #:modules ((guix build utils)) + #:builder (begin + (use-modules (guix build utils) + (system base compile)) + + (let* ((out (assoc-ref %outputs "out")) + (bin (string-append out "/bin")) + (ld ,(if target + `(string-append bin "/" ,target "-" + ,linker) + `(string-append bin "/" ,linker))) + (go (string-append ld ".go"))) + + (setvbuf (current-output-port) + (cond-expand (guile-2.0 _IOLBF) + (else 'line))) + (format #t "building ~s/bin/ld wrapper in ~s~%" + (assoc-ref %build-inputs "binutils") + out) + + (mkdir-p bin) + (copy-file (assoc-ref %build-inputs "wrapper") ld) + (substitute* ld + (("@SELF@") + ld) + (("@GUILE@") + (string-append (assoc-ref %build-inputs "guile") + "/bin/guile")) + (("@BASH@") + (string-append (assoc-ref %build-inputs "bash") + "/bin/bash")) + (("@LD@") + (string-append (assoc-ref %build-inputs "binutils") + ,(if target + (string-append "/bin/" + target "-" linker) + (string-append "/bin/" linker))))) + (chmod ld #o555) + (compile-file ld #:output-file go)))))) + (synopsis "The linker wrapper") + (description + "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any missing @code{-rpath} flags, and to detect any misuse of libraries outside of the store.") - (home-page "https://www.gnu.org/software/guix//") - (license gpl3+))) + (home-page "https://www.gnu.org/software/guix//") + (license gpl3+)))) (define-public %glibc/hurd-configure-flags ;; 'configure' in glibc 2.35 omits to pass '-ffreestanding' when detecting