Subject: bug#55305: 28.0.50: With async nativecomp, package manager fails to load hyperbole-autoloads.el before compilation

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 May 2022 18:05:44 +0300

> From: Robert Weiner <[email-masked]>
> Date: Sat, 14 May 2022 10:47:40 -0400
> Cc: [email-masked]
> 
> > loaddefs.el is preloaded into Emacs when it is built, so the analogy
> > doesn't work in practice.
> 
> Emacs loads autoloads from a file when it is built (prior to dumping its
> image) and I am simply suggesting that both the package manager and the
> native compiler do the same for packages.

How can a native compiler or a byte compiler know that a given .el
file needs some loadefs file to be loaded before it's compiled?  Most
Lisp files don't have and don't need any loaddefs files to be
compiled.

For that matter, how can a compiler know that a given .el files _has_
a loaddefs file, and if so, what is its name?

Loaddefs files are needed for when a file is loaded, not when it's
compiled.  For compilation, we have 'require' and 'eval-when-compile',
and always had them.  Are you saying that 'require' and
'eval-when-compile' should also be replaced by some automation? if so,
how can this work even in principle without some meta-data available
somewhere for the compiler to find and use?  And if we need meta-data,
what is wrong with having it in the form of 'require' and
'eval-when-compile' in the file itself?

> > I think you should look at bundled packages like Calc.  Calc has
> > calc-loaddefs.el, but I just now forced Emacs 28.1 to native-compile
> > Calc and didn't see any problems.  And I see that calc.el does say
> > explicitly
> >
> >   ;;;; (Autoloads here)
> >   (load "calc-loaddefs.el" nil t)
> >
> 
> Exactly, calc.el works around this missing feature by explicitly loading
> the loaddefs and then having every other calc module require the 'calc'
> library.

But it isn't just calc.el: every single FOO-loaddefs.el file in the
Emacs tree is loaded like that.  This is a de-facto standard in how we
use the separate loaddefs files of bundled packages.

And again, there's nothing new here related to the native compiler: it
works the same with the byte compiler, and will output the same
warnings if you fail to follow this paradigm.  It's nothing new.

If you are lobbying for having more automated discovery and loading of
loaddefs files, then you are asking for a new feature, not reporting a
bug in Emacs 28 that didn't exist in previous versions.  And I don't
think I agree that this feature is a good idea, for when a file is
compiled.  But we could discuss this feature request; my point is that
there's no bug here, but a normal behavior we have with any
compilation of any Lisp file in any Emacs version.