From 4beb850efb99b881fb8b648ad7bb43c6539a2431 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 24 Dec 2019 20:48:49 +0100 Subject: [PATCH] add native support to the build system --- lisp/Makefile.in | 41 ++++++++++++++++++++++++++++++++++--- lisp/emacs-lisp/autoload.el | 2 +- src/Makefile.in | 20 ++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 57527bb5afc..91b44de46aa 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -32,6 +32,11 @@ XARGS_LIMIT = @XARGS_LIMIT@ # 'make' verbosity. AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_V_ELN = $(am__v_ELN_@AM_V@) +am__v_ELN_ = $(am__v_ELN_@AM_DEFAULT_V@) +am__v_ELN_0 = @echo " ELN " $@; +am__v_ELN_1 = + AM_V_ELC = $(am__v_ELC_@AM_V@) am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) am__v_ELC_0 = @echo " ELC " $@; @@ -99,7 +104,8 @@ COMPILE_FIRST = \ $(lisp)/emacs-lisp/cconv.elc \ $(lisp)/emacs-lisp/byte-opt.elc \ $(lisp)/emacs-lisp/bytecomp.elc \ - $(lisp)/emacs-lisp/autoload.elc + $(lisp)/emacs-lisp/autoload.elc \ + $(lisp)/emacs-lisp/comp.elc # Files to compile early in compile-main. Works around bug#25556. MAIN_FIRST = ./emacs-lisp/eieio.el ./emacs-lisp/eieio-base.el \ @@ -127,7 +133,7 @@ SUBDIRS_SUBDIRS = $(filter-out ${srcdir}/cedet% ${srcdir}/leim%,${SUBDIRS}) # cus-load and finder-inf are not explicitly requested by anything, so # we add them here to make sure they get built. -all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el +all: compile-main compile-native-main $(lisp)/cus-load.el $(lisp)/finder-inf.el PHONY_EXTRAS = .PHONY: all custom-deps finder-data autoloads update-subdirs $(PHONY_EXTRAS) @@ -281,6 +287,13 @@ $(THEFILE)c: -l bytecomp -f byte-compile-refresh-preloaded \ -f batch-byte-compile $(THEFILE) +THEFILE = no-such-file +.PHONY: $(THEFILE)n +$(THEFILE)n: + $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \ + -l comp -f byte-compile-refresh-preloaded \ + -f batch-native-compile $(THEFILE) + # 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 @@ -288,13 +301,16 @@ $(THEFILE)c: # subdirectories, to make sure require's and load's in the files being # compiled find the right files. -.SUFFIXES: .elc .el +.SUFFIXES: .eln .elc .el # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. .el.elc: $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< +.el.eln: + $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-native-compile $< + .PHONY: compile-first compile-main compile compile-always compile-first: $(COMPILE_FIRST) @@ -329,6 +345,21 @@ compile-main: gen-lisp compile-clean $(MAKE) compile-targets TARGETS="$$chunk"; \ done +# Obsiusly copy pasted from above. Just do it on elns + ignoring errors... +compile-native-main: gen-lisp compile-clean + @(cd $(lisp) && \ + els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \ + for el in ${MAIN_FIRST} $$els; do \ + test -f $$el || continue; \ + test ! -f $${el}c && \ + GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > /dev/null && \ + continue; \ + echo "$${el}n"; \ + done | xargs $(XARGS_LIMIT) echo) | \ + while read chunk; do \ + $(MAKE) -i compile-targets TARGETS="$$chunk"; \ + done + .PHONY: compile-clean # Erase left-over .elc files that do not have a corresponding .el file. compile-clean: @@ -338,6 +369,8 @@ compile-clean: if test -f "$$el" || test ! -f "$${el}c"; then :; else \ echo rm "$${el}c"; \ rm "$${el}c"; \ + echo rm "$${el}n"; \ + rm "$${el}n"; \ fi; \ done @@ -361,6 +394,8 @@ semantic: # Calling make recursively because suffix rule cannot have prerequisites. compile: $(LOADDEFS) autoloads compile-first $(MAKE) compile-main +# Ignore error for now cause we can't compile dynamic code + $(MAKE) -i compile-native-main # Compile all Lisp files. This is like 'compile' but compiles files # unconditionally. Some files don't actually get compiled because they diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 785e350e0e5..53d353858b3 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -1045,7 +1045,7 @@ write its autoloads into the specified file instead." ;; we don't want to depend on whether Emacs was ;; built with or without modules support, nor ;; what is the suffix for the underlying OS. - (unless (string-match "\\.\\(elc\\|so\\|dll\\)" suf) + (unless (string-match "\\.\\(elc\\|eln\\|so\\|dll\\)" suf) (push suf tmp))) (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))) (files (apply #'nconc diff --git a/src/Makefile.in b/src/Makefile.in index 6c65275d6da..faf24802791 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -513,14 +513,26 @@ lisp.mk: $(lispsource)/loadup.el sed -e 's/$$/.elc \\/' -e 's/\.el\.elc/.el/'; \ echo "" ) > $@ +shortnativelisp = +native_lisp.mk: $(lispsource)/loadup.el + @rm -f $@ + ${AM_V_GEN}( printf 'shortnativelisp = \\\n'; \ + sed -n 's/^[ \t]*(load "\([^"]*\)".*/\1/p' $< | \ + sed -e 's/$$/.eln \\/' -e 's/\.el\.eln/.el/'; \ + echo "" ) > $@ + -include lisp.mk +-include native_lisp.mk shortlisp_filter = leim/leim-list.el site-load.elc site-init.elc shortlisp := $(filter-out ${shortlisp_filter},${shortlisp}) +shortnativelisp_filter = leim/leim-list.el site-load.eln site-init.eln +shortnativelisp := $(filter-out ${shortnativelisp_filter},${shortnativelisp}) ## Place loaddefs.el first, so it gets generated first, since it is on ## the critical path (relevant in parallel compilations). ## We don't really need to sort, but may as well use it to remove duplicates. shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) lisp = $(addprefix ${lispsource}/,${shortlisp}) +nativelisp = $(addprefix ${lispsource}/,${shortnativelisp}) ## Construct full set of libraries to be linked. LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ @@ -571,7 +583,7 @@ ${lispintdir}/characters.elc: ${charscript:.el=.elc} ## since not all pieces are used on all platforms. But DOC depends ## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here. emacs$(EXEEXT): temacs$(EXEEXT) \ - lisp.mk $(etc)/DOC $(lisp) \ + lisp.mk native_lisp.mk $(etc)/DOC $(lisp) $(nativelisp) \ $(lispsource)/international/charprop.el ${charsets} ifeq ($(DUMPING),unexec) LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump @@ -721,7 +733,7 @@ bootstrap-clean: clean fi distclean: bootstrap-clean - rm -f Makefile lisp.mk + rm -f Makefile lisp.mk native_lisp.mk rm -fr $(DEPDIR) maintainer-clean: distclean @@ -788,6 +800,10 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\ THEFILE=$< $