Subject: 29.0.50; Synchronous nativecomp

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 14 Oct 2022 12:38:30 +0200

I thought I'd open a bug report for something I mentioned elsewhere: It
should be possible for --batch Emacsen to do native compilation.

I've got a bunch of Elisp scripts, and some of them do a lot of stuff,
and it'd be nice if they were native-compiled.  This will happen if I
also use the same packages interactively, but that often doesn't happen.
(And besides, since there's a bunch of different Emacs versions, they
won't use the same eln cache anyway.)

So I'd like to be able to say "emacs --batch --native-compile -l ..." or
something along those lines.

However, this also almost requires that we allow the nativecomp to
happen synchronously -- the batch job may end before nativecomp finished
otherwise, leading to cleanup problems and loss of efficiency.  So in
this mode, loading an .elc file (with missing .eln file) should instead
just trigger .eln generation, and then we load the .eln file.

And then perhaps we don't actually have to fork an Emacs to do the .eln
generation?  We can just do it in the currently running one, leading to
further efficiency gains.

This is also useful as a general tool for debugging: Today, things
aren't really reproducible, because things happen asynchronously and
unpredictably.  So if we have this, we can also use it as a debugging
tool in general, and not just in --batch.

In GNU Emacs 29.0.50 (build 144, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2022-10-13 built on downe
Repository revision: cbd04ad3d572850775f18bde868c71abcde733ed
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.1 LTS