From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#47049: [feature/native] macro-expansion cycle when compiling comp.el Date: Fri, 12 Mar 2021 21:15:15 +0000 Message-ID: References: <83zgzbnm7i.fsf@gnu.org> <83pn07nfuc.fsf@gnu.org> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5959"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Zaretskii , 47049@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 12 22:16:10 2021 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 1lKp8j-0001Qz-Uc for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 22:16:09 +0100 Original-Received: from localhost ([::1]:37970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKp8j-0000s5-1B for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 16:16:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKp8c-0000qP-EQ for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:16:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKp8c-0004Av-6e for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lKp8c-0002ij-34 for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Mar 2021 21:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47049 X-GNU-PR-Package: emacs Original-Received: via spool by 47049-submit@debbugs.gnu.org id=B47049.161558372310397 (code B ref 47049); Fri, 12 Mar 2021 21:16:02 +0000 Original-Received: (at 47049) by debbugs.gnu.org; 12 Mar 2021 21:15:23 +0000 Original-Received: from localhost ([127.0.0.1]:58553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKp7z-0002hd-5p for submit@debbugs.gnu.org; Fri, 12 Mar 2021 16:15:23 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:62289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKp7u-0002hK-CC for 47049@debbugs.gnu.org; Fri, 12 Mar 2021 16:15:22 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 12CLFFBL024732 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Fri, 12 Mar 2021 21:15:15 GMT In-Reply-To: (Stefan Monnier's message of "Fri, 12 Mar 2021 16:05:57 -0500") 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" Xref: news.gmane.io gmane.emacs.bugs:202210 Archived-At: Stefan Monnier writes: >>>>> > I made some local modifications in comp.el, and used that modified >>>>> > comp.el for a while (by loading it manually at run time) to debug some >>>>> > problem. Then I undid those local modifications of comp.el (by saying >>>>> > "git checkout") and said "make" to rebuild Emacs. And I see this: >>>>> > >>>>> > ELC emacs-lisp/comp.elc >>>>> > Warning: Eager macro-expansion skipped due to cycle: >>>>> > => (load "comp.el") => (macroexpand-all (defalias 'comp-add-call-cstr )) => (macroexpand (comp-loop-insn-in-block )) => (load "comp.el") >>>>> > >>>>> > Why does this happen? >>>>> >>>>> I'm not sure, but I can reproduce it. >>>>> >>>>> I guess (just a guess) it might be because `comp-add-call-cstr' is using >>>>> a macro `comp-loop-insn-in-block' that is expanding with a >>>>> `cl-symbol-macrolet' inside? (no idea why this should be a problem). >>>>> >>>>> > could it be that while comp.el was modified it >>>>> > got native-compiled, and now that inconsistent comp.eln gets in the >>>>> > way? >>>>> >>>>> I think this has not to do specifically with native compilation. >>>>> >>>>> I see it goes away removing '(setq load-prefer-newer t)' from the >>>>> invocation tho. >>>>> >>>>> Perhaps somebody already more into the macro expansion business might >>>>> have some suggestion. >>>> >>>> Stefan, can you help, please? >>> >>> Nothing jumps at me by looking at the code. I'll have to look at the >>> actual complete stacktrace I think. >> >> Cool didn't know was so easy to generate backtraces to debug this kind >> of issues. At the bottom I attached the backtrace I produced and had a >> look into. >> >> IIUC while *loading* "comp.el" we try to advice `macroexpand' and >> consequentially we try to install a trampoline (was already compiled) >> for `macroexpand', this is supposed to be done by >> `comp-subr-trampoline-install' requiring "comp.el" to be loaded again! >> >> Assuming my analysis is correct I'm not sure what's the best work around >> for this condition. WDYT? > > Does the circularity cause problems later on? > [ As you can see above, this cyclic expansion problem only results in > a warning rather than an error: the eager macroexpansion fails, but > that just means we fallback on lazy macroexpansion instead. ] I'm not aware of any functional problem except the aesthetic of the warning emitted. > If so, then let's first focus on solving that problem. > > And if not, then it's probably a good idea to understand why the > problem doesn't show up when the macroexpansion happens lazily: > is it because we just don't go through that cl-symbol-macrolet while > compiling the trampoline? Yes I think that's the case. > Maybe you can guess my opinion on the best solution: pre-compile all the > trampoline we may need (and ideally only one trampoline per > number-of-arguments, more or less) ;-) :) > But maybe a simpler solution is to move the definition of > `comp-subr-trampoline-install` earlier in the file (before the first > use of `comp-loop-insn-in-block`)? Yep that's what I attemped and reported in the other mail, I guess our mails crossed over the ocean. Thanks! Andrea