Subject: bug#57929: 29.0.50; package-quickstart.elc incompatible with Emacs 28.2 due to defvar-1

From: Stefan Monnier <[email-masked]>
Date: Mon, 19 Sep 2022 08:38:55 -0400

Stefan Kangas [2022-09-19 05:56:39] wrote:
> It seems like the package-quickstart.elc is now backwards-incompatible
> since defvar-1 is missing.

Yes, same old issue of compatibility for `.elc` files.

It would be good to improve our handling of such situations (for
`package-quickstart.elc` as well as for other compiled files such as
those in ELPA packages).

I can think of two ways to detect the problem:
- When loading the `.elc` file signals an error.
  [ It might be a legitimate error, but we could catch it and ask the
  user if we should try loading the non-compiled file instead.  ]
- When the loaded file's version marker is "too large".  The 4th byte of
  `.elc` files holds the major version of the Emacs that compiled it
  (except that 29.0.xx counts as 28, see comment in bytecomp.el:2390),
  so we could easily use this evidence that the file was compiled by
  a newer Emacs to skip the .`elc` file.

Once detected we could also delete the file, or recompile it, or suggest
doing one of those.  Deleting could throw away a handy file.
And recompiling may generate an invalid `.elc` file if some of the
dependencies defining macros aren't loaded (or may fail if some of the
required dependencies aren't in `load-path`).

        Stefan