Subject: [PATCH 5/7] gnu: Memozise cross-mig results.

From: Christopher Baines <[email-masked]>
Date: Fri, 5 Jan 2024 16:40:47 +0000

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-mig): Move code to
cross-mig/implementation and call it.
(cross-mig/implementation) New procedure.

Change-Id: Iaf2a69c48664d2f0766b9d2f6e981653e0e3c44c
---
 gnu/packages/cross-base.scm | 56 +++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index f966e2f5ac..6c6c6e7636 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -467,37 +467,39 @@ (define* (cross-mig target
                     (xbinutils (cross-binutils target)))
   "Return a cross-mig for TARGET, where TARGET is a GNU triplet.  Use XGCC as
 the base compiler.  Use XBINUTILS as the associated cross-Binutils."
-  (define xgnumach-headers
-    (cross-gnumach-headers target
-                           #:xgcc xgcc
-                           #:xbinutils xbinutils))
-  (package
-    (inherit mig)
-    (name (string-append "mig-cross"))
-    (arguments
-     (substitute-keyword-arguments (package-arguments mig)
-       ((#:configure-flags flags #~'())
-        #~(list #$(string-append "--target=" target)))
-       ((#:tests? _ #f)
-        #f)
-       ((#:phases phases #~%standard-phases)
-        #~(modify-phases #$phases
-            (add-before 'configure 'set-cross-headers-path
-              (lambda* (#:key inputs #:allow-other-keys)
-                (let* ((mach #+xgnumach-headers)
-                       (cpath (string-append mach "/include")))
-                  (for-each (lambda (variable)
-                              (setenv variable cpath))
-                            '#$%gcc-cross-include-paths))))))))
-    (propagated-inputs
-     (list xgnumach-headers))
-    (native-inputs
-     (modify-inputs (package-native-inputs mig)
-       (prepend xgcc xbinutils)))))
+  (cross-mig/implementation target xgcc xbinutils))
 
+(define cross-mig/implementation
+  (mlambda (target xgcc xbinutils)
+    "Return a cross-mig for TARGET, where TARGET is a GNU triplet.  Use XGCC as
+the base compiler.  Use XBINUTILS as the associated cross-Binutils."
+    (define xgnumach-headers
+      (cross-gnumach-headers target
+                             #:xgcc xgcc
+                             #:xbinutils xbinutils))
     (package
+      (inherit mig)
+      (name (string-append "mig-cross"))
       (arguments
+       (substitute-keyword-arguments (package-arguments mig)
+         ((#:configure-flags flags #~'())
+          #~(list #$(string-append "--target=" target)))
+         ((#:tests? _ #f)
+          #f)
+         ((#:phases phases #~%standard-phases)
           #~(modify-phases #$phases
+              (add-before 'configure 'set-cross-headers-path
+                (lambda* (#:key inputs #:allow-other-keys)
+                  (let* ((mach #+xgnumach-headers)
+                         (cpath (string-append mach "/include")))
+                    (for-each (lambda (variable)
+                                (setenv variable cpath))
+                              '#$%gcc-cross-include-paths))))))))
+      (propagated-inputs
+       (list xgnumach-headers))
+      (native-inputs
+       (modify-inputs (package-native-inputs mig)
+         (prepend xgcc xbinutils))))))
 
 (define cross-kernel-headers/implementation
   (mlambda (target linux-headers xgcc xbinutils)
-- 
2.41.0