]> git.eshelyaron.com Git - emacs.git/commitdiff
Have .elc files in `load-history' when loading native code (bug#43089)
authorAndrea Corallo <akrl@sdf.org>
Sat, 29 Aug 2020 09:29:01 +0000 (11:29 +0200)
committerAndrea Corallo <akrl@sdf.org>
Sat, 29 Aug 2020 14:08:03 +0000 (16:08 +0200)
* src/lread.c (Fload): Add the corresponding .elc file to
`load-history' when loading native code.

* lisp/subr.el (eval-after-load): Use `load-file-name' instead of
`load-true-file-name'.

lisp/subr.el
src/lread.c

index 6e86601550957131a86f3d35b022d61247ca970a..b020d09280a1f33f26ab0bc3e56047a1240b3451 100644 (file)
@@ -4613,10 +4613,10 @@ This function makes or adds to an entry on `after-load-alist'."
                ;; So add an indirection to make sure that `func' is really run
                ;; "after-load" in case the provide call happens early.
                (lambda ()
-                 (if (not load-true-file-name)
+                 (if (not load-file-name)
                      ;; Not being provided from a file, run func right now.
                      (funcall func)
-                   (let ((lfn load-true-file-name)
+                   (let ((lfn load-file-name)
                          ;; Don't use letrec, because equal (in
                          ;; add/remove-hook) would get trapped in a cycle.
                          (fun (make-symbol "eval-after-load-helper")))
index 326af307f9c0f153b5c3feff96754b43d6748724..ac5b2838eef888817f9a00d7398893b26960b132 100644 (file)
@@ -1322,10 +1322,23 @@ Return t if the file exists and loads successfully.  */)
   specbind (Qlexical_binding, Qnil);
 
   /* Get the name for load-history.  */
+  Lisp_Object found_for_hist;
+  if (is_native_elisp)
+    {
+      /* Reconstruct the .elc filename.  */
+      Lisp_Object src_name = Fgethash (Ffile_name_nondirectory (found),
+                                      Vcomp_eln_to_el_h, Qnil);
+      if (suffix_p (src_name, "el.gz"))
+       src_name = Fsubstring (src_name, make_fixnum (0), make_fixnum (-3));
+      found_for_hist = concat2 (src_name, build_string ("c"));
+    }
+  else
+    found_for_hist = found;
+
   hist_file_name = (! NILP (Vpurify_flag)
                     ? concat2 (Ffile_name_directory (file),
-                               Ffile_name_nondirectory (found))
-                    : found;
+                               Ffile_name_nondirectory (found_for_hist))
+                    : found_for_hist);
 
   version = -1;
 
@@ -1504,13 +1517,6 @@ Return t if the file exists and loads successfully.  */)
     {
 #ifdef HAVE_NATIVE_COMP
       specbind (Qcurrent_load_list, Qnil);
-      if (!NILP (Vpurify_flag))
-       {
-         Lisp_Object base = concat2 (parent_directory (Vinvocation_directory),
-                                     build_string ("lisp/"));
-         Lisp_Object offset = Flength (base);
-         hist_file_name = Fsubstring (found, offset, Qnil);
-       }
       LOADHIST_ATTACH (hist_file_name);
       Fnative_elisp_load (found, Qnil);
       build_load_history (hist_file_name, true);