Subject: bug#65455: 30.0.50; Disassemble: error with "free-standing" native compiled function

From: Andrea Corallo <[email-masked]>
Date: Fri, 25 Aug 2023 04:11:48 -0400

Gerd Möllmann <[email-masked]> writes:

> In *scratch*, evaluate
>
> (defun foo (a b)
>   (list a b))
>
> (native-compile 'foo)
> (disassemble 'foo)
>
> This gives an error in disass.el, around line 98 that a re-search fails,
> but the real error might be that, in the lines above, objdump is called
> on a file that does not exist.
>
> Workaround is to save the function to a file, native-compile that file,
> and load the resulting .eln.  Then the disassemble works as expected.
>
> In GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.6.0, NS
>  appkit-2299.70 Version 13.5 (Build 22G74)) of 2023-08-22 built on
>  Mini.fritz.box
> Repository revision: fe6009795211844ae2deda602c197cb57265eb64
> Repository branch: scratch/pkg
> Windowing system distributor 'Apple', version 10.3.2299
> System Description:  macOS 13.5
>
> Configured using:
>  'configure --cache-file /Users/gerd/tmp/config.cache.pkg
>  --with-native-compilation --disable-silent-rules 'CFLAGS=-g -O0''

Hello all,

okay so the issue is the following, when we try to disassemble the
function we fail as the temporary eln file (that was created in /tmp)
just after being loaded is deleted.  I believe thei behaviour was
introduced by ef6059cb8325 with the intent of not leaving temporary
files around.

Infact "normal disassemble" of functions belonging to .el files it's
still functional and this bug affects only functions not related to a
specific source file.

I think we have 3 options:

1- Give up on the disassemble on this specific case

2- Do not remove the temporary eln file in /tmp and wait for the OS to
   do it for us.

3- Keep a list of temporary eln files we want to clean-up when Emacs
   exits.

Bests

  Andrea