refactor: simplify native-comp detection
Reduce cases where native-comp procedures were executed in non-native-comp contexts (somehow). Also: - Adds a NATIVECOMP constant for statically detecting the feature. - Remove native-comp-* -> comp-* aliases (Emacs HEAD has long since moved on from these). - Add 'no-native-compile: t' to autoloads file.
This commit is contained in:
parent
c8484838a7
commit
cc3be7cb44
3 changed files with 28 additions and 49 deletions
|
@ -76,7 +76,7 @@ one wants that.")
|
|||
(print-quoted t)
|
||||
(print-level nil)
|
||||
(print-length nil))
|
||||
(insert ";; -*- lexical-binding: t; coding: utf-8; -*-\n"
|
||||
(insert ";; -*- lexical-binding: t; coding: utf-8; no-native-compile: t -*-\n"
|
||||
";; This file is autogenerated by 'doom sync', DO NOT EDIT IT!!\n")
|
||||
(dolist (form (delq nil forms))
|
||||
(mapc #'prin1 form))
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/cli/packages.el
|
||||
|
||||
(require 'comp nil t)
|
||||
|
||||
|
||||
;;
|
||||
;;; Commands
|
||||
|
||||
(defcli! (update u) (&rest _)
|
||||
"This command was removed."
|
||||
:hidden t
|
||||
|
@ -210,7 +216,7 @@ list remains lean."
|
|||
(comp-async-runnings))
|
||||
0))
|
||||
|
||||
(defun doom--wait-for-compile-jobs ()
|
||||
(defun doom--wait-for-native-compile-jobs ()
|
||||
"Wait for all pending async native compilation jobs."
|
||||
(cl-loop for pending = (doom--native-compile-jobs)
|
||||
with previous = 0
|
||||
|
@ -224,8 +230,7 @@ list remains lean."
|
|||
|
||||
(defun doom--write-missing-eln-errors ()
|
||||
"Write .error files for any expected .eln files that are missing."
|
||||
(when (and (require 'comp nil t)
|
||||
(ignore-errors (native-comp-available-p)))
|
||||
(when NATIVECOMP
|
||||
(cl-loop for file in doom--eln-output-expected
|
||||
for eln-name = (doom--eln-file-name file)
|
||||
for eln-file = (doom--eln-output-file eln-name)
|
||||
|
@ -239,8 +244,7 @@ list remains lean."
|
|||
|
||||
(defun doom--compile-site-packages ()
|
||||
"Queue async compilation for all non-doom Elisp files."
|
||||
(when (and (featurep 'comp)
|
||||
(ignore-errors (native-comp-available-p)))
|
||||
(when NATIVECOMP
|
||||
(cl-loop with paths = (cl-loop for path in load-path
|
||||
unless (string-prefix-p doom-local-dir path)
|
||||
collect path)
|
||||
|
@ -288,8 +292,9 @@ declaration) or dependency thereof that hasn't already been."
|
|||
(signal 'doom-package-error (list package e))))))
|
||||
(progn
|
||||
(doom--compile-site-packages)
|
||||
(doom--wait-for-compile-jobs)
|
||||
(doom--write-missing-eln-errors)
|
||||
(when NATIVECOMP
|
||||
(doom--wait-for-native-compile-jobs)
|
||||
(doom--write-missing-eln-errors))
|
||||
(print! (success "\033[KInstalled %d packages") (length built)))
|
||||
(print! (info "No packages need to be installed"))
|
||||
nil))))
|
||||
|
@ -334,8 +339,7 @@ declaration) or dependency thereof that hasn't already been."
|
|||
(and (eq (car-safe build) :not)
|
||||
(setq want-byte-compile (not want-byte-compile)
|
||||
want-native-compile (not want-native-compile)))
|
||||
(or (and (require 'comp nil t)
|
||||
(ignore-errors (native-comp-available-p)))
|
||||
(unless NATIVECOMP
|
||||
(setq want-native-compile nil))
|
||||
(and (or want-byte-compile want-native-compile)
|
||||
(or (file-newer-than-file-p repo-dir build-dir)
|
||||
|
@ -352,8 +356,9 @@ declaration) or dependency thereof that hasn't already been."
|
|||
(straight-use-package (intern package))))
|
||||
(progn
|
||||
(doom--compile-site-packages)
|
||||
(doom--wait-for-compile-jobs)
|
||||
(doom--write-missing-eln-errors)
|
||||
(when NATIVECOMP
|
||||
(doom--wait-for-native-compile-jobs)
|
||||
(doom--write-missing-eln-errors))
|
||||
;; HACK Every time you save a file in a package that straight tracks,
|
||||
;; it is recorded in ~/.emacs.d/.local/straight/modified/.
|
||||
;; Typically, straight will clean these up after rebuilding, but
|
||||
|
@ -637,8 +642,7 @@ If ELPA-P, include packages installed with package.el (M-x package-install)."
|
|||
(if (not regraft-repos-p)
|
||||
(ignore (print! (info "Skipping regrafting")))
|
||||
(doom--cli-packages-regraft-repos repos-to-regraft))
|
||||
(when (and (require 'comp nil t)
|
||||
(native-comp-available-p))
|
||||
(when NATIVECOMP
|
||||
(if (not eln-p)
|
||||
(ignore (print! (info "Skipping native bytecode")))
|
||||
(doom--cli-packages-purge-eln))))))))
|
||||
|
|
35
core/core.el
35
core/core.el
|
@ -45,6 +45,7 @@ envvar will enable this at startup.")
|
|||
(defconst doom-interactive-p (not noninteractive)
|
||||
"If non-nil, Emacs is in interactive mode.")
|
||||
|
||||
(defconst NATIVECOMP (if (fboundp 'native-comp-available-p) (native-comp-available-p)))
|
||||
(defconst EMACS28+ (> emacs-major-version 27))
|
||||
(defconst IS-MAC (eq system-type 'darwin))
|
||||
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
||||
|
@ -155,43 +156,17 @@ users).")
|
|||
;;
|
||||
;;; Native Compilation support (http://akrl.sdf.org/gccemacs.html)
|
||||
|
||||
;; REVIEW Remove after a month
|
||||
(when EMACS28+
|
||||
(mapc (lambda (varset)
|
||||
(unless (boundp (car varset))
|
||||
(defvaralias (car varset) (cdr varset))))
|
||||
'((native-comp-deferred-compilation . comp-deferred-compilation)
|
||||
(native-comp-deferred-compilation-deny-list . comp-deferred-compilation-deny-list)
|
||||
(native-comp-eln-load-path . comp-eln-load-path)
|
||||
(native-comp-warning-on-missing-source . comp-warning-on-missing-source)
|
||||
(native-comp-driver-options . comp-native-driver-options)
|
||||
(native-comp-async-query-on-exit . comp-async-query-on-exit)
|
||||
(native-comp-async-report-warnings-errors . comp-async-report-warnings-errors)
|
||||
(native-comp-async-env-modifier-form . comp-async-env-modifier-form)
|
||||
(native-comp-async-all-done-hook . comp-async-all-done-hook)
|
||||
(native-comp-async-cu-done-functions . comp-async-cu-done-functions)
|
||||
(native-comp-async-jobs-number . comp-async-jobs-number)
|
||||
(native-comp-never-optimize-functions . comp-never-optimize-functions)
|
||||
(native-comp-bootstrap-deny-list . comp-bootstrap-deny-list)
|
||||
(native-comp-always-compile . comp-always-compile)
|
||||
(native-comp-verbose . comp-verbose)
|
||||
(native-comp-debug . comp-debug)
|
||||
(native-comp-speed . comp-speed)))
|
||||
|
||||
(when NATIVECOMP
|
||||
;; Don't store eln files in ~/.emacs.d/eln-cache (they are likely to be purged
|
||||
;; when upgrading Doom).
|
||||
(when (boundp 'native-comp-eln-load-path)
|
||||
(add-to-list 'native-comp-eln-load-path (concat doom-cache-dir "eln/"))))
|
||||
(add-to-list 'native-comp-eln-load-path (concat doom-cache-dir "eln/"))
|
||||
|
||||
(with-eval-after-load 'comp
|
||||
;; HACK Disable native-compilation for some troublesome packages
|
||||
(mapc (doom-partial #'add-to-list 'native-comp-deferred-compilation-deny-list)
|
||||
(let ((local-dir-re (concat "\\`" (regexp-quote doom-local-dir))))
|
||||
(list (concat "\\`" (regexp-quote doom-autoloads-file) "\\'")
|
||||
(concat local-dir-re ".*/evil-collection-vterm\\.el\\'")
|
||||
(concat local-dir-re ".*/with-editor\\.el\\'")
|
||||
;; https://github.com/nnicandro/emacs-jupyter/issues/297
|
||||
(concat local-dir-re ".*/jupyter-channel\\.el\\'")))))
|
||||
(list (concat local-dir-re ".*/evil-collection-vterm\\.el\\'")
|
||||
(concat local-dir-re ".*/with-editor\\.el\\'"))))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue