qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] trace: avoid unnecessary recompilation if n


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 2/2] trace: avoid unnecessary recompilation if nothing changed
Date: Mon, 27 Sep 2010 10:32:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Blue Swirl <address@hidden> writes:

> Add logic to detect changes in generated files. If the old
> and new files are identical, don't touch the generated file.
> This avoids a lot of churn since many files depend on trace.h.
>
> Signed-off-by: Blue Swirl <address@hidden>
> ---
>  Makefile |   18 ++++++++++++++++--
>  1 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index ff39025..085e8ed 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -107,10 +107,24 @@ ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
>  bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
>
>  trace.h: $(SRC_PATH)/trace-events config-host.mak
> -     $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h
> < $< > $@,"  GEN   $@")
> +     $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h
> < $< > address@hidden,"  GEN   $@")
> +     @if test -f $@; then \
> +       if ! cmp -s $@ address@hidden; then \
> +         mv address@hidden $@; \
> +       fi; \
> +      else \
> +       mv address@hidden $@; \
> +      fi

Why the conditional?  cmp -s fails fine when argument files don't exist.

Note that common versions of make including GNU Make do not stat a
rule's target to check whether the rule changed it.  Instead, they
assume it changed, and remake everything depending on it.

    address@hidden:~/tmp$ cat Makefile 
    foo: bar
            echo "Remaking foo"

    bar:
            [ -f $@ ] || touch $@ && echo "Touched bar"
    address@hidden:~/tmp$ rm -f foo
    address@hidden:~/tmp$ make
    [ -f bar ] || touch bar && echo "Touched bar"
    Touched bar
    echo "Remaking foo"
    Remaking foo
    address@hidden:~/tmp$ make
    echo "Remaking foo"
    Remaking foo

I doubt your patch avoids churn as advertized with such makes.

[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]