From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#47049: [feature/native] macro-expansion cycle when compiling comp.el Date: Fri, 12 Mar 2021 16:05:57 -0500 Message-ID: References: <83zgzbnm7i.fsf@gnu.org> <83pn07nfuc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5703"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47049@debbugs.gnu.org To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 12 22:07:14 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 1lKp05-0001MS-JS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 22:07:13 +0100 Original-Received: from localhost ([::1]:33984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKp04-0003Gp-Iy for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 16:07:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKozu-0003GV-I0 for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKozu-0008S7-Aa for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lKozu-0002Rp-4M for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 16:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Mar 2021 21:07: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.16155831719337 (code B ref 47049); Fri, 12 Mar 2021 21:07:02 +0000 Original-Received: (at 47049) by debbugs.gnu.org; 12 Mar 2021 21:06:11 +0000 Original-Received: from localhost ([127.0.0.1]:58535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKoz5-0002QX-CM for submit@debbugs.gnu.org; Fri, 12 Mar 2021 16:06:11 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46995) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKoz1-0002Q1-1I for 47049@debbugs.gnu.org; Fri, 12 Mar 2021 16:06:10 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 80335100263; Fri, 12 Mar 2021 16:06:01 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 55E4610005D; Fri, 12 Mar 2021 16:05:59 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1615583159; bh=3JUXWrR9HH11foaHH9MmZ8xeebqJE3Pow6l/ivHApno=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=YNX52JRmbgkU9cqknyS2dSQh5IYdCG9DvmQ4tjWJApdblDfwH6gy/rg8z+a1PMbIo ejxb9t0yZbjXNXjoxWJpb2wwon0gGZNIMhWZ5vbehH6zpKY+kqE8/s46vm5Kn3TInR eJ6hXF3VXm3LODHoDWwmjsLosvZMhm2oaDAasupQg6J+5CkK9rKpVIAB89uOJ+PolT my6dq/PwtT6jJ2Cb5xN58fe93HG6QhuBJQVYmykVNz/v1aW6vPyXXUNkfye97pywfl 0Am/xPRppmGc2ZQ1IQzBpUKnCodI4Lg1d26UY48XfesGeZkEp/2l55LY4UK1H5g6ko OpsBUTzwhFXxQ== Original-Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1AA731201AA; Fri, 12 Mar 2021 16:05:59 -0500 (EST) In-Reply-To: (Andrea Corallo's message of "Fri, 12 Mar 2021 20:02:25 +0000") 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:202208 Archived-At: >>>> > 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. ] 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? 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`)? Stefan