aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2023-07-13 20:11:55 -0400
committerStefan Monnier2023-07-13 20:13:32 -0400
commitfcade74066d82625e367c561a34971f52cf46a61 (patch)
treec496c261380a248d39bcc74a144aba38bd94e47e /lisp
parent3ffb99f28f29cd98094f359ea316468572535aa0 (diff)
downloademacs-fcade74066d82625e367c561a34971f52cf46a61.tar.gz
emacs-fcade74066d82625e367c561a34971f52cf46a61.zip
src/comp.c: Use `pending_funcalls` to fix bug#64494
Make sure `comp.el` is never loaded synchronously by simply delaying all calls to `native--compile-async` via `pending_funcalls`. * lisp/startup.el (comp--compilable, comp--delayed-sources): Don't declare. (startup--require-comp-safely) (startup--honor-delayed-native-compilations): Delete functions. (normal-top-level): Don't call `startup--honor-delayed-native-compilations`. * src/comp.c (maybe_defer_native_compilation): Use `pending_funcalls`. (syms_of_comp): Delete `Vcomp__delayed_sources` and `comp__compilable`. Define `Qnative__compile_async`.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/comp.el1
-rw-r--r--lisp/startup.el24
2 files changed, 2 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 22fb08e4688..5f5e7f26446 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -4226,6 +4226,7 @@ LOAD and SELECTOR work as described in `native--compile-async'."
4226 (string-match-p re file)) 4226 (string-match-p re file))
4227 native-comp-jit-compilation-deny-list)))) 4227 native-comp-jit-compilation-deny-list))))
4228 4228
4229;;;###autoload
4229(defun native--compile-async (files &optional recursively load selector) 4230(defun native--compile-async (files &optional recursively load selector)
4230 ;; BEWARE, this function is also called directly from C. 4231 ;; BEWARE, this function is also called directly from C.
4231 "Compile FILES asynchronously. 4232 "Compile FILES asynchronously.
diff --git a/lisp/startup.el b/lisp/startup.el
index 5a389294e78..7f601668369 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -520,27 +520,6 @@ DIRS are relative."
520 xdg-dir) 520 xdg-dir)
521 (t emacs-d-dir)))) 521 (t emacs-d-dir))))
522 522
523(defvar comp--compilable)
524(defvar comp--delayed-sources)
525(defun startup--require-comp-safely ()
526 "Require the native compiler avoiding circular dependencies."
527 (when (featurep 'native-compile)
528 ;; Require comp with `comp--compilable' set to nil to break
529 ;; circularity.
530 (let ((comp--compilable nil))
531 (require 'comp))
532 (native--compile-async comp--delayed-sources nil 'late)
533 (setq comp--delayed-sources nil)))
534
535(declare-function native--compile-async "comp.el"
536 (files &optional recursively load selector))
537(defun startup--honor-delayed-native-compilations ()
538 "Honor pending delayed deferred native compilations."
539 (when (and (native-comp-available-p)
540 comp--delayed-sources)
541 (startup--require-comp-safely))
542 (setq comp--compilable t))
543
544(defvar native-comp-eln-load-path) 523(defvar native-comp-eln-load-path)
545(defvar native-comp-jit-compilation) 524(defvar native-comp-jit-compilation)
546(defvar native-comp-enable-subr-trampolines) 525(defvar native-comp-enable-subr-trampolines)
@@ -846,8 +825,7 @@ It is the default value of the variable `top-level'."
846 nil))) 825 nil)))
847 (setq env (cdr env))))) 826 (setq env (cdr env)))))
848 (when display 827 (when display
849 (setq process-environment (delete display process-environment))))) 828 (setq process-environment (delete display process-environment))))))
850 (startup--honor-delayed-native-compilations))
851 829
852;; Precompute the keyboard equivalents in the menu bar items. 830;; Precompute the keyboard equivalents in the menu bar items.
853;; Command-line options supported by tty's: 831;; Command-line options supported by tty's: