From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64494: 30.0.50; Recursive load error with native-compile Date: Fri, 07 Jul 2023 13:02:55 -0400 Message-ID: References: <83ttuhgjpg.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22068"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: German Pacenza , 64494@debbugs.gnu.org, Andrea Corallo To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 07 19:04:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qHosK-0005UH-62 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Jul 2023 19:04:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHosF-0003z6-Aa; Fri, 07 Jul 2023 13:04:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHosE-0003yx-Il for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 13:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHosE-0004F8-9s for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 13:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qHosE-0004IB-6G for bug-gnu-emacs@gnu.org; Fri, 07 Jul 2023 13:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jul 2023 17:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64494 X-GNU-PR-Package: emacs Original-Received: via spool by 64494-submit@debbugs.gnu.org id=B64494.168874938716437 (code B ref 64494); Fri, 07 Jul 2023 17:04:02 +0000 Original-Received: (at 64494) by debbugs.gnu.org; 7 Jul 2023 17:03:07 +0000 Original-Received: from localhost ([127.0.0.1]:43692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHorK-0004H3-PD for submit@debbugs.gnu.org; Fri, 07 Jul 2023 13:03:07 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:29367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHorH-0004GR-2g for 64494@debbugs.gnu.org; Fri, 07 Jul 2023 13:03:05 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CEEDC100194; Fri, 7 Jul 2023 13:02:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 91FA210011D; Fri, 7 Jul 2023 13:02:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1688749376; bh=9k8ZkSxud0T6lJGf00Sw2/mD9mjkpFV3CicaYV4uxdU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=SD7aK7Uq80IOIhDCDDLsoh1a9M6I9dgVU6kAIG4XtFYA4yNlF5h9vy6H1oY0ymUn/ +IkE8TCzAHUu46mESQH6S/jGEk6e1Ik1gp5EWPAKHVjuZE1u3AstG7XNToQgLMSkmW pha5Ns9IhXWnJHBi1S0QOSVFowmiivatqshlowOzrZrMSFrN1bUBx8++QiU+3J69r1 iXT3LGaB/c3zzkbiYiM3hfeSfzZt5sedLP+iK6Ypd+UnlR2lerAq4MwIC6Mg4k6n/Z t7zA+jdZMOdCZzjNXaoosgTFuuOyrrW1Zg5bS4ybGaiKR79gflfSpBx7wWt0Og+KOd THBBy0qx9jsDg== Original-Received: from pastel (69-165-155-162.dsl.teksavvy.com [69.165.155.162]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6651C12027A; Fri, 7 Jul 2023 13:02:56 -0400 (EDT) In-Reply-To: <83ttuhgjpg.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 06 Jul 2023 18:09:47 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264738 Archived-At: > 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); } @@ -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);