Skip to content

Commit

Permalink
Soft-require comp
Browse files Browse the repository at this point in the history
Before performing native compilation we use `fboundp' to check the
availability of certain native-compilation functions.  This served
two purposes; to suppress warning from the byte-compiler, when
these functions are not available, and to determine whether
native-compilation is available.

In Emacs 30 the latter did not work reliably anymore as the libraries
in which these functions are defined are no longer loaded up front.
We address this by loading `comp' up front when `borg' is loaded,
effectively undoing this upstream optimization.

I've considered to delay loading `comp' until Borg is about to compile
a package, but when native-compilation is not available we would end up
(unsuccessfully) searching for `comp' every time a file is compiled,
which seems more wasteful than potentially needlessly loading `comp'.
  • Loading branch information
tarsius committed Jul 22, 2024
1 parent 62274cb commit 0373de1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions borg.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
;;; Code:

(require 'bytecomp)
(require 'comp nil t)
(require 'cl-lib)
(require 'info)
(require 'pcase)
Expand Down Expand Up @@ -568,16 +569,15 @@ and optional NATIVE are both non-nil, then also compile natively."
(cond
(noninteractive
(let ((borg-compile-function borg-compile-function))
(when (fboundp 'comp-ensure-native-compiler)
(when native
(setq borg-compile-function
(if (functionp native) native #'borg-byte+native-compile)))
(when (memq borg-compile-function '( borg--native-compile
native-compile
native-compile-async))
(message "WARNING: Using `%s' instead of unsuitable `%s'"
'borg-byte+native-compile borg-compile-function)
(setq borg-compile-function #'borg-byte+native-compile)))
(when native
(setq borg-compile-function
(if (functionp native) native #'borg-byte+native-compile)))
(when (memq borg-compile-function '( borg--native-compile
native-compile
native-compile-async))
(message "WARNING: Using `%s' instead of unsuitable `%s'"
'borg-byte+native-compile borg-compile-function)
(setq borg-compile-function #'borg-byte+native-compile))
(borg--build-noninteractive clone)
(when activate
(borg-activate clone))))
Expand Down

0 comments on commit 0373de1

Please sign in to comment.