Fix building --with-native-compilation=aot from release tarball

* lisp/Makefile.in (%.eln): Pattern rule for AOT native
compilation.
(compile-eln-targets, compile-eln-aot): New targets for AOT native
compilation.

* src/Makefile.in (../native-lisp): If NATIVE_COMPILATION_AOT is
set, also native-compile all the other Lisp files.
(Bug#64167)
This commit is contained in:
Eli Zaretskii 2023-06-22 14:03:17 +03:00
parent 4ca371e9cc
commit e962cf4ba7
2 changed files with 44 additions and 0 deletions

View file

@ -436,6 +436,42 @@ ifeq ($(HAVE_NATIVE_COMP),yes)
$(emacs) -l comp -f comp-compile-all-trampolines
endif
.PHONY: compile-eln-targets compile-eln-aot
# ELNDONE is defined by ../src/Makefile, as the list of preloaded
# *.eln files, which are therefore already compiled by the time
# compile-eln-aot is called.
ifeq ($(NATIVE_COMPILATION_AOT),yes)
%.eln: %.el
$(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f byte-compile-refresh-preloaded \
--eval '(batch-native-compile t)' $<
compile-eln-targets: $(filter-out $(ELNDONE),$(TARGETS))
else
compile-eln-targets:
endif
# This is called from ../src/Makefile when building a release tarball
# configured --with-native-compilation=aot.
compile-eln-aot:
@(cd $(lisp) && \
els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
for el in $$els; do \
test -f $$el || continue; \
test -f $${el}c || continue; \
GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > /dev/null && \
continue; \
GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-native-compile: *t' $$el > /dev/null && \
continue; \
echo "$${el}n"; \
done | xargs $(XARGS_LIMIT) echo) | \
while read chunk; do \
$(MAKE) compile-eln-targets \
TARGETS="$$chunk" ELNDONE="$(ELNDONE)"; \
done
.PHONY: backup-compiled-files compile-after-backup
# Backup compiled Lisp files in elc.tar.gz. If that file already

View file

@ -872,6 +872,11 @@ elnlisp := $(addprefix ${lispsource}/,${elnlisp}) $(lisp:.elc=.eln)
## native-lisp where the *.eln files will be produced, and the exact
## names of those *.eln files, cannot be known in advance; we must ask
## Emacs to produce them.
## If AOT native compilation is requested, we additionally
## native-compile all the *.el files in ../lisp that need to be
## compiled and haven't yet been compiled. ELDONE holds the list
## of *.el files that were already native-compiled.
NATIVE_COMPILATION_AOT = @NATIVE_COMPILATION_AOT@
../native-lisp: | $(pdmp)
@if test ! -d $@; then \
mkdir $@ && $(MAKE) $(AM_V_NO_PD) $(elnlisp); \
@ -882,6 +887,9 @@ elnlisp := $(addprefix ${lispsource}/,${elnlisp}) $(lisp:.elc=.eln)
--bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR) \
&& cp -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT) \
&& cp -f $(pdmp) $(bootstrap_pdmp); \
if test $(NATIVE_COMPILATION_AOT) = yes; then \
$(MAKE) $(AM_V_NO_PD) -C ../lisp compile-eln-aot EMACS="../src/emacs$(EXEEXT)" ELNDONE="$(addprefix %,$(notdir $(elnlisp))))"; \
fi; \
fi
endif