Skip to content

Commit 3853dff

Browse files
committed
tweak: disable ahead-of-time native compilation
Rather than impose a 10-45min compilation step on users, I've disabled ahead-of-time compilation for deferred compilation. In exchange, it will eat up some CPU time the first time each uncompiled package is loaded, but as this happens asynchronously (and are then quietly loaded in the background), I think this is acceptable. An --aot switch (or similar) will be added to `doom sync` and `doom build` in the future, in case folks prefer the old behavior.
1 parent b7f84bd commit 3853dff

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lisp/doom-packages.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ uses a straight or package.el command directly).")
9797
straight-vc-git-default-clone-depth '(1 single-branch))
9898

9999
(with-eval-after-load 'straight
100+
;; HACK Doom relies on deferred compilation, which spares the user 20-50min of
101+
;; compilation at install time, but subjects them to ~50% CPU activity when
102+
;; starting Emacs for the first time. To complete this, straight.el needs to
103+
;; be told not to do native-compilation, but it won't obey
104+
;; `straight-disable-native-compile'.
105+
;;
106+
;; It *will* obey `straight--native-comp-available', though. Trouble is:
107+
;; it's a constant; it resets itself when straight is loaded, so it must be
108+
;; changed afterwards.
109+
(setq straight--native-comp-available nil)
100110
;; `let-alist' is built into Emacs 26 and onwards
101111
(add-to-list 'straight-built-in-pseudo-packages 'let-alist))
102112

lisp/doom.el

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@
5959
(unless (get var 'initial-value)
6060
(put var 'initial-value (default-value var))))
6161

62-
;; Prevent unwanted runtime compilation for gccemacs (native-comp) users;
63-
;; packages are compiled ahead-of-time when they are installed and site files
64-
;; are compiled when gccemacs is installed.
65-
(setq native-comp-deferred-compilation nil)
66-
6762
;; Since Emacs 27, package initialization occurs before `user-init-file' is
6863
;; loaded, but after `early-init-file'. Doom handles package initialization, so
6964
;; we must prevent Emacs from doing it again.
@@ -316,6 +311,18 @@ users).")
316311
;;; Native Compilation support (http://akrl.sdf.org/gccemacs.html)
317312

318313
(when (featurep 'native-compile)
314+
;; Enable deferred compilation and disable ahead-of-time compilation, so we
315+
;; don't bog down the install process with an excruciatingly long compile
316+
;; times. It will mean more CPU time at runtime, but given its asynchronosity,
317+
;; this is acceptable.
318+
(setq native-comp-deferred-compilation t
319+
straight-disable-native-compile t)
320+
321+
;; Suppress compiler warnings, to avoid inundating users will popups. They
322+
;; don't cause breakage, so it's not worth dedicating screen estate to them.
323+
(setq native-comp-async-report-warnings-errors init-file-debug
324+
native-comp-warning-on-missing-source init-file-debug)
325+
319326
;; Don't store eln files in ~/.emacs.d/eln-cache (where they can easily be
320327
;; deleted by 'doom upgrade').
321328
;; REVIEW Use `startup-redirect-eln-cache' when 28 support is dropped

0 commit comments

Comments
 (0)