From 539140820fbabeb7b838aba1d2325e95c426520b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 16 May 2024 09:50:39 -0400 Subject: [PATCH] * lisp/loadup.el: Add workaround for occasional "bootstrap" failure (cherry picked from commit ee3ef57c24fe3435cd896e1f096aadff5f9372a0) --- lisp/loadup.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lisp/loadup.el b/lisp/loadup.el index 7c67df9fade..b8844ea042c 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -191,6 +191,23 @@ (setq definition-prefixes new)) (load "button") ;After loaddefs, because of define-minor-mode! + +(when (interpreted-function-p (symbol-function 'add-hook)) + ;; `subr.el' is needed early and hence can't use macros like `setf' + ;; liberally. Yet, it does use such macros in code that it knows will not + ;; be executed too early, such as `add-hook'. Usually, by the time we + ;; run that code, either `subr.el' was already compiled to start with + ;; or on the contrary many files aren't compiled yet and have thus caused + ;; macro packages like `gv' to be loaded. But not always. + ;; The specific error we're trying to work around, here, occurs when + ;; `cl-preloaded's `provide' ends up (because of an `eval-after-load') + ;; calling `add-hook' which burps with a "void-function setf" on + ;; (setf (get hook 'hook--depth-alist) depth-sym)'. + ;; FIXME: We should probably split `subr.el' into one that's loaded early + ;; where we refrain from using macros like `setf', and another loaded later + ;; where we can blissfully `require' packages like `gv'. + (require 'gv)) + (load "emacs-lisp/cl-preloaded") (load "emacs-lisp/oclosure") ;Used by cl-generic (load "obarray") ;abbrev.el is implemented in terms of obarrays. -- 2.39.5