summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2022-01-19 21:07:00 +0100
committerAndrea Corallo <akrl@sdf.org>2022-01-19 22:04:14 +0100
commit9396b7d0b425a114eb6e8695c439be3d30490f98 (patch)
tree26b175578cfbce7ab5a47bfde8df8bb1120dbb65 /lisp/emacs-lisp
parent6a79de530f5de5ada701a5fec4a4892a4250bb60 (diff)
downloademacs-9396b7d0b425a114eb6e8695c439be3d30490f98.tar.gz
emacs-9396b7d0b425a114eb6e8695c439be3d30490f98.tar.bz2
emacs-9396b7d0b425a114eb6e8695c439be3d30490f98.zip
Suspend temp .elc production when native compiling till when necessary
* lisp/emacs-lisp/bytecomp.el (byte-to-native-output-buffer-file): Rename from `byte-to-native-output-file'. (byte-write-target-file): Update. (byte-compile-file): Write the temporary .elc only when not native compiling. (byte-compile-file): Kill the .elc buffer only when not native compiling. * lisp/emacs-lisp/comp.el (batch-byte+native-compile): Instead of just renaming the temporary .elc make use of `byte-write-target-file' to write it down and kill the temporary buffer.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el15
-rw-r--r--lisp/emacs-lisp/comp.el10
2 files changed, 16 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 49d4ca6510a..7dfe21441bd 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -615,8 +615,8 @@ Each element is (INDEX . VALUE)")
"Hash byte-code -> byte-to-native-lambda.")
(defvar byte-to-native-top-level-forms nil
"List of top level forms.")
-(defvar byte-to-native-output-file nil
- "Temporary file containing the byte-compilation output.")
+(defvar byte-to-native-output-buffer-file nil
+ "Pair holding byte-compilation output buffer, elc filename.")
(defvar byte-to-native-plist-environment nil
"To spill `overriding-plist-environment'.")
@@ -2008,7 +2008,7 @@ If compilation is needed, this functions returns the result of
;; deleting target-file before writing it.
(if byte-native-compiling
;; Defer elc final renaming.
- (setf byte-to-native-output-file
+ (setf byte-to-native-output-buffer-file
(cons tempfile target-file))
(rename-file tempfile target-file t)))))
@@ -2143,7 +2143,11 @@ See also `emacs-lisp-byte-compile-and-load'."
;; Need to expand in case TARGET-FILE doesn't
;; include a directory (Bug#45287).
(expand-file-name target-file))))
- (byte-write-target-file (current-buffer) target-file)
+ (if byte-native-compiling
+ ;; Defer elc production.
+ (setf byte-to-native-output-buffer-file
+ (cons (current-buffer) target-file))
+ (byte-write-target-file (current-buffer) target-file))
(or noninteractive
byte-native-compiling
(message "Wrote %s" target-file)))
@@ -2164,7 +2168,8 @@ See also `emacs-lisp-byte-compile-and-load'."
"Cannot overwrite file"
"Directory not writable or nonexistent")
target-file))))))
- (kill-buffer (current-buffer)))
+ (unless byte-native-compiling
+ (kill-buffer (current-buffer))))
(if (and byte-compile-generate-call-tree
(or (eq t byte-compile-generate-call-tree)
(y-or-n-p (format "Report call tree for %s? "
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index e50538c4232..c9cb2b1c7be 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -4212,11 +4212,13 @@ variable 'NATIVE_DISABLED' is set, only byte compile."
(batch-byte-compile)
(cl-assert (length= command-line-args-left 1))
(let ((byte+native-compile t)
- (byte-to-native-output-file nil))
+ (byte-to-native-output-buffer-file nil))
(batch-native-compile)
- (pcase byte-to-native-output-file
- (`(,tempfile . ,target-file)
- (rename-file tempfile target-file t)))
+ (pcase byte-to-native-output-buffer-file
+ (`(,temp-buffer . ,target-file)
+ (unwind-protect
+ (byte-write-target-file temp-buffer target-file))
+ (kill-buffer temp-buffer)))
(setq command-line-args-left (cdr command-line-args-left)))))
;;;###autoload