Make the build of source tarball produce *.eln files

* lisp/emacs-lisp/comp.el (batch-native-compile): Accept an
optional argument; if non-nil, place the .eln file as appropriate
for building a source tarball.

* doc/lispref/compile.texi (Native-Compilation Functions):
Document the new optional argument of 'batch-native-compile'.

* lisp/Makefile.in (.PHONY, $(THEFILE)n) [HAVE_NATIVE_COMP]: New
targets.

* src/Makefile.in (%.eln) [HAVE_NATIVE_COMP]: New recipe.
(all) [HAVE_NATIVE_COMP]: Add ../native-lisp to prerequisites.
(elnlisp) [HAVE_NATIVE_COMP]: New list of *.eln files.
(../native-lisp) [HAVE_NATIVE_COMP]: New recipe.

* src/verbose.mk.in (AM_V_ELN): New macro.
This commit is contained in:
Eli Zaretskii 2021-09-28 15:00:50 +03:00
parent b02a7ad263
commit 90655e4bc0
5 changed files with 77 additions and 11 deletions

View file

@ -904,13 +904,20 @@ invokes the same Emacs executable as the process that called this
function.
@end defun
@defun batch-native-compile
@defun batch-native-compile &optional for-tarball
This function runs native-compilation on files specified on the Emacs
command line in batch mode. It must be used only in a batch execution
of Emacs, as it kills Emacs upon completion of the compilation. If
one or more of the files fail to compile, the Emacs process will
attempt to compile all the other files, and will terminate with a
non-zero status code.
non-zero status code. The optional argument @var{for-tarball}, if
non-@code{nil}, tells the function to place the resulting @file{.eln}
files in the last directory mentioned in
@code{native-comp-eln-load-path} (@pxref{Library Search}); this is
meant to be used as part of building an Emacs source tarball for the
first time, when the natively-compiled files, which are absent from
the source tarball, should be generated in the build tree instead of
the user's cache directory.
@end defun
Native compilation can be run entirely asynchronously, in a subprocess

View file

@ -281,6 +281,14 @@ else
-f batch-byte-compile $(THEFILE)
endif
ifeq ($(HAVE_NATIVE_COMP),yes)
.PHONY: $(THEFILE)n
$(THEFILE)n:
$(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f byte-compile-refresh-preloaded \
--eval '(batch-native-compile t)' $(THEFILE)
endif
# Files MUST be compiled one by one. If we compile several files in a
# row (i.e., in the same instance of Emacs) we can't make sure that
# the compilation environment is clean. We also set the load-path of

View file

@ -4191,20 +4191,27 @@ form, return the compiled function."
(comp--native-compile function-or-file nil output))
;;;###autoload
(defun batch-native-compile ()
(defun batch-native-compile (&optional for-tarball)
"Perform batch native compilation of remaining command-line arguments.
Native compilation equivalent of `batch-byte-compile'.
Use this from the command line, with -batch; it wont work
in an interactive Emacs session."
in an interactive Emacs session.
Optional argument FOR-TARBALL non-nil means the file being compiled
as part of building the source tarball, in which case the .eln file
will be placed under the native-lisp/ directory (actually, in the
last directory in `native-comp-eln-load-path')."
(comp-ensure-native-compiler)
(cl-loop for file in command-line-args-left
if (or (null byte+native-compile)
(cl-notany (lambda (re) (string-match re file))
native-comp-bootstrap-deny-list))
do (comp--native-compile file)
else
do (byte-compile-file file)))
(let ((native-compile-target-directory
(if for-tarball
(car (last native-comp-eln-load-path)))))
(cl-loop for file in command-line-args-left
if (or (null byte+native-compile)
(cl-notany (lambda (re) (string-match re file))
native-comp-bootstrap-deny-list))
do (comp--native-compile file)
else
do (byte-compile-file file))))
;;;###autoload
(defun batch-byte+native-compile ()

View file

@ -448,7 +448,15 @@ FIRSTFILE_OBJ=@FIRSTFILE_OBJ@
ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj)
# Must be first, before dep inclusion!
ifeq ($(HAVE_NATIVE_COMP),yes)
ifeq ($(NATIVE_DISABLED),)
all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES) ../native-lisp
else
all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
endif
else
all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
endif
.PHONY: all
dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \
@ -775,6 +783,38 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
@$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\
THEFILE=$< $<c
ifeq ($(HAVE_NATIVE_COMP),yes)
ifeq ($(NATIVE_DISABLED),)
## The following rules are used only when building a source tarball
## for the first time, when the native-lisp/ directory doesn't yet
## exist and needs to be created and populated with the preloaded
## *.eln files.
## List of *.eln files we need to produce in addition to the preloaded
## ones in $(lisp).
elnlisp := \
emacs-lisp/autoload.eln \
emacs-lisp/byte-opt.eln \
emacs-lisp/bytecomp.eln \
emacs-lisp/cconv.eln \
international/charscript.eln \
emacs-lisp/comp.eln \
emacs-lisp/comp-cstr.eln \
international/emoji-zwj.eln
elnlisp := $(addprefix ${lispsource}/,${elnlisp}) $(lisp:.elc=.eln)
%.eln: %.el | emacs$(EXEEXT) $(pdmp)
@$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="../src/emacs$(EXEEXT)"\
THEFILE=$< $<n
../native-lisp: | $(pdmp)
mkdir $@ && $(MAKE) $(AM_V_NO_PD) $(elnlisp)
LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \
--bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR)
cp -f $@ $(bootstrap_pdmp)
endif
endif
## VCSWITNESS points to the file that holds info about the current checkout.
## We use it as a heuristic to decide when to rebuild loaddefs.el.
## If empty it is ignored; the parent makefile can set it to some other value.

View file

@ -25,6 +25,7 @@ AM_V_at =
AM_V_CC =
AM_V_CCLD =
AM_V_ELC =
AM_V_ELN =
AM_V_GEN =
AM_V_GLOBALS =
AM_V_NO_PD =
@ -37,11 +38,14 @@ AM_V_CCLD = @echo " CCLD " $@;
ifeq ($(HAVE_NATIVE_COMP),yes)
ifeq ($(NATIVE_DISABLED),1)
AM_V_ELC = @echo " ELC " $@;
AM_V_ELN =
else
AM_V_ELC = @echo " ELC+ELN " $@;
AM_V_ELN = @echo " ELN " $@;
endif
else
AM_V_ELC = @echo " ELC " $@;
AM_V_ELN =
endif
AM_V_GEN = @echo " GEN " $@;
AM_V_GLOBALS = @echo " GEN " globals.h;