]> git.eshelyaron.com Git - emacs.git/commitdiff
Make eln files re-dumpable (bug#45103)
authorAndrea Corallo <acorallo@gnu.org>
Tue, 24 Oct 2023 15:09:38 +0000 (17:09 +0200)
committerAndrea Corallo <acorallo@gnu.org>
Tue, 24 Oct 2023 17:57:34 +0000 (19:57 +0200)
* lisp/loadup.el (load--bin-dest-dir, load--eln-dest-dir): New
variable.
(load--fixup-all-elns): New function.
* src/pdumper.c (Fdump_emacs_portable): Update to call
'load--fixup-all-elns'.
* src/print.c (print_vectorlike): Improve CU printing.

lisp/loadup.el
src/pdumper.c
src/print.c

index 35c59dba453eda42ca58017ce6d50005a1dad3c1..07895228d0d5ba2985a59bd4266a6eea7647d957 100644 (file)
@@ -496,23 +496,23 @@ lost after dumping")))
 ;; At this point, we're ready to resume undo recording for scratch.
 (buffer-enable-undo "*scratch*")
 
-(defvar comp-subr-arities-h)
-(when (featurep 'native-compile)
-  ;; Save the arity for all primitives so the compiler can always
-  ;; retrive it even in case of redefinition.
-  (mapatoms (lambda (f)
-              (when (subr-primitive-p (symbol-function f))
-                (puthash f (func-arity f) comp-subr-arities-h))))
-  ;; Fix the compilation unit filename to have it working when
-  ;; installed or if the source directory got moved.  This is set to be
-  ;; a pair in the form of:
-  ;;     (rel-filename-from-install-bin . rel-filename-from-local-bin).
-  (let ((bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
-        (eln-dest-dir (cadr (member "--eln-dest" command-line-args))))
-    (when (and bin-dest-dir eln-dest-dir)
-      (setq eln-dest-dir
-            (concat eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
-      (maphash (lambda (_ cu)
+(defvar load--bin-dest-dir nil
+  "Store the original value passed by \"--bin-dest\" during dump.
+Internal use only.")
+(defvar load--eln-dest-dir nil
+  "Store the original value passed by \"--eln-dest\" during dump.
+Internal use only.")
+
+(defun load--fixup-all-elns ()
+  "Fix all compilation unit filename.
+This to have it working when installed or if Emacs source
+directory got moved.  This is set to be a pair in the form of:
+\(rel-filename-from-install-bin . rel-filename-from-local-bin)."
+  (when (and load--bin-dest-dir load--eln-dest-dir)
+    (setq eln-dest-dir
+          (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
+    (maphash (lambda (_ cu)
+               (when (stringp (native-comp-unit-file cu))
                  (let* ((file (native-comp-unit-file cu))
                         (preloaded (equal (substring (file-name-directory file)
                                                      -10 -1)
@@ -529,10 +529,20 @@ lost after dumping")))
                                           (file-name-nondirectory
                                            file)
                                           eln-dest-dir-eff)
-                                         bin-dest-dir)
+                                         load--bin-dest-dir)
                      ;; Relative filename from the built uninstalled binary.
-                     (file-relative-name file invocation-directory)))))
-              comp-loaded-comp-units-h)))
+                     (file-relative-name file invocation-directory))))))
+            comp-loaded-comp-units-h)))
+
+(defvar comp-subr-arities-h)
+(when (featurep 'native-compile)
+  ;; Save the arity for all primitives so the compiler can always
+  ;; retrive it even in case of redefinition.
+  (mapatoms (lambda (f)
+              (when (subr-primitive-p (symbol-function f))
+                (puthash f (func-arity f) comp-subr-arities-h))))
+  (setq load--bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
+  (setq load--eln-dest-dir (cadr (member "--eln-dest" command-line-args)))
   ;; Set up the mechanism to allow inhibiting native-comp via
   ;; file-local variables.
   (defvar comp--no-native-compile (make-hash-table :test #'equal)))
index ce4faefdaeafcd0c6b830b354acce571265c5d74..315a31e2bcb256cc7d768ba41238a4866e855a25 100644 (file)
@@ -4090,6 +4090,10 @@ types.  */)
   if (!NILP (XCDR (Fall_threads ())))
     error ("No other Lisp threads can be running when this function is called");
 
+#ifdef HAVE_NATIVE_COMP
+  CALLN (Ffuncall, intern_c_string ("load--fixup-all-elns"));
+#endif
+
   check_pure_size ();
 
   /* Clear out any detritus in memory.  */
index eb20cfb1c47c2934438200b9e942e3d55d7a27cc..4eee8319f65611fd10f3aee66625f385614a9b72 100644 (file)
@@ -2008,7 +2008,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
       {
        struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (obj);
        print_c_string ("#<native compilation unit: ", printcharfun);
-       print_string (cu->file, printcharfun);
+       print_object (cu->file, printcharfun, escapeflag);
        printchar (' ', printcharfun);
        print_object (cu->optimize_qualities, printcharfun, escapeflag);
        printchar ('>', printcharfun);