GNU bug report logs - #50569
28.0.50; [native-comp] emacs-lisp-native-compile-and-load does not load require'd files before compiling

Previous Next

Package: emacs;

Reported by: Adam Porter <adam <at> alphapapa.net>

Date: Mon, 13 Sep 2021 13:42:02 UTC

Severity: normal

Tags: moreinfo

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50569 in the body.
You can then email your comments to 50569 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50569; Package emacs. (Mon, 13 Sep 2021 13:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adam Porter <adam <at> alphapapa.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 13 Sep 2021 13:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Adam Porter <adam <at> alphapapa.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; [native-comp] emacs-lisp-native-compile-and-load does not
 load require'd files before compiling
Date: Mon, 13 Sep 2021 08:41:13 -0500
#+TITLE: Native-comp macro-defining macro bug

Hi Andrea, et al,

This provides a way to reproduce a bug I seem to have found in the
native-comp feature in this Emacs version:

: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.5, cairo version 1.16.0) of 2021-09-06

* Summary

The function ~emacs-lisp-native-compile-and-load~ does not seem to
ensure that macros defined in a ~require~'d file are defined before
compiling the current buffer.

* Steps to reproduce

1. In an empty directory:

   a. Make file =foo.el= with these contents:

#+begin_src elisp
(defmacro foo-define-definer (name prefix)
  `(defmacro ,name (name args &rest body)
     (let ((function-name (intern (concat ,prefix "-" (symbol-name name)))))
       `(defun ,function-name ,args ,@body))))

(provide 'foo)
#+end_src

   b. Make file =bar.el= with these contents:

#+begin_src elisp
(require 'foo)

(foo-define-definer bar-define-key "bar-key")

(bar-define-key baz (&rest args)
  (message "%S" args))

(bar-key-baz 'ARG)
#+end_src

2. ~(push default-directory load-path)~.

3. ~(find-file "bar.el")~.

4. =M-x emacs-lisp-native-compile-and-load RET=.

*Expected results:*
+ Compilation succeeds without errors or warnings.
+ Macro ~bar-define-key~ is defined.
+ Function ~bar-key-baz~ is defined.

*Actual results:* Neither the macro nor the function are defined, and
these warnings are displayed in =*Compile-Log*=:

#+begin_example
Compiling file /home/me/src/emacs/misc/ecms/native-comp-macro-defining-macro-bug/bar.el
at Mon Sep 13 13:16:46 2021
bar.el:3:21: Warning: reference to free variable ‘bar-define-key’
bar.el:5:17: Warning: reference to free variable ‘baz’
bar.el:5:28: Warning: reference to free variable ‘args’

In end of data:
bar.el:8:2: Warning: the function ‘bar-key-baz’ is not known to be defined.
bar.el:5:22: Warning: the function ‘&rest’ is not known to be defined.
bar.el:5:2: Warning: the function ‘bar-define-key’ is not known to be defined.
bar.el:3:2: Warning: the function ‘foo-define-definer’ is not known to be
    defined.
#+end_example

* Additional notes

+ If ~emacs-lisp-byte-compile-and-load~ is called before
~emacs-lisp-native-compile-and-load~, the native compilation succeeds
without errors or warnings, and the macro and function are defined.

-- 
Thanks,
Adam




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50569; Package emacs. (Thu, 25 Aug 2022 15:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 50569 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Adam Porter <adam <at> alphapapa.net>
Cc: 50569 <at> debbugs.gnu.org
Subject: Re: bug#50569: 28.0.50; [native-comp]
 emacs-lisp-native-compile-and-load does not load require'd files before
 compiling
Date: Thu, 25 Aug 2022 17:16:07 +0200
Adam Porter <adam <at> alphapapa.net> writes:

> *Expected results:*
> + Compilation succeeds without errors or warnings.
> + Macro ~bar-define-key~ is defined.
> + Function ~bar-key-baz~ is defined.
>
> *Actual results:* Neither the macro nor the function are defined, and
> these warnings are displayed in =*Compile-Log*=:

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I'm unable to reproduce this problem in Emacs 29 -- do you still see
this problem with the current master?




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 25 Aug 2022 15:17:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50569; Package emacs. (Thu, 25 Aug 2022 22:06:02 GMT) Full text and rfc822 format available.

Message #13 received at 50569 <at> debbugs.gnu.org (full text, mbox):

From: Adam Porter <adam <at> alphapapa.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50569 <at> debbugs.gnu.org
Subject: Re: bug#50569: 28.0.50; [native-comp]
 emacs-lisp-native-compile-and-load does not load require'd files before
 compiling
Date: Thu, 25 Aug 2022 17:05:52 -0500
Hi Lars,

Thanks for following up on this.

On 8/25/22 10:16, Lars Ingebrigtsen wrote:
> Adam Porter <adam <at> alphapapa.net> writes:
> 
>> *Expected results:* + Compilation succeeds without errors or 
>> warnings. + Macro ~bar-define-key~ is defined. + Function 
>> ~bar-key-baz~ is defined.
>> 
>> *Actual results:* Neither the macro nor the function are defined, 
>> and these warnings are displayed in =*Compile-Log*=:
> 
> (I'm going through old bug reports that unfortunately weren't 
> resolved at the time.)
> 
> I'm unable to reproduce this problem in Emacs 29 -- do you still see 
> this problem with the current master?

I'm afraid I don't have time to test that myself right now.  If you were
unable to reproduce it with the recipe I provided, I'd guess that it's
been solved in version 29.

If it's possible to backport a fix to version 28, that would be
good, because if that version ends up being included in various
distributions and used for years, it would mean that Emacs packages
could have to workaround this problem for years as well.  (Or, of
course, they could declare Emacs 29 as the minimum required version,
which will lead users on version 28 to complain...you know the drill.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50569; Package emacs. (Fri, 26 Aug 2022 11:00:02 GMT) Full text and rfc822 format available.

Message #16 received at 50569 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Adam Porter <adam <at> alphapapa.net>
Cc: 50569 <at> debbugs.gnu.org
Subject: Re: bug#50569: 28.0.50; [native-comp]
 emacs-lisp-native-compile-and-load does not load require'd files before
 compiling
Date: Fri, 26 Aug 2022 12:59:12 +0200
Adam Porter <adam <at> alphapapa.net> writes:

> I'm afraid I don't have time to test that myself right now.  If you were
> unable to reproduce it with the recipe I provided, I'd guess that it's
> been solved in version 29.
>
> If it's possible to backport a fix to version 28, that would be
> good,

I can't reproduce it in Emacs 28, either, so I guess this was fixed
before the release.

So I'm closing this bug report, but if you see still see this (perhaps
there's something missing in the recipe or something), please respond to
the debbugs address and we'll reopen.




bug marked as fixed in version 28.1, send any further explanations to 50569 <at> debbugs.gnu.org and Adam Porter <adam <at> alphapapa.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 26 Aug 2022 11:00:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Sep 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 209 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.