GNU bug report logs - #14551
compiler fails to track eval-when-compile in required files

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Mon, 3 Jun 2013 20:33:02 UTC

Severity: minor

Found in version 24.3

To reply to this bug, email your comments to 14551 AT debbugs.gnu.org.

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#14551; Package emacs. (Mon, 03 Jun 2013 20:33:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: compiler fails to track eval-when-compile in required files
Date: Mon, 03 Jun 2013 16:30:27 -0400
Package: emacs
Severity: minor
Version: 24.3

(I guess this issue has always been present.)

Suppose we have three files:


foo.el:
(require 'lib)
(defun foo ()
  (lib2-func))


lib.el:
(eval-when-compile
  (require 'lib2))
(provide 'lib)


lib2.el:
(defun lib2-func ()
  t)
(provide 'lib2)


rm lib*.elc
emacs -Q -L . -batch -f batch-byte-compile foo.el

produces no warnings.

If lib.el is compiled first though:
emacs -Q -L . -batch -f batch-byte-compile lib.el
emacs -Q -L . -batch -f batch-byte-compile foo.el

In end of data:
foo.el:6:1:Warning: the function `lib2-func' is not known to be defined.


eval-when-compile is equivalent to progn in uncompiled code, and the
compiler doesn't compile things brought in by require.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14551; Package emacs. (Mon, 03 Jun 2013 21:02:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14551 <at> debbugs.gnu.org
Subject: Re: bug#14551: compiler fails to track eval-when-compile in required
	files
Date: Mon, 03 Jun 2013 16:59:07 -0400
> foo.el:
> (require 'lib)
> (defun foo ()
>   (lib2-func))
[...]
> lib.el:
> (eval-when-compile
>   (require 'lib2))
> (provide 'lib)
[...]
> rm lib*.elc
> emacs -Q -L . -batch -f batch-byte-compile foo.el
> produces no warnings.

Yes, that's a long standing bug.  Fixing it right is likely to be pretty
tricky/difficult because it means we need to disregard some of the
packages already loaded somehow.  In the general case, you have the same
problem even without eval-when-compile, e.g. if you have in lib.el
a call to an autoloaded macro, in which case the autoloaded package will
be loaded if lib.el is not yet compiled but not if it is.

The "noruntime" warnings are implemented with a pile of hacks, and I'd
rather not add to them.  So, given that a proper fix looks pretty
difficult, I wouldn't hold my breath.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14551; Package emacs. (Wed, 10 Jan 2024 11:18:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 14551 <at> debbugs.gnu.org
Subject: Re: bug#14551: compiler fails to track eval-when-compile in required
 files
Date: Wed, 10 Jan 2024 03:17:05 -0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> foo.el:
>> (require 'lib)
>> (defun foo ()
>>   (lib2-func))
> [...]
>> lib.el:
>> (eval-when-compile
>>   (require 'lib2))
>> (provide 'lib)
> [...]
>> rm lib*.elc
>> emacs -Q -L . -batch -f batch-byte-compile foo.el
>> produces no warnings.
>
> Yes, that's a long standing bug.  Fixing it right is likely to be pretty
> tricky/difficult because it means we need to disregard some of the
> packages already loaded somehow.  In the general case, you have the same
> problem even without eval-when-compile, e.g. if you have in lib.el
> a call to an autoloaded macro, in which case the autoloaded package will
> be loaded if lib.el is not yet compiled but not if it is.
>
> The "noruntime" warnings are implemented with a pile of hacks, and I'd
> rather not add to them.  So, given that a proper fix looks pretty
> difficult, I wouldn't hold my breath.

Is still an issue 10 years later?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14551; Package emacs. (Fri, 12 Jan 2024 15:58:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 14551 <at> debbugs.gnu.org
Subject: Re: bug#14551: compiler fails to track eval-when-compile in
 required files
Date: Fri, 12 Jan 2024 10:57:03 -0500
> Is still an issue 10 years later?

I don't think anything has changed in this respect.


        Stefan





This bug report was last modified 110 days ago.

Previous Next


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