fix: don't byte-compile profile init file

The performance benefit of doing so has always been questionable or, at
best, negligible, but has caused numerous issues over the years. The
latest one being #8162, where byte-compiling a profile init file with
too many package autoloads would consume more than 255 opcodes, causing
an overflow error.

For simplicity's sake, Doom will no longer byte-compile this file.

Fix: #8162
This commit is contained in:
Henrik Lissner
2024-11-18 18:27:47 -05:00
parent 04c7cf51b4
commit 87a024ee90
3 changed files with 6 additions and 15 deletions

View File

@ -1713,7 +1713,7 @@ If DEFAULT? is non-nil, an unspecified CAR/CDR will fall bakc to (_default .
(list "Expected PROFILE to be a string, cons cell, or `doom-profile'"
(type-of profile) profile))))))
(defun doom-profile-init-file (profile &optional el?)
(defun doom-profile-init-file (profile)
"Return the init file for PROFILE."
(declare (side-effect-free t))
(cl-destructuring-bind (name . ref)
@ -1721,10 +1721,9 @@ If DEFAULT? is non-nil, an unspecified CAR/CDR will fall bakc to (_default .
(doom-profile-key profile t)
(cons nil nil))
(file-name-concat doom-data-dir name "@" ref
(format "init.%d.%d.%s"
(format "init.%d.%d.el"
emacs-major-version
emacs-minor-version
(if el? "el" "elc")))))
emacs-minor-version))))
(defun doom-profile-get (profile-name &optional property null-value)
"Return PROFILE-NAME's PROFILE, otherwise its PROPERTY, otherwise NULL-VALUE."

View File

@ -308,9 +308,7 @@ If RETURN-P, return the message as a string instead of displaying it."
(doom-profile-init-file doom-profile)))
;; If we loaded a compiled file, set `user-init-file' to the
;; source version if that exists.
(setq user-init-file
(concat (string-remove-suffix ".elc" init-file-name)
".el"))
(setq user-init-file init-file-name)
;; HACK: if `init-file-name' happens to be higher in
;; `load-history' than a symbol's actual definition,
;; `symbol-file' (and help/helpful buffers) will report the

View File

@ -242,7 +242,7 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
(doom-initialize-packages)
(let* ((default-directory doom-profile-dir)
(init-dir doom-profile-init-dir-name)
(init-file (doom-profile-init-file doom-profile t)))
(init-file (doom-profile-init-file doom-profile)))
(print! (start "(Re)building profile in %s/...") (path default-directory))
(condition-case-unless-debug e
(with-file-modes #o750
@ -302,14 +302,8 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
if (fboundp genfn)
collect (list initfn))))
(current-buffer)))
(print! (start "Byte-compiling %s...") (relpath init-file))
(print-group!
(let ((byte-compile-debug t)
(byte-compile-warnings (if init-file-debug '(suspicious make-local callargs))))
(byte-compile-file init-file)))
(print! (success "Built %s") (byte-compile-dest-file init-file))))
(print! (success "Built %s") (filename init-file))))
(error (delete-file init-file)
(delete-file (byte-compile-dest-file init-file))
(signal 'doom-autoload-error (list init-file e))))))
(defun doom-profile--generate-vars ()