unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 60996@debbugs.gnu.org
Subject: bug#60996: 29.0.60; Native compile fails to remove temp file for trampoline
Date: Sat, 28 Jan 2023 21:15:02 +0000	[thread overview]
Message-ID: <86zga2pdih.fsf@gmail.com> (raw)
In-Reply-To: <74d13c46-5b26-9dd8-45dc-32b7fda25421@gmail.com>

On Fri 27 Jan 2023, Andrea Corallo wrote:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Cc: andrewjmoreton@gmail.com, 60996@debbugs.gnu.org
>>> Date: Thu, 26 Jan 2023 20:38:45 +0200
>>> From: Eli Zaretskii <eliz@gnu.org>
>>> 
>>> > The only case where we might do that AFAIR is when
>>> > `inhibit-automatic-native-compilation' is used.  This was the infamous
>>> > mechanism that was installed by Lars where, if I'm not wrong, we are
>>> > supposed to compile a trampoline, load it, and remove it to pretend we
>>> > didn't compiled anything :x
>>> 
>>> OK, this seems to be what is happening here, because we compile the
>>> trampoline to a temporary directory.  Otherwise, I don't see why we
>>> would do that, and why we would delete a trampoline we just compiled.

Sorry that this bug report has consumed so much of everyone's time.
After a while where I could not reproduce the problem, a new rebuild on
master provoked it again.

From more experimentation, the recipe seems to be:
1) Delete the "subr-trampoline-*.eln" files from the eln-cache dir
2) Start emacs with inhibit-automatic-native-compilation non-nil


>> Actually, I don't think I see where we delete the trampoline that we
>> generated when inhibit-automatic-native-compilation is non-nil.  Can
>> you point me to the code which does that?
>
> Sure, the code behind this mechanism is not straightforward and took me
> a bit to decipher it as well yesterday.

Perhaps an opportunity to refactor it at some point, to make it easier
for future maintainers to reason about this code.

> In `comp-trampoline-compile' when `inhibit-automatic-native-compilation'
> is not nil we invoke `comp--native-compile' with the `output' parameter
> set to null.
>
> `comp--native-compile' after compiling does two things:
>
> 1- If the compilation input was a file returns the .eln filename
>
> 2- If the input was a lambda (the case for trampolines) it does return
> the compiled subr.  To do that it preforms a load of the eln before
> returning.
>
> So in general what `comp--native-compile' returns is:
>
>               (if (stringp function-or-file)
>                    data
>                  ;; So we return the compiled function.
>                  (native-elisp-load data)))
>
> But at the end of `comp--native-compile' this when was added
>
> (when (and (not (stringp function-or-file))
>                       (not output)
>                       comp-ctxt
>                       (comp-ctxt-output comp-ctxt)
>                       (file-exists-p (comp-ctxt-output comp-ctxt)))
>              (delete-file (comp-ctxt-output comp-ctxt)))
>
>
> Took me a while to actually realize this is the unwindform of an
> enormous `unwind-protect'.  Anyway this is the code that when `output'
> is null (the case for trampolines) tries to performs the file
> deletetion.

I think you have identified the cause of this issue - as the .eln has
been loaded, the delete-file will never succeed on Windows.

I know Eli is not a fan of inhibit-automatic-native-compilation, but I
think there is a place for it. Users may want to use precompiled .eln
files but not waste effort on native compiling other code.

If this error can be suppressed such that the only effect is for a temp
file to be left around, that is a reasonable solution to this.

    AndyM






  reply	other threads:[~2023-01-28 21:15 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 22:12 bug#60996: 29.0.60; Native compile fails to remove temp file for trampoline Andy Moreton
2023-01-22  6:17 ` Eli Zaretskii
2023-01-22 12:51   ` Andy Moreton
2023-01-23 17:04     ` Andrea Corallo
2023-01-23 17:11       ` Eli Zaretskii
2023-01-26 16:50         ` Andrea Corallo
2023-01-26 18:38           ` Eli Zaretskii
2023-01-26 19:46             ` Andrea Corallo
2023-01-26 20:03               ` Eli Zaretskii
2023-01-26 20:25                 ` Andrea Corallo
2023-01-27 13:00                 ` Eli Zaretskii
2023-01-27 13:56                   ` Andrea Corallo
2023-01-26 20:35             ` Eli Zaretskii
2023-01-27  9:51               ` Andrea Corallo
2023-01-28 21:15                 ` Andy Moreton [this message]
2023-01-29  7:01                   ` Eli Zaretskii
2023-01-29  7:23                     ` Eli Zaretskii
2023-01-30 10:11                       ` Andrea Corallo
2023-01-29  7:47                   ` Eli Zaretskii
2023-01-29 11:37                     ` Andy Moreton
2023-01-29 13:50                       ` Eli Zaretskii
2023-01-29 13:50                       ` Eli Zaretskii
2023-01-23  2:30   ` Andy Moreton
2023-01-23 14:58     ` Eli Zaretskii
2023-01-24  1:18       ` Andy Moreton
2023-01-24 12:56         ` Eli Zaretskii
2023-01-24 17:50           ` Eli Zaretskii
2023-01-24 19:12             ` Eli Zaretskii
2023-01-24 22:32               ` Andy Moreton
2023-01-25 11:58                 ` Eli Zaretskii
2023-01-25 23:49                   ` Andy Moreton
2023-01-26  6:51                     ` Eli Zaretskii
2023-01-26 16:57             ` 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=86zga2pdih.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=60996@debbugs.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).