Re: [PATCH 1/1] emacs: always write emacs/.eldeps when the target is remade

Subject: Re: [PATCH 1/1] emacs: always write emacs/.eldeps when the target is remade

Date: Fri, 14 Feb 2014 21:24:15 +0200

To: Austin Clements

Cc: notmuch@notmuchmail.org

From: Tomi Ollila


On Thu, Feb 13 2014, Austin Clements <amdragon@MIT.EDU> wrote:

> Quoth Tomi Ollila on Feb 13 at  9:26 am:
>> On Thu, Feb 13 2014, Austin Clements <amdragon@MIT.EDU> wrote:
>> 
>> > Quoth Tomi Ollila on Jan 25 at 12:21 pm:
>> >> So that the target is newer than its prerequisites.
>> >> ---
>> >>  emacs/Makefile.local | 3 +--
>> >>  1 file changed, 1 insertion(+), 2 deletions(-)
>> >> 
>> >> diff --git a/emacs/Makefile.local b/emacs/Makefile.local
>> >> index 42bfbd9..d5d402e 100644
>> >> --- a/emacs/Makefile.local
>> >> +++ b/emacs/Makefile.local
>> >> @@ -32,8 +32,7 @@ emacs_bytecode = $(emacs_sources:.el=.elc)
>> >>  ifeq ($(HAVE_EMACS),1)
>> >>  $(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 $@)
>> >> +		-f batch-make-deps $(emacs_sources) > $@.tmp && mv $@.tmp $@
>> >>  -include $(dir)/.eldeps
>> >>  endif
>> >>  CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp
>> >
>> > Is this just so the rule doesn't get run again on the next make
>> > invocation (unless, of course, a dependent changed)?
>> 
>> Basically yes. I did multiple builds in rapid succession when developing
>> something and this thing confused me quite a lot in the beginning...
>> 
>> > Interestingly, if any of the dependents have changed, but in ways that
>> > don't affect .eldeps, this change will make the build more expensive
>> > because it will trigger a make restart after .eldeps is updated.
>> 
>> I wondered what was the reason for the recipe you've chosen here, has
>> it something to do with inodes or something ;) (and were going to ask
>> an alternative to touch (or even : > $@) the target...
>> 
>> ... but now I understand. E.g. change in notmuch-lib.el will cause *all* 
>> .el files to be re-bytecompiled after this change. 
>
> This is unrelated to the cmp in the recipe.  A change in
> notmuch-lib.el *must* cause almost all .el files to be recompiled
> because they almost all require it and may use macros from it.  If you
> touch, e.g., notmuch-hello.el, you'll see that very little is rebuilt
> (with or without this patch).
>
>> An alternative to this patch would be adding a message to the rule
>> which informs user to touch .eldeps to avoid re-doing .eldeps if
>> that irritates one :D
>> 
>> something like:
>> 
>> (cmp -s $@.tmp $@ && \
>>      echo "touch $@ to avoid redoing this target" || mv $@.tmp $@)
>
> I think this patch is good as it is; I was just pointing out that the
> change also has a performance drawback in some situations.  (Knowing
> make, there's probably *some* way to get the best of both worlds and
> it's probably really ugly.)

Ah, now I understand, because emacs/Makefile.local includes emacs/.eldeps
when it notices mtime of emacs/.eldeps changes it restarts itself...

... to compare with current behaviour:

$ make
...
$ touch emacs/notmuch.el
$ make
...
$ make
Use "make V=1" to see the verbose compile lines.
EMACS emacs/.eldeps
make: Nothing to be done for `all'.
$ make
Use "make V=1" to see the verbose compile lines.
EMACS emacs/.eldeps
make: Nothing to be done for `all'.
$ make
Use "make V=1" to see the verbose compile lines.
EMACS emacs/.eldeps
make: Nothing to be done for `all'.

It will rerun emacs -L emacs -batch -l make-deps.el -f batch-make-deps ...
over and over again...

I thought I figured out a solution involving .eldeps.stamp file but
that turned out to be no-go... (circular dependency netween .eldeps.stamp
and Makefile.local).

So, with this if one edits emacs/* files and keeps building byte-compiled
versions often, make will both run EMACS emacs/.eldeps and restarting
-- and when moving to edit other files both of the above stops. Without
this change after editing emacs/* files EMACS emacs/.eldeps will be
executed until it is touched or make clean executed (I wonder how make
handles rebuilding emacs/.eldeps while doing make clean ;)


Tomi

Thread: