From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: German Pacenza <germanp82@hotmail.com>,
64494@debbugs.gnu.org, Andrea Corallo <acorallo@gnu.org>
Subject: bug#64494: 30.0.50; Recursive load error with native-compile
Date: Fri, 07 Jul 2023 13:02:55 -0400 [thread overview]
Message-ID: <jwvedljwu78.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83ttuhgjpg.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 06 Jul 2023 18:09:47 +0300")
> Andrea, Stefan: any ideas for how to allow emacs-lisp-compilation-mode
> in async compilation buffers without triggering this recursive-load
> nastiness?
I'm wondering if instead of having the C code do:
/* 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);
we shouldn't just do something like
pending_funcalls
= Fcons (list (Qnative__compile_async, src, Qnil, Qlate),
pending_funcalls);
I.e. never call native--compile-async synchronously.
The patch below seems to work so far, tho I haven't tried bootstrapping yet.
Stefan
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 77584b692a4..4892733d456 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -4230,6 +4230,7 @@ native-compile-async-skip-p
(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 @@ startup--xdg-or-homedot
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 @@ normal-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..003bec38efa 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);
}
\f
@@ -5798,6 +5790,8 @@ syms_of_comp (void)
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);
next prev parent reply other threads:[~2023-07-07 17:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 11:45 bug#64494: 30.0.50; Recursive load error with native-compile German Pacenza
2023-07-06 15:09 ` Eli Zaretskii
2023-07-07 17:02 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-07-07 18:23 ` Eli Zaretskii
2023-07-07 20:18 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 1:22 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-14 1:29 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvedljwu78.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=64494@debbugs.gnu.org \
--cc=acorallo@gnu.org \
--cc=eliz@gnu.org \
--cc=germanp82@hotmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).