[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master fcade74066d 1/2: src/comp.c: Use `pending_funcalls` to fix bug#64
From: |
Stefan Monnier |
Subject: |
master fcade74066d 1/2: src/comp.c: Use `pending_funcalls` to fix bug#64494 |
Date: |
Thu, 13 Jul 2023 21:28:55 -0400 (EDT) |
branch: master
commit fcade74066d82625e367c561a34971f52cf46a61
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
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`.
---
lisp/emacs-lisp/comp.el | 1 +
lisp/startup.el | 24 +-----------------------
src/comp.c | 23 +++++------------------
3 files changed, 7 insertions(+), 41 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'."
(string-match-p re file))
native-comp-jit-compilation-deny-list))))
+;;;###autoload
(defun native--compile-async (files &optional recursively load selector)
;; BEWARE, this function is also called directly from C.
"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."
xdg-dir)
(t emacs-d-dir))))
-(defvar comp--compilable)
-(defvar comp--delayed-sources)
-(defun startup--require-comp-safely ()
- "Require the native compiler avoiding circular dependencies."
- (when (featurep 'native-compile)
- ;; Require comp with `comp--compilable' set to nil to break
- ;; circularity.
- (let ((comp--compilable nil))
- (require 'comp))
- (native--compile-async comp--delayed-sources nil 'late)
- (setq comp--delayed-sources nil)))
-
-(declare-function native--compile-async "comp.el"
- (files &optional recursively load selector))
-(defun startup--honor-delayed-native-compilations ()
- "Honor pending delayed deferred native compilations."
- (when (and (native-comp-available-p)
- comp--delayed-sources)
- (startup--require-comp-safely))
- (setq comp--compilable t))
-
(defvar native-comp-eln-load-path)
(defvar native-comp-jit-compilation)
(defvar native-comp-enable-subr-trampolines)
@@ -846,8 +825,7 @@ It is the default value of the variable `top-level'."
nil)))
(setq env (cdr env)))))
(when display
- (setq process-environment (delete display process-environment)))))
- (startup--honor-delayed-native-compilations))
+ (setq process-environment (delete display process-environment))))))
;; Precompute the keyboard equivalents in the menu bar items.
;; Command-line options supported by tty's:
diff --git a/src/comp.c b/src/comp.c
index 013ac6358c1..3c63cad18c7 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -5199,17 +5199,9 @@ maybe_defer_native_compilation (Lisp_Object
function_name,
Fputhash (function_name, definition, Vcomp_deferred_pending_h);
- /* This is so deferred compilation is able to compile comp
- dependencies breaking circularity. */
- if (comp__compilable)
- {
- /* Startup is done, comp is usable. */
- CALL0I (startup--require-comp-safely);
- CALLN (Ffuncall, intern_c_string ("native--compile-async"),
- src, Qnil, Qlate);
- }
- else
- Vcomp__delayed_sources = Fcons (src, Vcomp__delayed_sources);
+ pending_funcalls
+ = Fcons (list (Qnative__compile_async, src, Qnil, Qlate),
+ pending_funcalls);
}
@@ -5674,13 +5666,6 @@ void
syms_of_comp (void)
{
#ifdef HAVE_NATIVE_COMP
- DEFVAR_LISP ("comp--delayed-sources", Vcomp__delayed_sources,
- doc: /* List of sources to be native-compiled when startup is finished.
-For internal use. */);
- DEFVAR_BOOL ("comp--compilable", comp__compilable,
- doc: /* Non-nil when comp.el can be native compiled.
-For internal use. */);
- /* Compiler control customizes. */
DEFVAR_BOOL ("native-comp-jit-compilation", native_comp_jit_compilation,
doc: /* If non-nil, compile loaded .elc files asynchronously.
@@ -5798,6 +5783,8 @@ natively-compiled one. */);
build_pure_c_string ("eln file inconsistent with current runtime "
"configuration, please recompile"));
+ DEFSYM (Qnative__compile_async, "native--compile-async");
+
defsubr (&Scomp__subr_signature);
defsubr (&Scomp_el_to_eln_rel_filename);
defsubr (&Scomp_el_to_eln_filename);