unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 59334@debbugs.gnu.org, Andrea Corallo <akrl@sdf.org>
Subject: bug#59334: 29.0.50; loading native-compiled init file sets user-init-file to .eln
Date: Fri, 18 Nov 2022 03:25:34 +0100	[thread overview]
Message-ID: <CAAeL0SSdRjnXFbhUM98kON-s84AP2C=mTnx04czrR11Nj9-NnQ@mail.gmail.com> (raw)
In-Reply-To: <83fsehcpi2.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2418 bytes --]

This fix works. It assumes (as the original code does) that the source will
either be an .el file, or extensionless (though when an .eln was loaded,
the source will always be .el), so the following code will check for
staleness of the .elc as usual.

In other words, with this patch, it will still warn if the source file is
newer than the .elc (as it does now Emacs), regardless of whether the init
file was loaded from an .elc or .eln. (The age of the .eln is irrelevant
here, that's for the native compiler to check and act upon.)


diff --git i/lisp/startup.el w/lisp/startup.el
index 70267fc857..62984426e5 100644
--- i/lisp/startup.el
+++ w/lisp/startup.el
@@ -1064,7 +1064,11 @@ startup--load-user-init-file
             ;; If we loaded a compiled file, set `user-init-file' to
             ;; the source version if that exists.
-            (when (equal (file-name-extension user-init-file)
-                         "elc")
-              (let* ((source (file-name-sans-extension user-init-file))
+            (when (member (file-name-extension user-init-file)
+                          '("elc" "eln"))
+              (let* ((source (file-name-sans-extension
+                              (or (gethash
+                                   (file-name-nondirectory user-init-file)
+                                   comp-eln-to-el-h)
+                                  user-init-file)))
                      (alt (concat source ".el")))
                 (setq source (cond ((file-exists-p alt) alt)


Testing this patch allowed me to discover another bug:

If you use ~/.emacs instead of ~.emacs.d/init.el, and happen to compile
.emacs, Emacs loads .emacs.elc (as it has always done), but the native
compiler does *not* know how to compile it (because it does not know how to
locate its source), so it gives a warning:

022-11-18 02:54:01+0100 Warning (comp): Cannot look up eln file as no
source file was found for d:/Home/.emacs.elc

and then it assigns the user-init-file to warnings.el!

ELISP> user-init-file
"d:/Home/.emacs.d/native/29.0.50-a4a10996/warnings-28e75f4d-02da775e.eln"

which, if my patch is installed, gets converted to its source file:

ELISP> user-init-file
"d:/Devel/emacs/repo/trunk/lisp/emacs-lisp/warnings.el"

So this is a double bug for anyone compiling their .emacs: they will always
get a warning, and an erroneous user-init-file.

Do you want me to file this as a separate bug?

[-- Attachment #2: Type: text/html, Size: 3169 bytes --]

  reply	other threads:[~2022-11-18  2:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  9:28 bug#59334: 29.0.50; loading native-compiled init file sets user-init-file to .eln Juanma Barranquero
2022-11-17 12:07 ` Eli Zaretskii
2022-11-17 13:30   ` Juanma Barranquero
2022-11-17 14:00     ` Eli Zaretskii
2022-11-17 20:04       ` Andrea Corallo
2022-11-17 20:09         ` Eli Zaretskii
2022-11-18  2:25           ` Juanma Barranquero [this message]
2022-11-18  2:56             ` Juanma Barranquero
2022-11-18  3:03               ` Juanma Barranquero
2022-11-18  7:50                 ` Eli Zaretskii
2022-11-18  7:19             ` Eli Zaretskii
2022-11-18  7:27             ` Eli Zaretskii
2022-11-18  7:45               ` Juanma Barranquero
2022-11-18  8:46                 ` Eli Zaretskii
2022-11-18  9:05                   ` Juanma Barranquero
2022-11-18  9:08                     ` Juanma Barranquero
2022-11-18 12:33                     ` Eli Zaretskii
2022-11-18 12:40                       ` Juanma Barranquero
2022-11-18 12:50                         ` Eli Zaretskii
2022-11-18 13:03                           ` Juanma Barranquero
2022-11-18 20:02                       ` Andrea Corallo
2022-11-18 10:39                   ` Andrea Corallo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAeL0SSdRjnXFbhUM98kON-s84AP2C=mTnx04czrR11Nj9-NnQ@mail.gmail.com' \
    --to=lekktu@gmail.com \
    --cc=59334@debbugs.gnu.org \
    --cc=akrl@sdf.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).