spacemacs
spacemacs copied to clipboard
Symbol's value as variable is void: `native-comp-speed` when `dotspacemacs-enable-emacs-pdumper` is non-nil
Description
The debugger is triggered on initialization when dotspacemacs-enable-emacs-pdumper
is non-nil, and when native-compilation is available and (apparently) enabled.
Work–around
Disable the Emacs portable dumper in .spacemacs
by setting dotspacemacs-enable-emacs-pdumper
to nil
.
Discussion
Disabling the portable dumper in the user Spacemacs dot–file should not be necessary, as boolean checks are already included in Spacemacs' core-dumper.el
:
https://github.com/syl20bnr/spacemacs/blob/756ffc5c004fdac5f3c24bab6c692aa3b446a62f/core/core-dumper.el#L121-L126
native-comp-speed
is a customization variable defined by the built–in comp.el
:
https://github.com/emacs-mirror/emacs/blob/22bee93d92567a1b01ebf7354089e6695e134611/lisp/emacs-lisp/comp.el#L46-L58
The built–in native-comp-speed
customization variable should be defined (and set, when the variable is unbound); the conditional check fails because the symbol remains unbound, causing the error.
TODO
-
[ ] Refactor the
spacemacs/emacs-with-native-compilation-enabled-p
predicate incore-dumper.el
to be more fail–safeBackgrounder
Loading of native–compiled and byte–compiled Emacs Lisp code
It is stated in § 27.8 Libraries of Lisp Code for Emacs of the Emacs Manual,
Automatic loading also occurs when completing names for describe-variable and describe-function, based on the prefix being completed. To disable this feature, change the variable help-enable-completion-autoload to nil.
I suspect that
/usr/share/emacs/28.1/lisp/emacs-lisp/comp.elc
is not being loaded until later in the initialization process than whendotspacemacs-enable-emacs-pdumper
' value is checked.When the error was produced, I instinctively ran
describe-variable
, which would trigger automatic loading and then define the variable. This may cause confusion for other users and lead to more open issues related to native compilation and the portable dumper.Possible solution
It may be possible to locate and preemptively load a byte–compiled or native–compiled form of
comp.el
, wheneverdotspacemacs-enable-emacs-pdumper
is non–nil, to implement the fail–safe condition check.;; FIXME: (not (eql native-comp-speed -1)) (if (and (native-comp-available-p) (not (boundp 'native-comp-speed))) (let ((native-comp-library (locate-file "comp" load-path '(".eln" ".elc" ".el")))) (if native-comp-library (load native-comp-library) (message "[DEBUG][BUILT-IN][native-compilation][SPACEMACS][core-dumper] The library `comp.el' or a compiled form was not found for preemptive loading."))))
Issues with possible solution
Customized values of
native-comp-speed
, such as-1
(which disables native compilation), will not be loaded by Spacemacs until the end of the initialization process, by which time loading a dump–file may have been skipped, or the Spacemacs dumping facilities will be broken, causing the dump file to not be updated.
Backtrace
Debugger entered--Lisp error: (void-variable native-comp-speed)
(eql native-comp-speed -1)
(not (eql native-comp-speed -1))
(and (featurep 'native-compile) (fboundp 'native-comp-available-p) (native-comp-available-p) (not (eql native-comp-speed -1)))
spacemacs/emacs-with-native-compilation-enabled-p()
(not (spacemacs/emacs-with-native-compilation-enabled-p))
(and dotspacemacs-enable-emacs-pdumper (file-exists-p (locate-file (or dotspacemacs-emacs-pdumper-executable-file "emacs") exec-path exec-suffixes 'file-executable-p)) (not (spacemacs/emacs-with-native-compilation-enabled-p)))
spacemacs/emacs-with-pdumper-set-p()
(and (spacemacs/emacs-with-pdumper-set-p) (spacemacs-run-from-dump-p))
(cond (changed-since-last-dump-p (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message "Layer list has changed since last dump.") (configuration-layer//dump-emacs)))) (spacemacs-force-dump (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message (concat "--force-dump passed on the command line or configu..." "been reloaded, forcing a redump.")) (configuration-layer//dump-emacs)))) ((spacemacs-is-dumping-p) (configuration-layer//load)) ((and (spacemacs/emacs-with-pdumper-set-p) (spacemacs-run-from-dump-p)) (configuration-layer/message "Running from a dumped file. Skipping the loading p...")) (t (configuration-layer//load) (if (spacemacs/emacs-with-pdumper-set-p) (progn (configuration-layer/message (concat "Layer list has not changed since last time. " "Skipping dumping process!"))))))
configuration-layer/load()
(let ((please-do-not-disable-file-name-handler-alist nil)) (require 'core-spacemacs) (spacemacs/dump-restore-load-path) (configuration-layer/load-lock-file) (spacemacs/init) (configuration-layer/stable-elpa-init) (configuration-layer/load) (spacemacs-buffer/display-startup-note) (spacemacs/setup-startup-hook) (spacemacs/dump-eval-delayed-functions) (if (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p))) (progn (require 'server) (if dotspacemacs-server-socket-dir (progn (setq server-socket-dir dotspacemacs-server-socket-dir))) (if (server-running-p) nil (message "Starting a server...") (server-start)))))
(if (not (version<= spacemacs-emacs-min-version emacs-version)) (error (concat "Your version of Emacs (%s) is too old. " "Spacemacs requires Emacs version %s or above.") emacs-version spacemacs-emacs-min-version) (let ((please-do-not-disable-file-name-handler-alist nil)) (require 'core-spacemacs) (spacemacs/dump-restore-load-path) (configuration-layer/load-lock-file) (spacemacs/init) (configuration-layer/stable-elpa-init) (configuration-layer/load) (spacemacs-buffer/display-startup-note) (spacemacs/setup-startup-hook) (spacemacs/dump-eval-delayed-functions) (if (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p))) (progn (require 'server) (if dotspacemacs-server-socket-dir (progn (setq server-socket-dir dotspacemacs-server-socket-dir))) (if (server-running-p) nil (message "Starting a server...") (server-start))))))
load-with-code-conversion("/home/cyber/.spacemacs.develop.d/init.el" "/home/cyber/.spacemacs.develop.d/init.el" t t)
load("/home/cyber/.spacemacs.develop.d/init.el" t t)
(let ((init-file (expand-file-name "init.el" user-emacs-directory))) (setq package-user-dir (expand-file-name "elpa" user-emacs-directory)) (load init-file t t) (let ((chemacs-custom-file (chemacs-profile-get 'custom-file init-file))) (if (not custom-file) (progn (setq custom-file chemacs-custom-file) (if (equal custom-file init-file) nil (if (file-exists-p custom-file) nil (let (...) (save-current-buffer ... ...))) (load custom-file))))))
chemacs-load-user-init()
load-with-code-conversion("/home/cyber/.emacs.d/init.el" "/home/cyber/.emacs.d/init.el" t t)
load("/home/cyber/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #<bytecode -0xb417b0228b986f4>) #f(compiled-function () #<bytecode -0x1f3c686ddc0ca9b5>) t)
command-line()
normal-top-level()
simple solution, (require 'native-compile)
require
appears insufficient
simple solution, (require 'native-compile)
That does sound reasonable, but where should this addition go in the resolving MR? Editing core/core-dumper.el
like below does not fix the issue; loading comp.el
(which sets the standard value of native-comp-speed
to 2
: enabled with full optimizations) prevents the portable dumper from being properly disabled, it appears. How did you intend loading the library to fix the issue?
(defun spacemacs/emacs-with-native-compilation-enabled-p ()
"Return non-nil if native compilation is enabled."
(and (featurep 'native-compile)
(fboundp 'native-comp-available-p)
(native-comp-available-p)
(if (not (boundp 'native-comp-speed))
(let ((native-comp-library (locate-file "comp" load-path '(".eln" ".elc" ".el"))))
(if native-comp-library
(require 'comp `,@native-comp-library)
(message "[DEBUG][BUILT-IN][native-compilation][SPACEMACS][core-dumper] The library `comp.el' or
a compiled form was not found for preemptive loading."))))
(not (eql native-comp-speed -1))))
I was unsure of my possible solution, and my test shows that it doesn't work as hoped. It does prevent the error on startup, but the documentation for Spacemacs portable dumper says that it should be disabled when native compilation is enabled, regardless of the value of the variable dotspacemacs-enable-emacs-pdumper
.
;; If non-nil then enable support for the portable dumper. You'll need to
;; compile Emacs 27 from source following the instructions in file
;; EXPERIMENTAL.org at to root of the git repository.
;;
;; WARNING: pdumper does not work with Native Compilation, so it's disabled
;; regardless of the following setting when native compilation is in effect.
;;
;; (default nil)
dotspacemacs-enable-emacs-pdumper t
Question regarding the libary name
Why is the library/feature that you propose to load in the Spacemacs sources called native-compile
and not comp
as in the Emacs Lisp source directory I linked to in my opening comment (comp.el
)? I'm just a little confused about that now.
I also saw that there is no completion candidate for a native-compile
feature when I call unload-feature
interactively, but calls to featurep()
each return non-nil when comp
or native-compile
are passed as arguments. Furthermore, helm-locate-library
has no candidates for native-compile
, but it is apparently a feature.
Do you know what's up? Is native-compile
an alias?
So the line (featurep 'native-compile) is wrong
It should be (featurep 'comp) Then (require 'comp)
And no need for (fboundp' ...)
How did you intend loading the library to fix the issue?
If you use custom-set-variale instead of setq on native-comp-speed, its value will be correct.
So the line (featurep 'native-compile) is wrong
It should be (featurep 'comp) Then (require 'comp)
And no need for (fboundp' ...)
So we should have the below defun
, then?
(defun spacemacs/emacs-with-native-compilation-enabled-p ()
"Return non-nil if native compilation is enabled."
(and (featurep 'comp)
(not (eql native-comp-speed -1))))
I will fix it.
Linked wrong issue :cold_sweat:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!