[PATCH] emacs: Compute build dependencies to fix byte compile issues
Tomi Ollila
tomi.ollila at iki.fi
Sun May 19 07:33:24 PDT 2013
On Fri, May 17 2013, Austin Clements <amdragon at MIT.EDU> wrote:
> Previously, we simply byte compiled each Elisp source file
> independently. This is actually the wrong thing to do and can lead to
> issues with macros and performance issues with substitutions because
> 1) when the byte compiler encounters a (require 'x) form, it will load
> x.elc in preference to x.el, even if x.el is newer, and as a result
> may load old macro and substitution definitions and 2) if we update a
> macro or substitution definition in one file, we currently won't
> re-compile other files that depend on the file containing the
> definition.
>
> This patch addresses these problems by computing make dependency rules
> from the (require 'x) forms in the Elisp source files, which we inject
> into make's dependency database.
> ---
> emacs/Makefile.local | 12 +++++++++
> emacs/make-deps.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 78 insertions(+)
> create mode 100644 emacs/make-deps.el
>
> diff --git a/emacs/Makefile.local b/emacs/Makefile.local
> index fb82247..456700a 100644
> --- a/emacs/Makefile.local
> +++ b/emacs/Makefile.local
> @@ -22,6 +22,18 @@ emacs_images := \
>
> emacs_bytecode = $(emacs_sources:.el=.elc)
>
> +# Because of defmacro's and defsubst's, we have to account for load
> +# dependencies between Elisp files when byte compiling. Otherwise,
> +# the byte compiler may load an old .elc file when processing a
> +# "require" or we may fail to rebuild a .elc that depended on a macro
> +# from an updated file.
> +$(dir)/.eldeps: $(dir)/Makefile.local $(dir)/make-deps.el $(emacs_sources)
> + $(call quiet,EMACS) --directory emacs -batch -l make-deps.el \
> + -f batch-make-deps $(emacs_sources) > $@.tmp && \
> + (cmp -s $@.tmp $@ || mv $@.tmp $@)
The last line above could be in format
{ cmp -s $@.tmp $@ || mv $@.tmp $@; }
so that the expression is evaluated in current shell instead of a subshell.
You may consider changing this if you add year to copyright line.
Tomi
> +-include $(dir)/.eldeps
> +CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp
> +
> %.elc: %.el $(global_deps)
> $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
>
More information about the notmuch
mailing list