* nativecomp and throw/catch across files
@ 2021-02-18 5:43 Aaron Jensen
2021-02-18 8:05 ` Andrea Corallo via Emacs development discussions.
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2021-02-18 5:43 UTC (permalink / raw)
To: emacs-devel
Hi there,
I've been trying out the nativecomp branch and I use straight.el as my
package manager.
One of the things that it does is throw when it detects that its own
compiled bytecode has changed. It does this from within straight.el:
(eval
`(unless (equal
(emacs-version)
,(eval-when-compile (emacs-version)))
(throw 'emacs-version-changed nil)))
https://github.com/raxod502/straight.el/blob/2d407bccd9378f1d5218f8ba2ae85c6be73fbaf1/straight.el#L45-L49
It then catches within bootstrap.el, which loads straight.el:
(catch 'emacs-version-changed
;; straight.el has a fun hack that throws
;; `emacs-version-changed' if the version of Emacs has changed
;; since the last time it was byte-compiled. This prevents us
;; from accidentally loading invalid byte-code, hopefully.
(load (expand-file-name (concat straight.el "c")
default-directory)
nil 'nomessage 'nosuffix)
(setq emacs-version-changed nil))
https://github.com/raxod502/straight.el/blob/2d407bccd9378f1d5218f8ba2ae85c6be73fbaf1/bootstrap.el#L47-L54
Unfortunately, this doesn't work with nativecomp. It claims that
there's no matching catch when a throw actually happens.
Warning (initialization): An error occurred while loading
‘/Users/aaronjensen/.emacs.d/early-init.el’:
No catch for tag: emacs-version-changed, nil
To reproduce, you should be able to use the bootstrap code:
https://github.com/raxod502/straight.el#bootstrapping-straightel
Then recompile emacs (which changes the value of emacs-version) and run again.
I tried narrowing it down to just a try/catch in two different files
and that worked, so there must be something more peculiar going on
here.
Aaron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nativecomp and throw/catch across files
2021-02-18 5:43 nativecomp and throw/catch across files Aaron Jensen
@ 2021-02-18 8:05 ` Andrea Corallo via Emacs development discussions.
2021-02-18 8:36 ` Aaron Jensen
0 siblings, 1 reply; 6+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-02-18 8:05 UTC (permalink / raw)
To: Aaron Jensen; +Cc: emacs-devel
Aaron Jensen <aaronjensen@gmail.com> writes:
> Hi there,
>
> I've been trying out the nativecomp branch and I use straight.el as my
> package manager.
>
> One of the things that it does is throw when it detects that its own
> compiled bytecode has changed. It does this from within straight.el:
>
> (eval
> `(unless (equal
> (emacs-version)
> ,(eval-when-compile (emacs-version)))
> (throw 'emacs-version-changed nil)))
>
> https://github.com/raxod502/straight.el/blob/2d407bccd9378f1d5218f8ba2ae85c6be73fbaf1/straight.el#L45-L49
>
> It then catches within bootstrap.el, which loads straight.el:
>
> (catch 'emacs-version-changed
> ;; straight.el has a fun hack that throws
> ;; `emacs-version-changed' if the version of Emacs has changed
> ;; since the last time it was byte-compiled. This prevents us
> ;; from accidentally loading invalid byte-code, hopefully.
> (load (expand-file-name (concat straight.el "c")
> default-directory)
> nil 'nomessage 'nosuffix)
> (setq emacs-version-changed nil))
>
> https://github.com/raxod502/straight.el/blob/2d407bccd9378f1d5218f8ba2ae85c6be73fbaf1/bootstrap.el#L47-L54
>
> Unfortunately, this doesn't work with nativecomp. It claims that
> there's no matching catch when a throw actually happens.
>
> Warning (initialization): An error occurred while loading
> ‘/Users/aaronjensen/.emacs.d/early-init.el’:
>
> No catch for tag: emacs-version-changed, nil
>
>
> To reproduce, you should be able to use the bootstrap code:
> https://github.com/raxod502/straight.el#bootstrapping-straightel
>
> Then recompile emacs (which changes the value of emacs-version) and run again.
>
> I tried narrowing it down to just a try/catch in two different files
> and that worked, so there must be something more peculiar going on
> here.
Hi Aaron,
is there a corresponding issue open in straight? Perhaps straight
developers can narrow down the issue and suggest a minimal reproducer in
case this is a real issue on our side.
Thanks
Andrea
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nativecomp and throw/catch across files
2021-02-18 8:05 ` Andrea Corallo via Emacs development discussions.
@ 2021-02-18 8:36 ` Aaron Jensen
2021-02-18 9:44 ` Andrea Corallo via Emacs development discussions.
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2021-02-18 8:36 UTC (permalink / raw)
To: Andrea Corallo; +Cc: emacs-devel
On Thu, Feb 18, 2021 at 2:06 AM Andrea Corallo <akrl@sdf.org> wrote:
>
> Hi Aaron,
>
> is there a corresponding issue open in straight? Perhaps straight
> developers can narrow down the issue and suggest a minimal reproducer in
> case this is a real issue on our side.
Reported here: https://github.com/raxod502/straight.el/issues/697
I believe the issue is that in the case that the version changes, the
throw works and the catch works. However, immediately after that, they
byte-compile straight.el and then attempt to load the elc. However,
because there's an eln, the eln is preferred and it throws again
because it wasn't rebuilt. If I rebuild the eln as well, it works as
expected.
https://github.com/raxod502/straight.el/blob/2d407bccd9378f1d5218f8ba2ae85c6be73fbaf1/bootstrap.el#L62-L65
Would it make sense to somehow invalidate the eln if the elc is
recompiled on the emacs side? Or should straight detect native-compile
and run it as well as byte-compile-file in this scenario?
Thanks,
Aaron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nativecomp and throw/catch across files
2021-02-18 8:36 ` Aaron Jensen
@ 2021-02-18 9:44 ` Andrea Corallo via Emacs development discussions.
2021-02-18 15:44 ` Aaron Jensen
0 siblings, 1 reply; 6+ messages in thread
From: Andrea Corallo via Emacs development discussions. @ 2021-02-18 9:44 UTC (permalink / raw)
To: Aaron Jensen; +Cc: emacs-devel
Aaron Jensen <aaronjensen@gmail.com> writes:
> Would it make sense to somehow invalidate the eln if the elc is
> recompiled on the emacs side? Or should straight detect native-compile
> and run it as well as byte-compile-file in this scenario?
It should be already the case. If you find a reproducer that highlight
the issue or there's evidence of this please file a bug in the bug
tracker so we can work on that.
Thanks!
Andrea
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-18 15:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-18 5:43 nativecomp and throw/catch across files Aaron Jensen
2021-02-18 8:05 ` Andrea Corallo via Emacs development discussions.
2021-02-18 8:36 ` Aaron Jensen
2021-02-18 9:44 ` Andrea Corallo via Emacs development discussions.
2021-02-18 15:44 ` Aaron Jensen
2021-02-18 15:54 ` Andrea Corallo via Emacs development discussions.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.