From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Nieder Subject: [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies Date: Fri, 1 Feb 2013 14:45:19 -0800 Message-ID: <20130201224519.GI12368@google.com> References: <27376267.797831359716377823.JavaMail.weblogic@epml01> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Jongman Heo , Jeff King , Thomas Rast , git , Antoine Pelisse , =?utf-8?B?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= Duy To: Junio C Hamano X-From: git-owner@vger.kernel.org Fri Feb 01 23:45:48 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U1PMh-0003kP-Gq for gcvg-git-2@plane.gmane.org; Fri, 01 Feb 2013 23:45:47 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757879Ab3BAWp0 convert rfc822-to-quoted-printable (ORCPT ); Fri, 1 Feb 2013 17:45:26 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:59793 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756741Ab3BAWpY (ORCPT ); Fri, 1 Feb 2013 17:45:24 -0500 Received: by mail-pa0-f46.google.com with SMTP id kp14so2452498pab.33 for ; Fri, 01 Feb 2013 14:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=p0S9P8cgKt9rtKrHu/Yo9vupvp0GOpLTadtdThxgJmk=; b=O7eHsX+xEp1i/Iw25yw7tKQjFahOkSS+eWA3/W9vBpny69fiL+XfS1YK7Fjugd6Q2A 77OB7zCj+YyJAKEZXtnxCibilfHcqfgIC23iPvLrUjvlrL0Pmfc+9Rsg9U+D7NVGFZnL o2CnkdhBQpCCZ6g7c6+sQmgVQoPQu43FwDmq8xCeEAM2CVMvUm++DDtkja4etzuncfDj S8/ke2lUISpHStEDXVzDVGSJ/28Ckd3wOvYOf9FhihZqBbFEgDLG5ry4sE2weJb9jOlw 8ftw1qaoMgYNp5A0mkFYdndapjRQOuhIOlp8Ufj/5xzyzFYNAO/C0Zk23Jw9qEx7A5Za 4rDQ== X-Received: by 10.68.219.71 with SMTP id pm7mr36215039pbc.82.1359758724136; Fri, 01 Feb 2013 14:45:24 -0800 (PST) Received: from google.com ([2620:0:1000:5b00:b6b5:2fff:fec3:b50d]) by mx.google.com with ESMTPS id nj1sm9669493pbc.13.2013.02.01.14.45.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 01 Feb 2013 14:45:22 -0800 (PST) Content-Disposition: inline In-Reply-To: <27376267.797831359716377823.JavaMail.weblogic@epml01> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Date: Fri, 18 Nov 2011 17:23:24 -0600 "gcc -MF depfile -MMD -MP -c -o path/to/file.o" produces a makefile snippet named "depfile" describing what files are needed to build the target given by "-o". When ccache versions before v3.0pre0~187 (Fix handling of the -MD and -MDD options, 2009-11-01) run, they execute gcc -MF depfile -MMD -MP -E instead to get the final content for hashing. Notice that the "-c -o" combination is replaced by "-E". The result is a target name without a leading path. Thus when building git with such versions of ccache with COMPUTE_HEADER_DEPENDENCIES enabled, the generated makefile snippets define dependencies for the wrong target: $ make builtin/add.o GIT_VERSION =3D 1.7.8.rc3 * new build flags or prefix CC builtin/add.o $ head -1 builtin/.depend/add.o.d add.o: builtin/add.c cache.h git-compat-util.h compat/bswap.h strbuf.h= \ After a change in a header file, object files in a subdirectory are not automatically rebuilt by "make": $ touch cache.h $ make builtin/add.o $ Luckily we can prevent trouble by explicitly supplying the name of the target to ccache and gcc, using the -MQ option. Do so. Reported-and-tested-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy Reported-by: : =ED=97=88=EC=A2=85=EB=A7=8C Signed-off-by: Jonathan Nieder --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 731b6a8..5a2e02d 100644 --- a/Makefile +++ b/Makefile @@ -973,7 +973,8 @@ endif =20 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto) dep_check =3D $(shell $(CC) $(ALL_CFLAGS) \ - -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \ + -c -MF /dev/null -MQ /dev/null -MMD -MP \ + -x c /dev/null -o /dev/null 2>&1; \ echo $$?) ifeq ($(dep_check),0) override COMPUTE_HEADER_DEPENDENCIES =3D yes @@ -1843,7 +1844,7 @@ $(dep_dirs): =20 missing_dep_dirs :=3D $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs)= ) dep_file =3D $(dir $@).depend/$(notdir $@).d -dep_args =3D -MF $(dep_file) -MMD -MP +dep_args =3D -MF $(dep_file) -MQ $@ -MMD -MP ifdef CHECK_HEADER_DEPENDENCIES $(error cannot compute header dependencies outside a normal build. \ Please unset CHECK_HEADER_DEPENDENCIES and try again) --=20 1.8.1