git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Re: Re: Re: Segmentation fault with latest git (070c57df)
@ 2013-02-01 10:59 Jongman Heo
  2013-02-01 22:38 ` Jonathan Nieder
  2013-02-01 22:45 ` [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies Jonathan Nieder
  0 siblings, 2 replies; 4+ messages in thread
From: Jongman Heo @ 2013-02-01 10:59 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, Thomas Rast, git, Antoine Pelisse


>> [...]
>>  Finished prerequisites of target file `builtin/fetch.o'.
>>  Prerequisite `builtin/fetch.c' is older than target `builtin/fetch.o'.
>>  Prerequisite `GIT-CFLAGS' is older than target `builtin/fetch.o'.
>> No need to remake target `builtin/fetch.o'.
>
>But it doesn't stimulate any prerequisites in make, which is weird.
>What's in builtin/.depend/fetch.o.d?
>
>-Peff

Hi, 

please see below~.

$ cat builtin/.depend/fetch.o.d            
fetch.o: builtin/fetch.c cache.h git-compat-util.h compat/bswap.h \
  strbuf.h hash.h advice.h gettext.h convert.h refs.h commit.h object.h \
  tree.h decorate.h builtin.h cache.h commit.h notes.h string-list.h \
  string-list.h remote.h transport.h remote.h run-command.h \
  parse-options.h sigchain.h submodule.h connected.h argv-array.h

cache.h:

git-compat-util.h:

compat/bswap.h:

strbuf.h:

hash.h:

advice.h:

gettext.h:

convert.h:

refs.h:

commit.h:

object.h:

tree.h:

decorate.h:

builtin.h:

cache.h:

commit.h:

notes.h:

string-list.h:

string-list.h:

remote.h:

transport.h:

remote.h:

run-command.h:

parse-options.h:

sigchain.h:

submodule.h:

connected.h:

argv-array.h:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Re: Re: Segmentation fault with latest git (070c57df)
  2013-02-01 10:59 Re: Re: Re: Segmentation fault with latest git (070c57df) Jongman Heo
@ 2013-02-01 22:38 ` Jonathan Nieder
  2013-02-01 22:45 ` [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies Jonathan Nieder
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Nieder @ 2013-02-01 22:38 UTC (permalink / raw)
  To: Jongman Heo; +Cc: Jeff King, Junio C Hamano, Thomas Rast, git, Antoine Pelisse

Jongman Heo wrote:

>> But it doesn't stimulate any prerequisites in make, which is weird.
>> What's in builtin/.depend/fetch.o.d?
[...]
> please see below~.
>
> $ cat builtin/.depend/fetch.o.d            
> fetch.o: builtin/fetch.c cache.h git-compat-util.h compat/bswap.h \

That's the problem.  See the following thread:

  http://thread.gmane.org/gmane.comp.version-control.git/185625/focus=185680

Currently when COMPUTE_HEADER_DEPENDENCIES=auto git tests for
dependency generation support by checking the output and exit status
from the following command:

	$(CC) $(ALL_CFLAGS) -c -MF /dev/null -MMD -MP \
		-x c /dev/null -o /dev/null 2>&1

Perhaps this can be improved?  Even something as simple as a ccache
version test could presumably help a lot.

Hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies
  2013-02-01 10:59 Re: Re: Re: Segmentation fault with latest git (070c57df) Jongman Heo
  2013-02-01 22:38 ` Jonathan Nieder
@ 2013-02-01 22:45 ` Jonathan Nieder
  2013-02-02  0:03   ` Jeff King
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2013-02-01 22:45 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Jongman Heo, Jeff King, Thomas Rast, git, Antoine Pelisse,
	Nguyễn Thái Ngọc Duy

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 = 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ễn Thái Ngọc Duy <pclouds@gmail.com>
Reported-by: : 허종만 <jongman.heo@samsung.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 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
 
 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
 dep_check = $(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 = yes
@@ -1843,7 +1844,7 @@ $(dep_dirs):
 
 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
 dep_file = $(dir $@).depend/$(notdir $@).d
-dep_args = -MF $(dep_file) -MMD -MP
+dep_args = -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)
-- 
1.8.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies
  2013-02-01 22:45 ` [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies Jonathan Nieder
@ 2013-02-02  0:03   ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2013-02-02  0:03 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Junio C Hamano, Jongman Heo, Thomas Rast, git, Antoine Pelisse,
	Nguyễn Thái Ngọc Duy

On Fri, Feb 01, 2013 at 02:45:19PM -0800, Jonathan Nieder wrote:

> 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.

Thanks, I missed the original thread last year, but this does look like
the same problem. The fixed version of ccache is a few years old, but
the OP did mention RHEL5, so that makes sense.

>  missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
>  dep_file = $(dir $@).depend/$(notdir $@).d
> -dep_args = -MF $(dep_file) -MMD -MP
> +dep_args = -MF $(dep_file) -MQ $@ -MMD -MP

This looks like a nice simple solution. The only downside would be if
-MQ is not supported by some gcc versions (in which case we would do
better to improve the "can we use computed dependencies" check, and
punish people on old ccache, not people on old gcc who otherwise could
work without -MQ).

As far as I can tell, though, -MQ came along with the other dependency
generation options in 2001:

  http://gcc.gnu.org/news/dependencies.html

which means it's not a problem to rely on. So the patch looks good to
me.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-02  0:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-01 10:59 Re: Re: Re: Segmentation fault with latest git (070c57df) Jongman Heo
2013-02-01 22:38 ` Jonathan Nieder
2013-02-01 22:45 ` [PATCH resend] Makefile: explicitly set target name for autogenerated dependencies Jonathan Nieder
2013-02-02  0:03   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).