Subject: bug#62317: bug #62317: 28.2; This byte-compiled file behaves wrongly.

From: Eli Zaretskii <[email-masked]>
Date: Thu, 30 Mar 2023 12:41:18 +0300

> Date: Thu, 30 Mar 2023 18:20:45 +0900 (JST)
> Cc: [email-masked], [email-masked]
> From: Teika Kazura <[email-masked]>
> 
> What surprises is that `native-compile-async' and `batch-native-compile' generate differnt codes. To show it, use the same init.el and a.el above. Byte-compile first a.el, then init.el. Next native-compile init.el. Run emacs, and the above bug appears.

This is not surprising at all: native-compile-async compiles in a
separate process with environment unaffected by your customizations,
whereas batch-native-compile compiles in the current session, and thus
inherits all of your customizations.

> The difference is that (i) if you use native-compile-async, by removing one of init-<hash>.eln or init.elc, the bug disappears, even if the other remains. But (ii) if you use "$ emacs -Q -batch -f batch-native-compile *el", eln in fact does not matter; only the presence of init.elc screws things up.
> 
> # Who can expect this?
> 
> At the very least, native-compilation has too many undocumented aspects. If you want, I'll open a new bug for this discrepancy.
> 
> # It's off-topic for this bug, but for the above sample code, automatic, asynchronous generation of an eln file does not happen, unlike the case of my real init.el. I can't find the reason yet.

If the above happens in "emacs -Q", a reproducible recipe will help.
And please try that in Emacs 29 if you can, since we don't plan on any
releases of Emacs 28 with any substantial changes.