From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51918 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0GKg-0008KZ-MC for qemu-devel@nongnu.org; Mon, 27 Sep 2010 12:13:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0GKf-0007JJ-DR for qemu-devel@nongnu.org; Mon, 27 Sep 2010 12:13:38 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:62564) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0GKf-0007Ij-9Z for qemu-devel@nongnu.org; Mon, 27 Sep 2010 12:13:37 -0400 Received: by gya1 with SMTP id 1so2215698gya.4 for ; Mon, 27 Sep 2010 09:13:33 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4CA06938.7030106@redhat.com> References: <4CA06938.7030106@redhat.com> From: Blue Swirl Date: Mon, 27 Sep 2010 16:13:12 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH 2/2] trace: avoid unnecessary recompilation if nothing changed List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Markus Armbruster , qemu-devel On Mon, Sep 27, 2010 at 9:51 AM, Paolo Bonzini wrote: > On 09/27/2010 10:32 AM, Markus Armbruster wrote: >> Why the conditional? =C2=A0cmp -s fails fine when argument files don't e= xist. >> >> Note that common versions of make including GNU Make do not stat a >> rule's target to check whether the rule changed it. =C2=A0Instead, they >> assume it changed, and remake everything depending on it. >> >> =C2=A0 =C2=A0 =C2=A0armbru@blackfin:~/tmp$ cat Makefile >> =C2=A0 =C2=A0 =C2=A0foo: bar >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "Remaking foo" >> >> =C2=A0 =C2=A0 =C2=A0bar: >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[ -f $@ ] || touch $@&& = =C2=A0echo "Touched bar" >> =C2=A0 =C2=A0 =C2=A0armbru@blackfin:~/tmp$ rm -f foo >> =C2=A0 =C2=A0 =C2=A0armbru@blackfin:~/tmp$ make >> =C2=A0 =C2=A0 =C2=A0[ -f bar ] || touch bar&& =C2=A0echo "Touched bar" >> =C2=A0 =C2=A0 =C2=A0Touched bar >> =C2=A0 =C2=A0 =C2=A0echo "Remaking foo" >> =C2=A0 =C2=A0 =C2=A0Remaking foo >> =C2=A0 =C2=A0 =C2=A0armbru@blackfin:~/tmp$ make >> =C2=A0 =C2=A0 =C2=A0echo "Remaking foo" >> =C2=A0 =C2=A0 =C2=A0Remaking foo >> >> I doubt your patch avoids churn as advertized with such makes. > > Indeed, see how it's done for config-*.h. > > # Uses generic rule in rules.mak > trace.h: trace.h-timestamp > trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak > =C2=A0 =C2=A0 =C2=A0 =C2=A0$(call quiet-command,sh $(SRC_PATH)/tracetool = --$(TRACE_BACKEND) -h < $< > $@," =C2=A0GEN =C2=A0trace.h) > =C2=A0 =C2=A0 =C2=A0 =C2=A0@cmp $@ trace.h >/dev/null 2>&1 || cp $@ trace= .h > > (untested). I just copied the rule from %/config-devices.mak. Is also that rule then incorrect? Perhaps there could be a macro for this, not unlike move-if-change script in various GNU packages?