summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2020-11-19 22:09:37 +0100
committerStefan Kangas <stefan@marxist.se>2020-11-20 21:05:57 +0100
commit050de01d948fa2c07d9e8fbd73c683fdb615ff32 (patch)
treeda966db123eb7bc5ca7f6438af884ef0089b57b1 /lisp/emacs-lisp
parenta79365acaff843a144eacc620bfe6992051f84d4 (diff)
downloademacs-050de01d948fa2c07d9e8fbd73c683fdb615ff32.tar.gz
emacs-050de01d948fa2c07d9e8fbd73c683fdb615ff32.tar.bz2
emacs-050de01d948fa2c07d9e8fbd73c683fdb615ff32.zip
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. (Bug#44676) (package-native-compile): New defcustom.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/package.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index a381ca01f33..9264a811ced 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -389,6 +389,12 @@ a sane initial value."
:version "25.1"
:type '(repeat symbol))
+(defcustom package-native-compile nil
+ "Non-nil means to native compile packages on installation."
+ :type '(boolean)
+ :risky t
+ :version "28.1")
+
(defcustom package-menu-async t
"If non-nil, package-menu will use async operations when possible.
Currently, only the refreshing of archive contents supports
@@ -968,6 +974,8 @@ untar into a directory named DIR; otherwise, signal an error."
;; E.g. for multi-package installs, we should first install all packages
;; and then compile them.
(package--compile new-desc)
+ (when package-native-compile
+ (package--native-compile-async 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 +1060,15 @@ This assumes that `pkg-desc' has already been activated with
(load-path load-path))
(byte-recompile-directory (package-desc-dir pkg-desc) 0 t)))
+(defun package--native-compile-async (pkg-desc)
+ "Native compile installed package PKG-DESC asynchronously.
+This assumes that `pkg-desc' has already been activated with
+`package-activate-1'."
+ (when (and (featurep 'nativecomp)
+ (native-comp-available-p))
+ (let ((warning-minimum-level :error))
+ (native-compile-async (package-desc-dir pkg-desc) t))))
+
;;;; Inferring package from current buffer
(defun package-read-from-string (str)
"Read a Lisp expression from STR.