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#50869: 28.0.50; tramp: void-function tramp-file-name-method--cmacro Date: Fri, 02 Sep 2022 14:52:27 -0400 Message-ID: References: <87tuhzcrje.fsf@gmx.de> <87pmlydvd4.fsf@gmx.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38948"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: shuguang79@qq.com, 50869@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 02 20:53:13 2022 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 1oUBmy-0009v3-IN for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Sep 2022 20:53:12 +0200 Original-Received: from localhost ([::1]:38768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUBmx-0002Sd-Lu for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Sep 2022 14:53:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUBmo-0002RI-G9 for bug-gnu-emacs@gnu.org; Fri, 02 Sep 2022 14:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUBmo-0000jo-6O for bug-gnu-emacs@gnu.org; Fri, 02 Sep 2022 14:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUBmo-00016F-0q for bug-gnu-emacs@gnu.org; Fri, 02 Sep 2022 14:53: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, 02 Sep 2022 18:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50869 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 50869-submit@debbugs.gnu.org id=B50869.16621447614199 (code B ref 50869); Fri, 02 Sep 2022 18:53:01 +0000 Original-Received: (at 50869) by debbugs.gnu.org; 2 Sep 2022 18:52:41 +0000 Original-Received: from localhost ([127.0.0.1]:40386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUBmS-00015f-OO for submit@debbugs.gnu.org; Fri, 02 Sep 2022 14:52:41 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:14073) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUBmQ-00015S-SP for 50869@debbugs.gnu.org; Fri, 02 Sep 2022 14:52:39 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DDF8380CFA; Fri, 2 Sep 2022 14:52:31 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1C21780508; Fri, 2 Sep 2022 14:52:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1662144750; bh=zquUIlcA/yT5ePNzrknls2VFfSyMl00WEabCFlzcjlc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=R31VH/EwajSgF/rBBjr/CL9cqWT5mthyaOm+OydpWFtazwk0FRizVGbMaxOid5YMG BH0NLZ4N12G4nu3YkoWdJ+CSHgbfNgIq+0BKHp9BtnliRBBblDH1qrFhYd93cNIE0Y lTYfXlbtOW1LkYkkv0mpLj5q6Eako7nohPC4DYA+Bjjd2trcgfBm4U2j3nS9Mugwpc KGCui377HJ3RbcRBd3HrrEawfS1z+0DVuWTJoAdiYdYatIt56hAZzym2KdyX1xMaoR Av2tS4JMOFj6ghuJ44MA3GbYnzQzsAVl/GvlWCk1zLioWL1R7bm79IiaA1xC33HSAg VBjF4N3PF0Tow== Original-Received: from pastel (unknown [157.52.9.190]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3096112076C; Fri, 2 Sep 2022 14:52:29 -0400 (EDT) In-Reply-To: <87pmlydvd4.fsf@gmx.de> (Michael Albinus's message of "Sun, 03 Apr 2022 17:44:55 +0200") 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:241353 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus [2022-04-03 17:44:55] wrote: > Stefan Monnier writes: >> Note: this is not a compile error. It's an error that happened during >> expansion of a compiler-macro. These are optional, so those errors only >> affect the performance of the code but shouldn't affect its behavior. >> >> IOW this sound more serious than it is. >> >> `tramp-file-name-method--cmacro` is supposed to be a function which >> inlines the code of calls to `tramp-file-name-method`. >> >> More specifically `tramp-file-name-method--cmacro` is auto-generated >> (and put on the `compiler-macro` property of the >> `tramp-file-name-method` symbol) by the `cl-defsubst` used to define >> `tramp-file-name-method`. >> >> So I guess the source of the error is that unloading `tramp` undefines >> the functions (both `tramp-file-name-method--cmacro` and >> `tramp-file-name-method`) but leaves the `compiler-macro` property of the >> `tramp-file-name-method` symbol. >> >> We really should make it so package unloading knows how to undo >> top-level `put`s. > > Honestly, I have no knowledge about the byte-compiler. I've reopened the > bug, so you can work on it. The main point is that putting the `cl-defstruct` into the `tramp-loaddefs.el` is really ugly and I think it's asking for trouble. In contrast the OP's "errors" aren't actual errors, they're just messages indicating that some optimization could not be applied. We should really change the wording to clarify that they're warnings. (see first hunk in patch below). But in the mean time I'd much rather live with a harmless "compiler-macro error" message than with a `cl-defstruct` in a loaddefs file. Lars Ingebrigtsen [2022-09-02 13:43:48] wrote: > Stefan Monnier writes: >> We really should make it so package unloading knows how to undo >> top-level `put`s. > Do you have any ideas for how to do that? There are a few ways: - We could let `unload-feature` remove compiler macros when present, as in the second hunk of the patch below. - We could make `cl-defstruct` use `define-symbol-prop` rather than `put`, as in the third hunk of the patch below. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=comp-macro.patch diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index c3ba1b36d44..f4df40249de 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -110,7 +110,8 @@ macroexp--compiler-macro (let ((symbols-with-pos-enabled t)) (apply handler form (cdr form))) (error - (message "Compiler-macro error for %S: Handler: %S\n%S" (car form) handler err) + (message "Warning: Optimization failure for %S: Handler: %S\n%S" + (car form) handler err) form))) (defun macroexp--funcall-if-compiled (_form) diff --git a/lisp/loadhist.el b/lisp/loadhist.el index b4ed0432465..76da002314b 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -171,6 +171,8 @@ loadhist-unload-element (cond ((null hist) (defalias fun nil) + (if (get fun 'compiler-macro) (put fun 'compiler-macro nil)) + (if (get fun 'gv-expander) (put fun 'gv-expander nil)) ;; Override the change that `defalias' just recorded. (put fun 'function-history nil)) ((equal (car hist) loadhist-unload-filename) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 80ca43c902a..b7fee7a3487 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -3570,7 +3570,7 @@ cl-define-compiler-macro (cl-defun ,fname ,(if (memq '&whole args) (delq '&whole args) (cons '_cl-whole-arg args)) ,@body) - (put ',func 'compiler-macro #',fname)))) + (define-symbol-prop ',func 'compiler-macro #',fname)))) ;;;###autoload (defun cl-compiler-macroexpand (form) --=-=-=--