Subject: bug#70357: 30.0.50; loadup.el, load nadvice before seq

From: Stefan Monnier <[email-masked]>
Date: Sun, 14 Apr 2024 10:14:39 -0400

> I did not look in enough detail to see the specific problem.
> E.g. I don't know what is the actual warning that we're trying to emit.

Oh, I see the origin of the problem: `cl-generic` calls `byte-compile`
too early during the bootstrap.  Normally, this is avoided with:

    (defvar cl--generic-compiler
      ;; Don't byte-compile the dispatchers if cl-generic itself is not
      ;; compiled.  Otherwise the byte-compiler and all the code on
      ;; which it depends needs to be usable before cl-generic is loaded,
      ;; which imposes a significant burden on the bootstrap.
      (if (not (compiled-function-p (lambda (x) (+ x 1))))
          (lambda (exp) (eval exp t))
        ;; But do byte-compile the dispatchers once bootstrap is passed:
        ;; the performance difference is substantial (like a 5x speedup on
        ;; the `eieio' elisp-benchmark)).
        ;; To avoid loading the byte-compiler during the final preload,
        ;; see `cl--generic-prefill-dispatchers'.
        #'byte-compile))

but in your case `cl-generic.el` has been compiled, so the `if` test
decides to use the byte-compiler.  I haven't figured out why this
doesn't bite more often nor why it bites in this specific case (I
haven't been able to reproduce the problem).

A quick fix could be the patch below.

        Stefan

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index fb3278c08ab..c402f91d67c 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1492,7 +1492,8 @@ byte-compile--function-signature
   (and (eq 'macro (car-safe f)) (setq f (cdr f)))
   ;; Advice wrappers have "catch all" args, so fetch the actual underlying
   ;; function to find the real arguments.
-  (setq f (advice--cd*r f))
+  (when (fboundp 'advice--cd*r) ;;nil during early bootstrap.
+    (setq f (advice--cd*r f)))
   (if (eq (car-safe f) 'declared)
       (byte-compile-arglist-signature (nth 1 f))
     (condition-case nil