unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Odd warning about `customize-variable'
@ 2022-05-11 10:57 Lars Ingebrigtsen
  2022-05-11 21:22 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-11 10:57 UTC (permalink / raw)
  To: emacs-devel

I don't know when this started, but I'm seeing one oddball warning when
building Emacs now:

In end of data:
org/org.el:15523:6: Warning: the function `customize-variable' might not be defined at runtime.

This is odd, because loaddefs has:

(defalias 'customize-variable 'customize-option)
(autoload 'customize-option "cus-edit" "\

So that alias (and that function it points to) should always be defined.

Anybody know what might be going on?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Odd warning about `customize-variable'
  2022-05-11 10:57 Odd warning about `customize-variable' Lars Ingebrigtsen
@ 2022-05-11 21:22 ` Stefan Monnier
  2022-05-12  0:33   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2022-05-11 21:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

Lars Ingebrigtsen [2022-05-11 12:57:20] wrote:
> org/org.el:15523:6: Warning: the function `customize-variable' might not be defined at runtime.
>
> This is odd, because loaddefs has:
>
> (defalias 'customize-variable 'customize-option)
> (autoload 'customize-option "cus-edit" "\

Here's what happens:

org.el does:

    (eval-when-compile (require 'gnus-sum))

which ends up loading `message` which loads `eudc-capf` which loads
`eudc` which calls `custom-menu-create` which loads `cus-edit`.

Loading `cus-edit` (re)defines `customize-variable` as an actual
function (rather than an alias) and adds a corresponding entry in
`load-history`.

At the end of `eval-when-compile`, `byte-compile-eval` looks at that
`load-history` and (mistakenly) thinks that `customize-variable` was
previously not defined.

This is because it does:

 		    (`(defun . ,f)
 		     (unless (seq-some #'autoloadp
		                       (get f 'function-history))
                        (push f byte-compile-noruntime-functions)))))))))))))

so it only skips the case where the function used to be defined as an
autoload, but not when it used to be defined as an alias.

I installed the patch below which should fix this false positive,
hopefully without introducing too many false negatives.

Another way to attack the problem could be to change `defalias` so it
doesn't push any entry into `load-history` when the new value is equal
to the old one.


        Stefan


diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index cbf2659109a..de51a7731eb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1056,8 +1056,14 @@ byte-compile-eval
 		(dolist (s xs)
 		  (pcase s
 		    (`(defun . ,f)
-		     (unless (seq-some #'autoloadp
-		                       (get (cdr s) 'function-history))
+		     ;; If `f' has a history, it's presumably because
+		     ;; it was already defined beforehand (typically
+		     ;; as an autoload).  It could also be because it
+		     ;; was defined twice during `form', in which case
+		     ;; we arguably should add it to b-c-noruntime-functions,
+                     ;; but it's not clear it's worth the trouble
+		     ;; trying to recognize that case.
+		     (unless (get f 'function-history)
                        (push f byte-compile-noruntime-functions)))))))))))))
 
 (defun byte-compile-eval-before-compile (form)




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Odd warning about `customize-variable'
  2022-05-11 21:22 ` Stefan Monnier
@ 2022-05-12  0:33   ` Lars Ingebrigtsen
  2022-05-12  0:38     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-12  0:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> This is because it does:
>
>  		    (`(defun . ,f)
>  		     (unless (seq-some #'autoloadp
> 		                       (get f 'function-history))
>                         (push f byte-compile-noruntime-functions)))))))))))))
>
> so it only skips the case where the function used to be defined as an
> autoload, but not when it used to be defined as an alias.

Ah, I see (I think).  And I guess this was triggered by 620ac67355,
which made message require eudc-capf, which explains why we didn't see
this warning until a couple days ago.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Odd warning about `customize-variable'
  2022-05-12  0:33   ` Lars Ingebrigtsen
@ 2022-05-12  0:38     ` Stefan Monnier
  2022-05-12  0:54       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2022-05-12  0:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> Ah, I see (I think).  And I guess this was triggered by 620ac67355,
> which made message require eudc-capf, which explains why we didn't see
> this warning until a couple days ago.

Indeed.  BTW, I don't understand why it needs to `require` eudc-capf,
since eudc-capf already autoloads all its functions.

Since `eudc-capf` itself requires `eudc`, I think loading these things
more lazily would be beneficial.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Odd warning about `customize-variable'
  2022-05-12  0:38     ` Stefan Monnier
@ 2022-05-12  0:54       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-12  0:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Indeed.  BTW, I don't understand why it needs to `require` eudc-capf,
> since eudc-capf already autoloads all its functions.
>
> Since `eudc-capf` itself requires `eudc`, I think loading these things
> more lazily would be beneficial.

Yup.  So I removed that require now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-12  0:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 10:57 Odd warning about `customize-variable' Lars Ingebrigtsen
2022-05-11 21:22 ` Stefan Monnier
2022-05-12  0:33   ` Lars Ingebrigtsen
2022-05-12  0:38     ` Stefan Monnier
2022-05-12  0:54       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).