guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/07: DRAFT pull: Reload modules before doing anything else.


From: Ludovic Courtès
Subject: 02/07: DRAFT pull: Reload modules before doing anything else.
Date: Wed, 22 Nov 2017 09:02:46 -0500 (EST)

civodul pushed a commit to branch wip-pull-reload
in repository guix.

commit a729609924e298323af0d7a4733abb5421a66de3
Author: Ludovic Courtès <address@hidden>
Date:   Wed Nov 22 09:40:56 2017 +0100

    DRAFT pull: Reload modules before doing anything else.
    
    * guix/self (reload-guix)[reload]: Use 'primitive-load' instead of
    'primitive-load-path'.
    * build-aux/build-self.scm (build): Uncomment call to 'reload-guix'.
---
 build-aux/build-self.scm | 16 +++++++---------
 guix/self.scm            | 28 ++++++++++++++++++++--------
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm
index d9d9263..c7c460f 100644
--- a/build-aux/build-self.scm
+++ b/build-aux/build-self.scm
@@ -87,18 +87,16 @@ files."
   ;;
   ;; Our checkout in the store has mtime set to the epoch, and thus .go
   ;; files look newer, even though they may not correspond.
-  (parameterize* ((%load-should-auto-compile #f)
-                  (%fresh-auto-compile #f)
+  (parameterize* ((%load-should-auto-compile #t)
+                  (%fresh-auto-compile #t)
 
                   ;; Work around <https://bugs.gnu.org/29226>.
                   (%load-compiled-path (pure-load-compiled-path)))
-    ;; FIXME: This is currently too expensive notably because it involves
-    ;; compiling a number of the big package files such as perl.scm, which
-    ;; takes lots of time and memory as of Guile 2.2.2.
-    ;;
-    ;; (let ((reload-guix (module-ref (resolve-interface '(guix self))
-    ;;                                'reload-guix)))
-    ;;   (reload-guix))           ;cross fingers!
+    ;; Hide auto-compilation messages.
+    (parameterize ((current-warning-port (%make-void-port "w")))
+      (let ((reload-guix (module-ref (resolve-interface '(guix self))
+                                     'reload-guix)))
+        (reload-guix)))                           ;cross fingers!
 
     (let ((guix-derivation (module-ref (resolve-interface '(guix self))
                                        'guix-derivation)))
diff --git a/guix/self.scm b/guix/self.scm
index 242fc9d..3067c74 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -25,6 +25,7 @@
   #:use-module (guix discovery)
   #:use-module (guix packages)
   #:use-module (guix sets)
+  #:use-module (guix modules)
   #:use-module (guix build utils)
   #:use-module (gnu packages)
   #:use-module (srfi srfi-1)
@@ -556,16 +557,23 @@ list of file-name/file-like objects suitable as inputs to 
'imported-files'."
 
 (define* (reload-guix #:optional (log-port (current-error-port)))
   "Reload all the Guix and GNU modules currently loaded."
-  (let* ((guix (resolve-module '(guix) #f #:ensure #f))
-         (gnu  (resolve-module '(gnu) #f #:ensure #f))
+  (let* ((guix (resolve-module '(guix) #f #f #:ensure #f))
+         (gnu  (resolve-module '(gnu) #f #f #:ensure #f))
+         (core (filter-map (lambda (module)
+                             (resolve-module module #f #f
+                                             #:ensure #f))
+                           (source-module-closure '((guix packages)))))
          (guix-submodules (recursive-submodules guix))
          (gnu-submodules  (recursive-submodules gnu)))
     (define (reload module)
-      (match (module-filename module)
-        (#f #f)
-        ((? string? file)
-         ;; The following should auto-compile FILE.
-         (primitive-load-path file))))
+      ;; Reload MODULE, unless it's already been reloaded indirectly in the
+      ;; meantime.
+      (unless (resolve-module (module-name module) #f #f #:ensure #f)
+        (match (module-filename module)
+          (#f #f)
+          ((? string? file)
+           ;; The following evaluates FILE.
+           (primitive-load (search-path %load-path file))))))
 
     ;; First, we need to nuke all the (guix) and (gnu) submodules so we don't
     ;; end up with a mixture of old and new modules when we reload (which
@@ -575,10 +583,14 @@ list of file-name/file-like objects suitable as inputs to 
'imported-files'."
     (unload-module-tree! gnu)
     (unload-module-tree! guix)
 
+    ;; When reloading, we compile the core modules and interpret the rest.
+    ;; This appears to be the most efficient approach.
     (format log-port "Loading new Guix...~%")
+    (for-each reload core)
+    (set! %load-should-auto-compile #f)
     (for-each reload (append guix-submodules (list guix)))
     (for-each reload (append gnu-submodules (list gnu)))
-    (format log-port "New Guix modules successfully loaded.~%")))
+    (format log-port "New modules successfully loaded.~%")))
 
 
 ;;;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]