alexmurray / emacs-snap

GNU Emacs in a snap
https://snapcraft.io/emacs
71 stars 13 forks source link

Ahead-of-time native-compilation of elisp doesn't work as expected #64

Closed alexmurray closed 11 months ago

alexmurray commented 11 months ago

As reported in https://www.reddit.com/r/emacs/comments/15g0gxt/emacs_291_compiling_some_packages_on_every_startup/ elisp files still get natively compiled when the emacs snap is first launched:

Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/subr-x.el.gz...
uncompressing subr-x.el.gz...
uncompressing subr-x.el.gz...done
Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/gv.el.gz...
uncompressing gv.el.gz...
uncompressing gv.el.gz...done
Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/pcase.el.gz...
uncompressing pcase.el.gz...
uncompressing pcase.el.gz...done
Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/cl-lib.el.gz...
uncompressing cl-lib.el.gz...
uncompressing cl-lib.el.gz...done
Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/cl-loaddefs.el.gz...
uncompressing cl-loaddefs.el.gz...
uncompressing cl-loaddefs.el.gz...done
Compiling /snap/emacs/current/usr/share/emacs/29.1/lisp/emacs-lisp/cl-macs.el.gz...
uncompressing cl-macs.el.gz...
uncompressing cl-macs.el.gz...done
Compilation finished.
alexmurray commented 11 months ago

Currently we specify --with-native-compilation as a configure flag

https://github.com/alexmurray/emacs-snap/blob/6f8b65544c43e04bfc91d6a97eb41f68835d6370/snapcraft.yaml#L63

and we setNATIVE_FULL_AOT=1 in the build-environment section

https://github.com/alexmurray/emacs-snap/blob/6f8b65544c43e04bfc91d6a97eb41f68835d6370/snapcraft.yaml#L234

but it looks like instead we should perhaps be setting --with-native-compilation=aot as per https://git.savannah.gnu.org/cgit/emacs.git/tree/configure.ac?h=emacs-29.1#n1024

alexmurray commented 11 months ago

Also added https://github.com/alexmurray/emacs-snap/commit/cf57ec68c2a5ac5b721f445928869ca14232a4d1 to then recompile comp.el after patching it - together these appear to fix this issue. I have promoted this version of the emacs snap to stable now too.