From: Andrea Corallo Date: Sat, 29 Aug 2020 09:29:01 +0000 (+0200) Subject: Have .elc files in `load-history' when loading native code (bug#43089) X-Git-Tag: emacs-28.0.90~2727^2~471 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=87b9c3e71840f480c2ce05eb51d71156790a5434;p=emacs.git Have .elc files in `load-history' when loading native code (bug#43089) * 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'. --- diff --git a/lisp/subr.el b/lisp/subr.el index 6e866015509..b020d09280a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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"))) diff --git a/src/lread.c b/src/lread.c index 326af307f9c..ac5b2838eef 100644 --- a/src/lread.c +++ b/src/lread.c @@ -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);