bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44676: [PATCH] Support native compilation of packages on install


From: Andrea Corallo
Subject: bug#44676: [PATCH] Support native compilation of packages on install
Date: Mon, 16 Nov 2020 15:12:31 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Kangas <stefan@marxist.se> writes:

Hi Stefan,

thanks for the patch

> Severity: wishlist
>
> Please find attach a patch to add support to package.el for native
> compilation of packages on installation.
>
> I've done some minimal testing and it seems to do the job.
>
> (This is intended for the native-comp branch.)
>
> From 9a0da21a6989b20f593ec2b27a48eb4ef90561b7 Mon Sep 17 00:00:00 2001
> From: Stefan Kangas <stefan@marxist.se>
> Date: Mon, 16 Nov 2020 03:28:39 +0100
> Subject: [PATCH] Support native compilation of packages on install
>
> * lisp/emacs-lisp/package.el (package-unpack)
> (package--native-compile): Native compile packages on install, if the
> feature is available.
> ---
>  lisp/emacs-lisp/package.el | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index a381ca01f3..54b42db181 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -968,6 +968,7 @@ package-unpack
>          ;; E.g. for multi-package installs, we should first install all 
> packages
>          ;; and then compile them.
>          (package--compile new-desc)
> +        (package--native-compile new-desc)
>          ;; After compilation, load again any files loaded by
>          ;; `activate-1', so that we use the byte-compiled definitions.
>          (package--load-files-for-activation new-desc :reload)))
> @@ -1052,6 +1053,12 @@ package--compile
>          (load-path load-path))
>      (byte-recompile-directory (package-desc-dir pkg-desc) 0 t)))
>  
> +(defun package--native-compile (pkg-desc)
> +  (when (and (featurep 'nativecomp)
> +             (native-comp-available-p))
> +    (let ((warning-minimum-level :error))
> +      (native-compile-async (package-desc-dir pkg-desc) t 'late))))

Late load assume the current bytecode is already loaded when the native
load will happen.  This because late load is designed to be issued when
some bytecode file is loaded and no native code alternative is found.

We should probably issue the async compilation here without late load
and in case the bytecode is being loaded before native compilation was
done just patch the kind of load stored into `comp-files-queue'.  ATM if
the stored load property and new one are not matching we complain (See
comp.el:3528).

So yeah non 100% straight forward :)

That said I think we should have a customize to decided if we want
package to eager command native compilation.

I may never used some of the installed files and prefer the current
solution for that, or maybe I may just like to have the compilation
happening in a more diluted fashion and on demand (my personal taste).

Thanks

  Andrea





reply via email to

[Prev in Thread] Current Thread [Next in Thread]