[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#65478] [PATCH emacs-team] gnu: emacs-flim-lb: Explicitly compile fi
From: |
Hilton Chain |
Subject: |
[bug#65478] [PATCH emacs-team] gnu: emacs-flim-lb: Explicitly compile files to bytecode. |
Date: |
Mon, 28 Aug 2023 12:21:30 +0800 |
On Sun, 27 Aug 2023 23:49:49 +0800,
Liliana Marie Prikler wrote:
>
> Am Sonntag, dem 27.08.2023 um 23:39 +0800 schrieb Hilton Chain:
> > Currently on master:
> >
> > $ guix build emacs-flim-lb
> > has elc files.
> >
> > $ guix build emacs-flim-lb --with-input=emacs-minimal=emacs
> > has elc and eln files.
> >
> > $ guix build emacs-flim-lb --with-input=emacs-minimal=emacs-next
> > has eln files.
> >
> > And I tried to build it with 'build phase deleted as well. Had them
> > all tested and came to the conclusion that elc files are required.
> Hmm, this sounds like a failure of emacs-build-system then. The
> assumption (based on Emacs 28) had been that both bytecode and native
> compilation are done with one function call. Maybe that no longer
> holds?
Found a change in `batch-byte+native-compile' with
$ git diff emacs-28.2..emacs-29.1 lisp/emacs-lisp/comp.el
--8<---------------cut here---------------start------------->8---
+(defun comp-write-bytecode-file (eln-file)
+ "After native compilation write the bytecode file for ELN-FILE.
+Make sure that eln file is younger than byte-compiled one and
+return the filename of this last.
+
+This function can be used only in conjuntion with
+`byte+native-compile' `byte-to-native-output-buffer-file' (see
+`batch-byte+native-compile')."
+ (pcase byte-to-native-output-buffer-file
+ (`(,temp-buffer . ,target-file)
+ (unwind-protect
+ (progn
+ (byte-write-target-file temp-buffer target-file)
+ ;; Touch the .eln in order to have it older than the
+ ;; corresponding .elc.
+ (when (stringp eln-file)
+ (set-file-times eln-file)))
+ (kill-buffer temp-buffer))
+ target-file)))
;;;###autoload
(defun batch-byte+native-compile ()
@@ -4221,17 +4345,16 @@ Generate .elc files in addition to the .eln files.
Force the produced .eln to be outputted in the eln system
directory (the last entry in `native-comp-eln-load-path') unless
`native-compile-target-directory' is non-nil. If the environment
-variable 'NATIVE_DISABLED' is set, only byte compile."
+variable \"NATIVE_DISABLED\" is set, only byte compile."
(comp-ensure-native-compiler)
(if (equal (getenv "NATIVE_DISABLED") "1")
(batch-byte-compile)
(cl-assert (length= command-line-args-left 1))
- (let ((byte+native-compile t)
- (byte-to-native-output-file nil))
- (batch-native-compile)
- (pcase byte-to-native-output-file
- (`(,tempfile . ,target-file)
- (rename-file tempfile target-file t))))))
+ (let* ((byte+native-compile t)
+ (byte-to-native-output-buffer-file nil)
+ (eln-file (car (batch-native-compile))))
+ (comp-write-bytecode-file eln-file)
+ (setq command-line-args-left (cdr command-line-args-left)))))
--8<---------------cut here---------------end--------------->8---
And the following patch should work for Emacs 29, but not 28:
--8<---------------cut here---------------start------------->8---
diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 850b1f5f2a..6c27b186e3 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -138,7 +138,7 @@ (define* (emacs-compile-directory dir)
(files (directory-files-recursively ,dir "\\.el$")))
(mapc
(lambda (file)
- (let (byte-to-native-output-file
+ (let (byte-to-native-output-buffer-file
;; First entry is the eln-cache of the homeless shelter,
;; second entry is the install directory.
(eln-dir (and (native-comp-available-p)
@@ -148,12 +148,12 @@ (define* (emacs-compile-directory dir)
(comp-el-to-eln-filename file eln-dir))
(byte-compile-file file))
;; Sadly, we can't use pcase because quasiquote works different in
- ;; Emacs. See `batch-byte+native-compile' in comp.el for the
- ;; actual shape of byte-to-native-output-file.
- (unless (null byte-to-native-output-file)
- (rename-file (car byte-to-native-output-file)
- (cdr byte-to-native-output-file)
- t))))
+ ;; Emacs. See `comp-write-bytecode-file' in comp.el for the actual
+ ;; shape of byte-to-native-output-buffer-file.
+ (unless (null byte-to-native-output-buffer-file)
+ (byte-write-target-file
+ (car byte-to-native-output-buffer-file)
+ (cdr byte-to-native-output-buffer-file)))))
files))
#:dynamic? #t))
--8<---------------cut here---------------end--------------->8---
[bug#65478] [PATCH emacs-team v2] build: emacs-utils: Adjust `emacs-compile-directory' for Emacs 29., Hilton Chain, 2023/08/28