Skip to content

pr fix autoload generation recursion error#953

Merged
matsl merged 4 commits into
masterfrom
pr_fix_autoload_generation_recursion_error
May 15, 2026
Merged

pr fix autoload generation recursion error#953
matsl merged 4 commits into
masterfrom
pr_fix_autoload_generation_recursion_error

Conversation

@matsl
Copy link
Copy Markdown
Collaborator

@matsl matsl commented May 13, 2026

What

Do not load and generate autoloads from hload-path while in batch
processing (such as byte compiling).

  • Do not load and generate autoloads from hload-path in batch
  • Remove compile dependency on loading autoloads

Why

When generating autoloads in Emacs 31 we get this error below. It does
not occur with older versions.

Eager macro-expansion failure

❯ make clean autoloads
  GEN      kotl/kotl-autoloads.el
  INFO     Scraping 66 files for loaddefs...
hibtypes:0: Warning: Not registering prefix "hy".  Affects: ("hyrolo-stuck-msg" "hyp-manual" "hyp-address" "hyp-source" "hywiki-word" "hywiki-existing-word")
loaddefs-gen: loading file hsys-youtube (for defact)
Loading /home/matsl/src/hyperbole/hsys-youtube.el (source)...
Warning (emacs): loaddefs-gen: load error
	(error "Eager macro-expansion failure: (error \"Eager macro-expansion failure: (error \\\"Recursive load\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/emacs-lisp/pcase.el.gz\\\" \\\"/home/matsl/src/hyperbole/set.el\\\" \\\"/home/matsl/src/hyperbole/hact.el\\\" \\\"/home/matsl/src/hyperbole/hsys-youtube.el\\\" \\\"/home/matsl/src/hyperbole/hload-path.el\\\")\")")
  INFO     Scraping 66 files for loaddefs...done
  GEN      hyperbole-autoloads.el
  INFO     Scraping 13 files for loaddefs...
  INFO     Scraping 13 files for loaddefs...done
  GEN      kotl-autoloads.el
Initializing Hyperbole...
Initializing Hyperbole...done
  INFO     Scraping 14 files for loaddefs...
  INFO     Scraping 14 files for loaddefs...done

The recursive load seems to origin from hload-path.el having a call to
check if autoloads are generated and if not generate and load them.

This PR tries to solve this by limiting the generation and loading of
autoloads to an interactive Emacs.

Further, the byte compile errors that occurs due to not loading
autoloads are resolved by adding declare-function and defvar. Each
el-file is by that possible to compile without having to load the
autoloads.

Note

I though this was a good experiment for solving the loaddefs-gen issue
by decoupling byte compilation from autoloads generation.

It also brought my attention to that we generate autoloads from
hload-path which feels a bit odd. I mean for normal use the autoloads
are generated by the package manager or, when running from source, by our
make target. Anyway this PR does not change that. An interactive Emacs
behaves the same.

@matsl matsl requested a review from rswgnu May 13, 2026 21:54
@rswgnu
Copy link
Copy Markdown
Owner

rswgnu commented May 14, 2026 via email

@matsl
Copy link
Copy Markdown
Collaborator Author

matsl commented May 14, 2026

The hload-path autoload generation is from long ago as is that whole setup when Emacs could not find its own executable directory.Are you saying that the PR has all the defs needed to work if there are no autoloads? If so, we should be able to go with this.

Yes, I think that is the case. Our CI build targets does generate autoloads before byte compiling so the CI build is not a perfect confirmation of that. It is just an indirect one since the hload-path check for the autoloads requires an interactive Emacs.

I have tested locally by running "make clean new-bin" which builds the elcs without building the autoloads. I have also tested to start en Emacs without the autoloads and then they are generated and loaded. The later I guess is what always happens when you run from source without using a package manager.

Copy link
Copy Markdown
Owner

@rswgnu rswgnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally fine, fix 2 comments and then can approve.

Comment thread hmouse-drv.el
Comment thread hycontrol.el
@rswgnu
Copy link
Copy Markdown
Owner

rswgnu commented May 14, 2026 via email

@matsl
Copy link
Copy Markdown
Collaborator Author

matsl commented May 14, 2026

I moved out the hycontrol changes. So now we have these warnings that the change to hycontrol was fixing:

hycontrol.el:581:9: Warning: assignment to free variable
hycontrol.el:582:9: Warning: assignment to free variable
hycontrol.el:603:10: Warning: reference to free variable
hycontrol.el:1077:13: Warning: reference to free variable
hycontrol.el:1077:35: Warning: reference to free variable
hycontrol.el:1098:11: Warning: reference to free variable
hycontrol.el:1100:11: Warning: reference to free variable

@matsl
Copy link
Copy Markdown
Collaborator Author

matsl commented May 14, 2026

See PT #954 for the hycontrol changes as requested in a separate PR.

@matsl matsl requested a review from rswgnu May 14, 2026 21:11
matsl added 4 commits May 15, 2026 16:09
* hload-path.el: Only generate and load autoloads when interactive
Add declare-function and defvar declarations so each el-file can be
byte compiled without requiring the autoloads to be loaded.
@matsl matsl force-pushed the pr_fix_autoload_generation_recursion_error branch from 6ff57c1 to 5e1a2e4 Compare May 15, 2026 14:33
@matsl matsl merged commit 35fa167 into master May 15, 2026
4 checks passed
@matsl matsl deleted the pr_fix_autoload_generation_recursion_error branch May 15, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants