Subject: Re: bug#73303: 30.0.91; Native compiler repeatedly interrupts at random moments

From: Eli Zaretskii <[email-masked]>
Date: Mon, 16 Sep 2024 21:42:24 +0300

tags 73303 notabug
thanks

> From: "N. Jackson" <[email-masked]>
> Date: Mon, 16 Sep 2024 18:14:46 +0000
> 
> 
> Since building Emacs 30.0.91, I have repeatedly been interrupted in
> my work by warnings from the native compiler.
> 
> A few examples of the warnings are:
> 
>   Warning (native-compiler): ~/.config/emacs/modules/cdlatex.el:1025:26: Warning: the function ‘reftex-what-environment’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:161:10: Warning: the function ‘python-nav-end-of-block’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:138:8: Warning: the function ‘python-util-forward-comment’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:94:4: Warning: the function ‘python-nav-beginning-of-statement’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:92:4: Warning: the function ‘python-nav-end-of-statement’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:62:31: Warning: the function ‘python-syntax-context’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:39:39: Warning: the function ‘python-indent’ is not known to be defined.
>   Warning (native-compiler): python-el-fgallina-expansions.el:37:40: Warning: the function ‘python-info-ppss-context’ is not known to be defined.

These warnings usually mean that the offending Lisp file lacks some
'require's.  JIT native compilation runs in a separate Emacs session,
which only loads the file it compiles, so any missing 'require's or
autoloading cookies trigger these warnings, whereas when the same
packages are loaded into your main Emacs session, they can benefit
from packages loaded earlier in the session.

IOW, these are minor bugs in the compiled files which need to be fixed
in those files and by their respective developers.

> This behaviour is quite annoying and I wonder if it would not be
> better if the native compiler compiled everything when Emacs is
> started and reported all the errors/warnings then.

You can disable these warnings if you are annoyed by them.  They are
just warnings, and will not usually cause any problems when using the
compiled code.  See native-comp-async-report-warnings-errors.

You can cause these compilations to happen at the beginning of your
Emacs session if you change your init files such that Emacs loads all
these files.  JIT native compilation is triggered by loading a .elc
file that doesn't yet have a corresponding .eln file, so by loading
them at the beginning, you will force Emacs to native-compile them all
at that time.

In any case, Emacs compiles each Lisp file just once, so you should
only see these when you start a new Emacs version for the first time.

> I supoose that might increase Emacs startup time which for some
> users would be unacceptable, but maybe it could happen the first
> time Emacs is started and after updating packages and after changing
> configuration.

It shouldn't increase startup time because the compilation is run in
separate processes, and those use other CPU cores.  Emacs doesn't wait
for the compilation to end before using a package; it uses the byte
code until the native compilation ends, and then loads the
native-compiled code when the compilation ends to replace the byte
code.

I see no bug in what you describe.