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

From: Robert Weiner <[email-masked]>
Date: Thu, 12 May 2022 01:14:58 -0400

On Sun, May 8, 2022 at 1:09 AM Eli Zaretskii <[email-masked]> wrote:

> > From: Robert Weiner <[email-masked]>
> > Date: Sat, 7 May 2022 16:05:17 -0400
> >
> > Tested under Emacs 28.1 and a recent tip of the Emacs git repo for Emacs
> > 29 with asynchronous native compilation enabled:
> >
> > M-x package-install RET hyperbole RET
> >
> > fails to load the hyperbole-autoloads.el file before the
> > async native compiler and byte compiler produce these errors since
> > the autoloaded var:append function is not defined:
>
> Hyperbole is not part of Emacs, so this problem should first be taken
> up with the Hyperbole developers.
>

Hi Eli:

Thanks for the response.  Two initial points:

1. I am the lead Hyperbole developer, so I will discuss it with myself :-)

2. I long ago was told that Elpa packages are considered part of Emacs
although they don't ship with it; this is why you see a number of Hyperbole
issues brought up on this list.  It would be good if you and other core
Emacs developers all held the same yes/no opinion on this so others could
follow whatever is decided.

> > Warning (comp): ~/.emacs.d/elpa/hyperbole-8.0.0/hui-em-but.el: Error:
> Symbol's function definition is void
> > var:append Disable showing Disable logging
> > Warning (comp): ~/.emacs.d/elpa/hyperbole-8.0.0/hui-mouse.el: Error:
> Symbol's function definition is void
> > var:append Disable showing Disable logging
> > Warning (comp): ~/.emacs.d/elpa/hyperbole-8.0.0/hbut.el: Error: Symbol's
> function definition is void
> > var:append Disable showing Disable logging
> >
> > The package manager definitely generates hyperbole-autoloads.el at some
> > point though I do not know if it is before these errors are produced.
>
> Do the *.el files that produce the error 'require' or 'load'
> hyperbole-autoloads?

No, the Emacs package manager installation process generates that file from
the ;;;###autoload annotations in Hyperbole lisp files (see the
'package--make-autoloads-and-stuff' function in "package.el").  The package
manager also sets up at package activation time to have those autoloads
loaded prior to loading any other code from the Hyperbole package.  It
would not make sense to require hyperbole-autoloads in other Lisp files
since that file does not exist when the package distribution is generated
and cannot be referenced prior to making a release; it would also defeat
the purpose of autoloads.

>   If not, how would compilation know to load that
> file?  Asynchronous native compilation runs in a separate pristine
> Emacs session, so it needs every dependency explicitly spelled out, or
> it will fail.
>

This is the issue that I am bringing up that I am surprised does not affect
or has not been reported for other packages.  There needs to be a
persistent, cross-session Emacs hook that runs prior to native compilation
of packages that loads the autoloads file for the package.

> But again, I think this is a matter for the Hyperbole developers to
> look into first.
>

I have resolved this for Hyperbole in an upcoming pre-release by moving a
number of previously autoloaded definitions into a file that can be
'required' by each Hyperbole module instead.  This was a good bit of work
and does not address the more general problem.  I hope you and others will
consider this a bit more and look into how it can be resolved for the good
of all packages, as it seems to be a disconnect between the Emacs package
manager and the native compilation code.

Best regards,

Bob