diff options
-rw-r--r-- | guix/derivations.scm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 8309f845d9..140c22b620 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -1207,13 +1207,25 @@ they can refer to each other." #:guile-for-build guile #:local-build? #t))) +(define %module-cache + ;; Map a list of modules to its 'imported+compiled-modules' result. + (make-weak-value-hash-table)) + (define* (imported+compiled-modules store modules #:key (system (%current-system)) (guile (%guile-for-build))) "Return a pair containing the derivation to import MODULES and that where MODULES are compiled." - (cons (%imported-modules store modules #:system system #:guile guile) - (%compiled-modules store modules #:system system #:guile guile))) + (define key + (list modules (derivation-file-name guile) system)) + + (or (hash-ref %module-cache key) + (let ((result (cons (%imported-modules store modules + #:system system #:guile guile) + (%compiled-modules store modules + #:system system #:guile guile)))) + (hash-set! %module-cache key result) + result))) (define* (build-expression->derivation store name exp ;deprecated #:key |