[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 536a57b72c: Fix potential native compiler circular dependencies d
From: |
Andrea Corallo |
Subject: |
master 536a57b72c: Fix potential native compiler circular dependencies during load |
Date: |
Thu, 27 Jan 2022 17:20:33 -0500 (EST) |
branch: master
commit 536a57b72ce11b1bb8d1b34b339424fea6ccbcce
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Fix potential native compiler circular dependencies during load
* lisp/startup.el (startup--require-comp-safetly): New function.
(startup--honor-delayed-native-compilations): Make use of
`startup--require-comp-safetly'.
* src/comp.c (CALL0I): New define.
(maybe_defer_native_compilation): Make use of
`startup--require-comp-safetly'.
---
lisp/startup.el | 26 +++++++++++++++-----------
src/comp.c | 6 +++++-
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/lisp/startup.el b/lisp/startup.el
index 05d829396d..856d600e38 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -519,22 +519,26 @@ DIRS are relative."
xdg-dir)
(t emacs-d-dir))))
-(defvar comp--delayed-sources)
(defvar comp--loadable)
+(defvar comp--delayed-sources)
+(defun startup--require-comp-safetly ()
+ "Require the native compiler avoiding circular dependencies."
+ (unless (featurep 'comp)
+ ;; Require comp with `comp--loadable' set to nil to break
+ ;; circularity.
+ (let ((comp--loadable 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."
- (if (and (native-comp-available-p)
- comp--delayed-sources)
- (progn
- ;; Require comp before setting `comp--loadable' to break
- ;; circularity.
- (require 'comp)
- (setq comp--loadable t)
- (native--compile-async comp--delayed-sources nil 'late)
- (setq comp--delayed-sources nil))
- (setq comp--loadable t)))
+ (when (and (native-comp-available-p)
+ comp--delayed-sources)
+ (startup--require-comp-safetly))
+ (setq comp--loadable t))
(defvar native-comp-eln-load-path)
(defun normal-top-level ()
diff --git a/src/comp.c b/src/comp.c
index d755df802f..66288988fd 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -480,6 +480,10 @@ load_gccjit_if_necessary (bool mandatory)
#define THIRD(x) \
XCAR (XCDR (XCDR (x)))
+/* Like call0 but stringify and intern. */
+#define CALL0I(fun) \
+ CALLN (Ffuncall, intern_c_string (STR (fun)))
+
/* Like call1 but stringify and intern. */
#define CALL1I(fun, arg) \
CALLN (Ffuncall, intern_c_string (STR (fun)), arg)
@@ -5128,7 +5132,7 @@ maybe_defer_native_compilation (Lisp_Object function_name,
if (comp__loadable)
{
/* Startup is done, comp is usable. */
- Frequire (Qcomp, Qnil, Qnil);
+ CALL0I(startup--require-comp-safetly);
Fputhash (function_name, definition, Vcomp_deferred_pending_h);
CALLN (Ffuncall, intern_c_string ("native--compile-async"),
src, Qnil, Qlate);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 536a57b72c: Fix potential native compiler circular dependencies during load,
Andrea Corallo <=