From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <8335aheqct.fsf@gnu.org> <83wn7td6l0.fsf@gnu.org> <83fsehcpi2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c837b105edb56dbc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30323"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59334@debbugs.gnu.org, Andrea Corallo To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 03:27:22 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovr68-0007hf-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 03:27:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovr5r-0007ez-Vj; Thu, 17 Nov 2022 21:27:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovr5q-0007ec-Qq for bug-gnu-emacs@gnu.org; Thu, 17 Nov 2022 21:27:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovr5q-0003SU-Al for bug-gnu-emacs@gnu.org; Thu, 17 Nov 2022 21:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ovr5p-00049z-ST for bug-gnu-emacs@gnu.org; Thu, 17 Nov 2022 21:27:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Nov 2022 02:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59334 X-GNU-PR-Package: emacs Original-Received: via spool by 59334-submit@debbugs.gnu.org id=B59334.166873837915941 (code B ref 59334); Fri, 18 Nov 2022 02:27:01 +0000 Original-Received: (at 59334) by debbugs.gnu.org; 18 Nov 2022 02:26:19 +0000 Original-Received: from localhost ([127.0.0.1]:34790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovr59-000493-2g for submit@debbugs.gnu.org; Thu, 17 Nov 2022 21:26:19 -0500 Original-Received: from mail-ej1-f53.google.com ([209.85.218.53]:38405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovr56-00048o-75 for 59334@debbugs.gnu.org; Thu, 17 Nov 2022 21:26:17 -0500 Original-Received: by mail-ej1-f53.google.com with SMTP id f18so9753958ejz.5 for <59334@debbugs.gnu.org>; Thu, 17 Nov 2022 18:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=afuWuZ6mjHKOwFd7QFpDhXsldNNo1udhudaLC1IPrbw=; b=laj3mllzvg+lCDXm1RTf7LkxqFT6EpeYToet74E3rUByAyRdgozHRbHwQI2l0UpWWU Ru4NyFDa6aozYehl/OlngjQxEiKSWkJmoIC/hgjVuZ9wFcqBI6jacwMHwxohclNVym96 KrdtHEMM/+VEryA66W9A0m4/0/LLRHfzrSCnAZFo070G8+u/jnRHINjUkzkb/zIF6NSz cSTP+JttYdowYf2PaQWnZILvda5mptcIK9RKx4tQoqX2ebBy8wXAnvuoaZOWy5lZxzM5 /27ECBqfsuqNGX5zeLTkU2Y983UyrK2FPUQx44ZnnsJsjX1Tvx516mxO1+DpEm/1y0Sz 0lhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=afuWuZ6mjHKOwFd7QFpDhXsldNNo1udhudaLC1IPrbw=; b=z23gEwwTD8jFH6t3QU7v/zHYn2JWpmU4gO4OMMnwj71oBoEKgIaO28tUfKQgOUqXiy oZoNE6YKnTU3LUH2nNr9kTig2Rfx/4vd1QqTki/J4CzqhHVtM5LURp006Q2D4KLzJ5V5 jWWXw6DhbDJvM0kV7GljSNam7lrFziDzs5Hhj8nCVBU+QXEaBLd6ZR9YoeUxPz2bb0xp Zhb/TKV4Zv357HXh7Mwt6y5ljn3+c6RSJtbQJZngNb/V6GtWPCKZaeVWBUmEgKhenLZR 8bvEI51pDm5EveZyXFh/Kshqw2xfwHqz5z0e1KtmPwIQ9rOA8EpkgzFh2EdQe/S2cfdt 1Prw== X-Gm-Message-State: ANoB5plY/p6/hoSgUXzjmPLeMAvithjvnEwWH4QtCTfMJx1XnAyYF4yL 8cg18JjdgwnL59yQAV9iIEhRH1hjkTefwuLw4AY= X-Google-Smtp-Source: AA0mqf69DtylO81txq+pFK8e7geRqazWaoPKq+BqW1ydxpBKjDeqcJeQL2akLQ96mrPKeD/IfF1StEMnaSzAfl5jLBM= X-Received: by 2002:a17:907:c24a:b0:7ac:2e16:bc31 with SMTP id tj10-20020a170907c24a00b007ac2e16bc31mr4249773ejc.242.1668738370253; Thu, 17 Nov 2022 18:26:10 -0800 (PST) In-Reply-To: <83fsehcpi2.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248156 Archived-At: --000000000000c837b105edb56dbc Content-Type: text/plain; charset="UTF-8" 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? --000000000000c837b105edb56dbc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 alw= ays 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 so= urce file is newer than the .elc (as it does now Emacs), regardless of whet= her the=C2=A0init file was loaded from an .elc or .eln. (The age of the .el= n is irrelevant here, that's for the native compiler to check and act= =C2=A0upon.)


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


Testing this patch allow= ed me to discover another bug:

If you use ~/.emacs instead of ~.emacs.d/init.el, and happen to c= ompile .emacs, Emacs loads .emacs.elc (as it has always done), but the nati= ve 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 i= t assigns the user-init-file to warnings.el!

ELISP> user-init-file
"d:/Home/.emacs.d/native/29.0.50-a4a1099= 6/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-l= isp/warnings.el"

So this is a double bug for anyone comp= iling their .emacs: they will always get a warning, and an erroneous user-i= nit-file.

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