diff options
| author | Stefan Kangas | 2020-11-19 22:09:37 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2020-11-20 21:05:57 +0100 |
| commit | 050de01d948fa2c07d9e8fbd73c683fdb615ff32 (patch) | |
| tree | da966db123eb7bc5ca7f6438af884ef0089b57b1 | |
| parent | a79365acaff843a144eacc620bfe6992051f84d4 (diff) | |
| download | emacs-050de01d948fa2c07d9e8fbd73c683fdb615ff32.tar.gz 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.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 17 |
2 files changed, 21 insertions, 0 deletions
| @@ -838,6 +838,10 @@ key binding | |||
| 838 | / u package-menu-filter-upgradable | 838 | / u package-menu-filter-upgradable |
| 839 | / / package-menu-filter-clear | 839 | / / package-menu-filter-clear |
| 840 | 840 | ||
| 841 | *** Option to automatically native compile packages on installation. | ||
| 842 | Customize the user option `package-native-compile' to enable automatic | ||
| 843 | native compilation of packages on installation. | ||
| 844 | |||
| 841 | --- | 845 | --- |
| 842 | *** Column widths in 'list-packages' display can now be customized. | 846 | *** Column widths in 'list-packages' display can now be customized. |
| 843 | See the new user options 'package-name-column-width', | 847 | See the new user options 'package-name-column-width', |
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." | |||
| 389 | :version "25.1" | 389 | :version "25.1" |
| 390 | :type '(repeat symbol)) | 390 | :type '(repeat symbol)) |
| 391 | 391 | ||
| 392 | (defcustom package-native-compile nil | ||
| 393 | "Non-nil means to native compile packages on installation." | ||
| 394 | :type '(boolean) | ||
| 395 | :risky t | ||
| 396 | :version "28.1") | ||
| 397 | |||
| 392 | (defcustom package-menu-async t | 398 | (defcustom package-menu-async t |
| 393 | "If non-nil, package-menu will use async operations when possible. | 399 | "If non-nil, package-menu will use async operations when possible. |
| 394 | Currently, only the refreshing of archive contents supports | 400 | Currently, only the refreshing of archive contents supports |
| @@ -968,6 +974,8 @@ untar into a directory named DIR; otherwise, signal an error." | |||
| 968 | ;; E.g. for multi-package installs, we should first install all packages | 974 | ;; E.g. for multi-package installs, we should first install all packages |
| 969 | ;; and then compile them. | 975 | ;; and then compile them. |
| 970 | (package--compile new-desc) | 976 | (package--compile new-desc) |
| 977 | (when package-native-compile | ||
| 978 | (package--native-compile-async new-desc)) | ||
| 971 | ;; After compilation, load again any files loaded by | 979 | ;; After compilation, load again any files loaded by |
| 972 | ;; `activate-1', so that we use the byte-compiled definitions. | 980 | ;; `activate-1', so that we use the byte-compiled definitions. |
| 973 | (package--load-files-for-activation new-desc :reload))) | 981 | (package--load-files-for-activation new-desc :reload))) |
| @@ -1052,6 +1060,15 @@ This assumes that `pkg-desc' has already been activated with | |||
| 1052 | (load-path load-path)) | 1060 | (load-path load-path)) |
| 1053 | (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))) | 1061 | (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))) |
| 1054 | 1062 | ||
| 1063 | (defun package--native-compile-async (pkg-desc) | ||
| 1064 | "Native compile installed package PKG-DESC asynchronously. | ||
| 1065 | This assumes that `pkg-desc' has already been activated with | ||
| 1066 | `package-activate-1'." | ||
| 1067 | (when (and (featurep 'nativecomp) | ||
| 1068 | (native-comp-available-p)) | ||
| 1069 | (let ((warning-minimum-level :error)) | ||
| 1070 | (native-compile-async (package-desc-dir pkg-desc) t)))) | ||
| 1071 | |||
| 1055 | ;;;; Inferring package from current buffer | 1072 | ;;;; Inferring package from current buffer |
| 1056 | (defun package-read-from-string (str) | 1073 | (defun package-read-from-string (str) |
| 1057 | "Read a Lisp expression from STR. | 1074 | "Read a Lisp expression from STR. |