"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'.")
;; 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)))))
;; 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)))
"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? "
(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