{"thread":{"id":"28969","subject":"A flaw in dep generation with gcc -MMD?","startedAt":"2011-11-18T02:24:12Z","lastAt":"2011-11-19T05:13:45Z","messageCount":19,"participants":["Nguyen Thai Ngoc Duy","Jonathan Nieder","Miles Bader","Junio C Hamano","Andreas Schwab","Samuel Bronson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"179665","messageId":"CACsJy8BZMDyf4MCiKxPJ5Z+XS+C-MC82SpMFyWgiXmb9xCnScw@mail.gmail.com","threadId":"28969","inReplyTo":null,"subject":"A flaw in dep generation with gcc -MMD?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-18T02:24:12Z","receivedAt":"2011-11-18T02:24:12Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Hi,\n\nMy builtin/.depend/add.o.d says\n\nadd.o: .... cache.h ...\n\nShouldn't it be \"builtin/add.o: ... cache.h ...\"? I tried to touch\ncache.h and \"make builtin/add.o\". It did not remake builtin/add.o. If\nI modify add.o.d by hand and remake, it works.\n-- \nDuy\n"},{"id":"179667","messageId":"20111118034142.GA25228@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"CACsJy8BZMDyf4MCiKxPJ5Z+XS+C-MC82SpMFyWgiXmb9xCnScw@mail.gmail.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T03:41:42Z","receivedAt":"2011-11-18T03:41:42Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> My builtin/.depend/add.o.d says\n>\n> add.o: .... cache.h ...\n\nInteresting.  What compiler do you use?\n\nThanks for finding it,\nJonathan\n\n $ head -1 builtin/.depend/add.o.d\n builtin/add.o: builtin/add.c cache.h git-compat-util.h compat/bswap.h \\\n $ gcc --version | head -1\n gcc (Debian 4.6.2-4) 4.6.2\n"},{"id":"179668","messageId":"CACsJy8A44PFtYrm8NQU+48sVkOe8mjJyO9opO5-TwRtAd-TKsQ@mail.gmail.com","threadId":"28969","inReplyTo":"20111118034142.GA25228@elie.hsd1.il.comcast.net","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-18T03:56:11Z","receivedAt":"2011-11-18T03:56:11Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Nov 18, 2011 at 10:41 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nguyen Thai Ngoc Duy wrote:\n>\n>> My builtin/.depend/add.o.d says\n>>\n>> add.o: .... cache.h ...\n>\n> Interesting.  What compiler do you use?\n\n$ gcc --version\ngcc (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4\n\n>  $ head -1 builtin/.depend/add.o.d\n>  builtin/add.o: builtin/add.c cache.h git-compat-util.h compat/bswap.h \\\n>  $ gcc --version | head -1\n>  gcc (Debian 4.6.2-4) 4.6.2\n\nHmm.. I guess it's my compiler's fault then. Next question, how can I\ndisable this feature?\n-- \nDuy\n"},{"id":"179670","messageId":"buor516m3w7.fsf@dhlpc061.dev.necel.com","threadId":"28969","inReplyTo":"CACsJy8A44PFtYrm8NQU+48sVkOe8mjJyO9opO5-TwRtAd-TKsQ@mail.gmail.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-11-18T04:49:12Z","receivedAt":"2011-11-18T04:49:12Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>> Interesting.  What compiler do you use?\n>\n> $ gcc --version\n> gcc (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4\n\nFWIW, gcc 4.4.6 on debian does the correct thing too...\n\n-Miles\n\n-- \nYo mama's so fat when she gets on an elevator it HAS to go down.\n"},{"id":"179671","messageId":"20111118045742.GA25145@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"CACsJy8A44PFtYrm8NQU+48sVkOe8mjJyO9opO5-TwRtAd-TKsQ@mail.gmail.com","subject":"[PATCH] Makefile: add option to disable automatic dependency generation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T04:57:42Z","receivedAt":"2011-11-18T04:57:42Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Duy noticed that now that the COMPUTE_HEADER_DEPENDENCIES feature is\nturned on automatically for compilers that support it (see\nv1.7.8-rc0~142^2~1, 2011-08-18), there is no easy way to force it off.\nFor example, setting COMPUTE_HEADER_DEPENDENCIES to the empty string\nin config.mak just tells the makefile to treat it as undefined and\nrun a test command to see if the -MMD option is supported.\n\nIntroduce a new NO_COMPUTE_HEADER_DEPENDENCIES variable that forces\nthe feature off.  The new semantics:\n\n - If NO_COMPUTE_HEADER_DEPENDENCIES is set to a nonempty string,\n   the -MMD option will not be used.  The build relies on hard-coded\n   dependencies in the \"ifndef USE_COMPUTED_HEADER_DEPENDENCIES\"\n   section of the Makefile instead.\n\n - If COMPUTE_HEADER_DEPENDENCIES is empty and NO_COMPUTE_... is\n   nonempty, the build uses gcc's on-the-fly dependency generation\n   feature.\n\n - If neither is nonempty, the makefile runs a quick test command\n   to decide whether the compiler supports the -MMD option and\n   whether to enable this feature.\n\nInspired-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nNguyen Thai Ngoc Duy wrote:\n\n> Hmm.. I guess it's my compiler's fault then. Next question, how can I\n> disable this feature?\n\n\"make COMPUTE_HEADER_DEPENDENCIES=\" works.  But there's no way aside\nfrom \"override COMPUTE_HEADER_DEPENDENCIES=\" to do that in config.mak.\nAnd yuck.\n\nBy the way, I'm not convinced it's your compiler's fault.  It might be\nmy compiler's fault.  More reading to do...\n\n Makefile |   15 ++++++++++++++-\n 1 files changed, 14 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ee34eab8..e4a658f6 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -250,6 +250,13 @@ all::\n #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',\n #   DEFAULT_EDITOR='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork'\n #\n+# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option\n+# and you want to avoid rebuilding objects when an unrelated header file\n+# changes.\n+#\n+# Define NO_COMPUTE_HEADER_DEPENDENCIES if you want to disable automatic\n+# dependency generation even though your compiler is detected to support it.\n+#\n # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded\n # dependency rules.\n #\n@@ -1245,10 +1252,16 @@ endif\n endif\n \n ifdef CHECK_HEADER_DEPENDENCIES\n+NO_COMPUTE_HEADER_DEPENDENCIES = YesPlease\n+endif\n+\n+ifdef NO_COMPUTE_HEADER_DEPENDENCIES\n COMPUTE_HEADER_DEPENDENCIES =\n USE_COMPUTED_HEADER_DEPENDENCIES =\n-else\n+endif\n+\n ifndef COMPUTE_HEADER_DEPENDENCIES\n+ifndef NO_COMPUTE_HEADER_DEPENDENCIES\n dep_check = $(shell $(CC) $(ALL_CFLAGS) \\\n \t-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \\\n \techo $$?)\n-- \n1.7.8.rc2\n"},{"id":"179672","messageId":"20111118050003.GB25145@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"20111118045742.GA25145@elie.hsd1.il.comcast.net","subject":"Re: [PATCH] Makefile: add option to disable automatic dependency generation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T05:00:03Z","receivedAt":"2011-11-18T05:00:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n\n>  - If COMPUTE_HEADER_DEPENDENCIES is empty and NO_COMPUTE_... is\n>    nonempty, the build uses gcc's on-the-fly dependency generation\n>    feature.\n\nErm.  This should say:\n\n  \"- If COMPUTE_HEADER_DEPENDENCIES is nonempty and NO_COMPUTE_... is\n     empty,\"\n\nSorry for the noise.\n"},{"id":"179675","messageId":"7vty62klg9.fsf@alter.siamese.dyndns.org","threadId":"28969","inReplyTo":"20111118045742.GA25145@elie.hsd1.il.comcast.net","subject":"Re: [PATCH] Makefile: add option to disable automatic dependency generation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-18T06:12:54Z","receivedAt":"2011-11-18T06:12:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Duy noticed that now that the COMPUTE_HEADER_DEPENDENCIES feature is\n> turned on automatically for compilers that support it (see\n> v1.7.8-rc0~142^2~1, 2011-08-18), there is no easy way to force it off.\n> For example, setting COMPUTE_HEADER_DEPENDENCIES to the empty string\n> in config.mak just tells the makefile to treat it as undefined and\n> run a test command to see if the -MMD option is supported.\n>\n> Introduce a new NO_COMPUTE_HEADER_DEPENDENCIES variable that forces\n> the feature off.\n\nEek. At least at the end user UI level, couldn't we do this as a tristate?\nE.g. \"YesPlease\" (or anything that begins with Y if you are ambitious) to\nexplicitly enable, empty (or \"auto\") to autodetect, and anything else to\ndecline?\n\nEven better, couldn't we either (1) rearrange .dep/ files somehow, so that\ncompiler difference does not matter, or (2) have dep_check to perform a\ntrial run to detect versions of compilers that produce the output that we\ncannot use?\n"},{"id":"179677","messageId":"20111118062150.GC25145@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"7vty62klg9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Makefile: add option to disable automatic dependency generation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T06:21:51Z","receivedAt":"2011-11-18T06:21:51Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> Eek. At least at the end user UI level, couldn't we do this as a tristate?\n> E.g. \"YesPlease\" (or anything that begins with Y if you are ambitious) to\n> explicitly enable, empty (or \"auto\") to autodetect, and anything else to\n> decline?\n\nAh, I didn't mind the UI so much.  Handling\n\n\tCOMPUTE_HEADER_DEPENDENCIES_FORCE = (yes | no | auto)\n\nshould be doable.  I'd suggest making any other value error out, so\ntypos don't result in mysterious behavior.\n\n> Even better, couldn't we either (1) rearrange .dep/ files somehow, so that\n> compiler difference does not matter\n\nYes, I'm working on an incantation all the compilers like (it\nshouldn't be hard --- adding an -MQ option should be enough, but I\nwant to understand the bug first).  But even with such a fix, I think\nit will be important to have a way to turn the feature off.  When\nsomeone using a compiler without -MMD support reports a bug, wouldn't\nit be nice to be able to reproduce it?\n"},{"id":"179684","messageId":"20111118095820.GF25145@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"7vty62klg9.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] Makefile: add option to disable automatic dependency generation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T09:58:21Z","receivedAt":"2011-11-18T09:58:21Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Now that the COMPUTE_HEADER_DEPENDENCIES feature is turned on\nautomatically for compilers that support it (see v1.7.8-rc0~142^2~1,\n2011-08-18), there is no easy way to force it off.  For example,\nsetting COMPUTE_HEADER_DEPENDENCIES to the empty string in config.mak\njust tells the makefile to treat it as undefined and run a test\ncommand to see if the -MMD option is supported.\n\nSo allow setting COMPUTE_HEADER_DEPENDENCIES=no to explicitly force\nthe feature off.  The new semantics:\n\n - \"yes\" means to explicitly enable the feature\n - \"no\" means to disable it\n - \"auto\" means to autodetect\n\nThe default is still \"auto\".  Any value other than these three will\ncause the build to error out with a descriptive message so typos and\nstale settings in config.mak don't result in mysterious behavior.\n\n\tMakefile:1278: *** please set COMPUTE_HEADER_DEPENDENCIES to\n\tyes, no, or auto (not \"1\").  Stop.\n\nSo now when someone using a compiler without -MMD support reports\ntrouble building git, you can reproduce it by running \"make\nCOMPUTE_HEADER_DEPENDENCIES=no\".\n\nSuggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nImproved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJunio C Hamano wrote:\n\n> Eek. At least at the end user UI level, couldn't we do this as a tristate?\n\nNice idea.  Here it is.\n\n Makefile |   31 ++++++++++++++++++++++++-------\n 1 files changed, 24 insertions(+), 7 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 34ac7957..b1c80a67 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -250,6 +250,12 @@ all::\n #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',\n #   DEFAULT_EDITOR='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork'\n #\n+# Define COMPUTE_HEADER_DEPENDENCIES to \"yes\" if you want dependencies on\n+# header files to be automatically computed, to avoid rebuilding objects when\n+# an unrelated header file changes.  Define it to \"no\" to use the hard-coded\n+# dependency rules.  The default is \"auto\", which means to use computed header\n+# dependencies if your compiler is detected to support it.\n+#\n # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded\n # dependency rules.\n #\n@@ -1246,21 +1252,32 @@ endif\n endif\n \n ifdef CHECK_HEADER_DEPENDENCIES\n-COMPUTE_HEADER_DEPENDENCIES =\n+COMPUTE_HEADER_DEPENDENCIES = no\n USE_COMPUTED_HEADER_DEPENDENCIES =\n-else\n+endif\n+\n ifndef COMPUTE_HEADER_DEPENDENCIES\n+COMPUTE_HEADER_DEPENDENCIES = auto\n+endif\n+\n+ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)\n dep_check = $(shell $(CC) $(ALL_CFLAGS) \\\n \t-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \\\n \techo $$?)\n ifeq ($(dep_check),0)\n-COMPUTE_HEADER_DEPENDENCIES=YesPlease\n-endif\n+override COMPUTE_HEADER_DEPENDENCIES = yes\n+else\n+override COMPUTE_HEADER_DEPENDENCIES = no\n endif\n endif\n \n-ifdef COMPUTE_HEADER_DEPENDENCIES\n+ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)\n USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease\n+else\n+ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)\n+$(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \\\n+(not \"$(COMPUTE_HEADER_DEPENDENCIES)\"))\n+endif\n endif\n \n ifdef SANE_TOOL_PATH\n@@ -1907,7 +1924,7 @@ OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)\n dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)\n dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))\n \n-ifdef COMPUTE_HEADER_DEPENDENCIES\n+ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)\n $(dep_dirs):\n \t@mkdir -p $@\n \n@@ -1920,7 +1937,7 @@ Please unset CHECK_HEADER_DEPENDENCIES and try again)\n endif\n endif\n \n-ifndef COMPUTE_HEADER_DEPENDENCIES\n+ifneq ($(COMPUTE_HEADER_DEPENDENCIES),yes)\n ifndef CHECK_HEADER_DEPENDENCIES\n dep_dirs =\n missing_dep_dirs =\n-- \n1.7.8.rc2\n"},{"id":"179685","messageId":"20111118100202.GG25145@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"20111118095820.GF25145@elie.hsd1.il.comcast.net","subject":"[PATCH] Makefile: add missing header file dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T10:02:02Z","receivedAt":"2011-11-18T10:02:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"When the streaming filter API was introduced in v1.7.7-rc0~60^2~7\n(2011-05-20), we forgot to add its header to LIB_H.  Most translation\nunits depend on streaming.h via cache.h.\n\nv1.7.5-rc0~48 (Fix sparse warnings, 2011-03-22) introduced undeclared\ndependencies by url.o on url.h and thread-utils.o on thread-utils.h.\n\nNoticed by make CHECK_HEADER_DEPENDENCIES=1.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nSome makefile buglets found while testing.\n\n Makefile |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ee34eab8..34ac7957 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -518,6 +518,7 @@ LIB_H += compat/win32/syslog.h\n LIB_H += compat/win32/poll.h\n LIB_H += compat/win32/dirent.h\n LIB_H += connected.h\n+LIB_H += convert.h\n LIB_H += csum-file.h\n LIB_H += decorate.h\n LIB_H += delta.h\n@@ -2009,13 +2010,13 @@ builtin/branch.o builtin/checkout.o builtin/clone.o builtin/reset.o branch.o tra\n builtin/bundle.o bundle.o transport.o: bundle.h\n builtin/bisect--helper.o builtin/rev-list.o bisect.o: bisect.h\n builtin/clone.o builtin/fetch-pack.o transport.o: fetch-pack.h\n-builtin/grep.o builtin/pack-objects.o transport-helper.o: thread-utils.h\n+builtin/grep.o builtin/pack-objects.o transport-helper.o thread-utils.o: thread-utils.h\n builtin/send-pack.o transport.o: send-pack.h\n builtin/log.o builtin/shortlog.o: shortlog.h\n builtin/prune.o builtin/reflog.o reachable.o: reachable.h\n builtin/commit.o builtin/revert.o wt-status.o: wt-status.h\n builtin/tar-tree.o archive-tar.o: tar.h\n-connect.o transport.o http-backend.o: url.h\n+connect.o transport.o url.o http-backend.o: url.h\n http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h\n http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h\n \n-- \n1.7.8.rc2\n"},{"id":"179686","messageId":"CACsJy8AY9bFR_DXnOhbfMGFBD4Ep6OmKF4EiCgUdNiZi-rjMLA@mail.gmail.com","threadId":"28969","inReplyTo":"20111118095820.GF25145@elie.hsd1.il.comcast.net","subject":"Re: [PATCH v2] Makefile: add option to disable automatic dependency generation","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-18T10:07:44Z","receivedAt":"2011-11-18T10:07:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Nov 18, 2011 at 4:58 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Now that the COMPUTE_HEADER_DEPENDENCIES feature is turned on\n> automatically for compilers that support it (see v1.7.8-rc0~142^2~1,\n> 2011-08-18), there is no easy way to force it off.  For example,\n> setting COMPUTE_HEADER_DEPENDENCIES to the empty string in config.mak\n> just tells the makefile to treat it as undefined and run a test\n> command to see if the -MMD option is supported.\n>\n> So allow setting COMPUTE_HEADER_DEPENDENCIES=no to explicitly force\n> the feature off.  The new semantics:\n>\n>  - \"yes\" means to explicitly enable the feature\n>  - \"no\" means to disable it\n>  - \"auto\" means to autodetect\n>\n> The default is still \"auto\".  Any value other than these three will\n> cause the build to error out with a descriptive message so typos and\n> stale settings in config.mak don't result in mysterious behavior.\n>\n>        Makefile:1278: *** please set COMPUTE_HEADER_DEPENDENCIES to\n>        yes, no, or auto (not \"1\").  Stop.\n>\n> So now when someone using a compiler without -MMD support reports\n> trouble building git, you can reproduce it by running \"make\n> COMPUTE_HEADER_DEPENDENCIES=no\".\n>\n> Suggested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Improved-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n\nTested-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n-- \nDuy\n"},{"id":"179693","messageId":"CACsJy8BuCdT3rRjc5u6Ex5RRgSbL_0SFF0GW-dTGqet4sG2cwg@mail.gmail.com","threadId":"28969","inReplyTo":"buor516m3w7.fsf@dhlpc061.dev.necel.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-18T11:34:25Z","receivedAt":"2011-11-18T11:34:25Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Nov 18, 2011 at 11:49 AM, Miles Bader <miles@gnu.org> wrote:\n> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>>> Interesting.  What compiler do you use?\n>>\n>> $ gcc --version\n>> gcc (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4\n>\n> FWIW, gcc 4.4.6 on debian does the correct thing too...\n>\n\nOK it's not gcc problem. I upgraded to 4.5.3 and still had the same\nproblem. I used ccache though. Without ccache, gcc produced correct\n.o.d files.\n-- \nDuy\n"},{"id":"179702","messageId":"CACsJy8CKmjq01KoLRzOnnaf6RwFCQJfjxziqKTZW9HDyd8CagA@mail.gmail.com","threadId":"28969","inReplyTo":"CACsJy8BuCdT3rRjc5u6Ex5RRgSbL_0SFF0GW-dTGqet4sG2cwg@mail.gmail.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-18T14:12:02Z","receivedAt":"2011-11-18T14:12:02Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Nov 18, 2011 at 6:34 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:\n> OK it's not gcc problem. I upgraded to 4.5.3 and still had the same\n> problem. I used ccache though. Without ccache, gcc produced correct\n> .o.d files.\n\n\"gcc -MF depfile -MMD -MP -c -o path/to/file.o\" will produce \"depfile\"\nwith target given by \"-o\". When ccache runs, it executes \"gcc -MF\ndepfile -MMD -MP -E\" instead to get the final content for hashing.\nNotice that \"-c -o\" combination is replaced by \"-E\". The latter\nproduces target without leading path.\n\nNot sure if I should report this to ccache or gcc. In the meantime,\nmay be we should recognize the situation and switch off\nCOMPUTE_HEADER_DEPENDENCIES when ccache is used (maybe hard).\n-- \nDuy\n"},{"id":"179716","messageId":"loom.20111118T191851-152@post.gmane.org","threadId":"28969","inReplyTo":"CACsJy8CKmjq01KoLRzOnnaf6RwFCQJfjxziqKTZW9HDyd8CagA@mail.gmail.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Samuel Bronson","fromEmail":"naesten@gmail.com","sentAt":"2011-11-18T18:30:05Z","receivedAt":"2011-11-18T18:30:05Z","isPatch":false,"sender":{"key":"naesten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13903?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds <at> gmail.com> writes:\n\n> \n> On Fri, Nov 18, 2011 at 6:34 PM, Nguyen Thai Ngoc Duy <pclouds <at> gmail.com> \nwrote:\n> > OK it's not gcc problem. I upgraded to 4.5.3 and still had the same\n> > problem. I used ccache though. Without ccache, gcc produced correct\n> > .o.d files.\n> \n> \"gcc -MF depfile -MMD -MP -c -o path/to/file.o\" will produce \"depfile\"\n> with target given by \"-o\". When ccache runs, it executes \"gcc -MF\n> depfile -MMD -MP -E\" instead to get the final content for hashing.\n> Notice that \"-c -o\" combination is replaced by \"-E\". The latter\n> produces target without leading path.\n> \n> Not sure if I should report this to ccache or gcc. In the meantime,\n> may be we should recognize the situation and switch off\n> COMPUTE_HEADER_DEPENDENCIES when ccache is used (maybe hard).\n\nI'm pretty sure you should report this against ccache; GCC seems to be\nbehaving as documented. (I believe there is another flag that ccache\nshould be passing in to tell GCC what target to use in the depfile.)\n\nOf course, it'd be wise to make sure that this problem still occurs in\nthe most recent version of ccache you can conveniently try it with before\nreporting...\n"},{"id":"179715","messageId":"m21ut5dyei.fsf@igel.home","threadId":"28969","inReplyTo":"CACsJy8BuCdT3rRjc5u6Ex5RRgSbL_0SFF0GW-dTGqet4sG2cwg@mail.gmail.com","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-11-18T19:27:17Z","receivedAt":"2011-11-18T19:27:17Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n> OK it's not gcc problem. I upgraded to 4.5.3 and still had the same\n> problem. I used ccache though. Without ccache, gcc produced correct\n> .o.d files.\n\nI'm also using ccache (version 3.1.3) and get correct dependencies.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"179720","messageId":"20111118211645.GA27440@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"loom.20111118T191851-152@post.gmane.org","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T21:16:45Z","receivedAt":"2011-11-18T21:16:45Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\n(restoring cc list.  Unfortunately gmane's web interface doesn't\n provide a built-in way to reply-to-all.  [1] has a hackish\n workaround.)\nSamuel Bronson wrote:\n> Nguyen Thai Ngoc Duy writes:\n\n>> \"gcc -MF depfile -MMD -MP -c -o path/to/file.o\" will produce \"depfile\"\n>> with target given by \"-o\". When ccache runs, it executes \"gcc -MF\n>> depfile -MMD -MP -E\" instead to get the final content for hashing.\n>> Notice that \"-c -o\" combination is replaced by \"-E\". The latter\n>> produces target without leading path.\n[...]\n> I'm pretty sure you should report this against ccache; GCC seems to be\n> behaving as documented.\n\nSeems to have been fixed by v3.0pre0~187:\n\n commit e8354384\n Author: Andrea Bittau <a.bittau@cs.ucl.ac.uk>\n Date:   Sun Nov 1 19:39:58 2009 +0100\n\n     Fix handling of the -MD and -MDD options\n\n     From <http://lists.samba.org/archive/ccache/2007q2/000272.html>:\n\n     The -MD and -MDD options automatically determine where the dependency file\n     should land and what the target should look like based on the -o option.\n     However, ccache drops -o and things mess up. The original patch was posted by\n     Kaz Kylheku but I reworked it to make it work properly. Here is his post:\n\n     http://lists.samba.org/archive/ccache/2006q4/000249.html\n\nWorkaround incoming in a few moments.\n\nThanks,\nJonathan\n"},{"id":"179724","messageId":"20111118232324.GA8746@elie.hsd1.il.comcast.net","threadId":"28969","inReplyTo":"CACsJy8BZMDyf4MCiKxPJ5Z+XS+C-MC82SpMFyWgiXmb9xCnScw@mail.gmail.com","subject":"[PATCH] Makefile: explicitly set target name for autogenerated dependencies","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-11-18T23:23:24Z","receivedAt":"2011-11-18T23:23:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"\"gcc -MF depfile -MMD -MP -c -o path/to/file.o\" produces a makefile\nsnippet named \"depfile\" describing what files are needed to build the\ntarget given by \"-o\".  When ccache versions before v3.0pre0~187 (Fix\nhandling of the -MD and -MDD options, 2009-11-01) run, they execute\n\n\tgcc -MF depfile -MMD -MP -E\n\ninstead to get the final content for hashing.  Notice that the \"-c -o\"\ncombination is replaced by \"-E\".  The result is a target name without\na leading path.\n\nThus when building git with such versions of ccache with\nCOMPUTE_HEADER_DEPENDENCIES enabled, the generated makefile snippets\ndefine dependencies for the wrong target:\n\n\t$ make builtin/add.o\n\tGIT_VERSION = 1.7.8.rc3\n\t    * new build flags or prefix\n\t    CC builtin/add.o\n\t$ head -1 builtin/.depend/add.o.d\n\tadd.o: builtin/add.c cache.h git-compat-util.h compat/bswap.h strbuf.h \\\n\nAfter a change in a header file, object files in a subdirectory are\nnot automatically rebuilt by \"make\":\n\n\t$ touch cache.h\n\t$ make builtin/add.o\n\t$\n\nLuckily we can prevent trouble by explicitly supplying the name of the\ntarget to ccache and gcc, using the -MQ option.  Do so.\n\nReported-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nHi,\n\nNguyen Thai Ngoc Duy wrote:\n\n> My builtin/.depend/add.o.d says\n>\n> add.o: .... cache.h ...\n>\n> Shouldn't it be \"builtin/add.o: ... cache.h ...\"?\n\nThe following seems to do the trick for me.  Thanks again for catching\nit.\n\n Makefile |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ee34eab8..71ad4b26 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1250,7 +1250,8 @@ USE_COMPUTED_HEADER_DEPENDENCIES =\n else\n ifndef COMPUTE_HEADER_DEPENDENCIES\n dep_check = $(shell $(CC) $(ALL_CFLAGS) \\\n-\t-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \\\n+\t-c -MF /dev/null -MQ /dev/null -MMD -MP \\\n+\t-x c /dev/null -o /dev/null 2>&1; \\\n \techo $$?)\n ifeq ($(dep_check),0)\n COMPUTE_HEADER_DEPENDENCIES=YesPlease\n@@ -1912,7 +1913,7 @@ $(dep_dirs):\n \n missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))\n dep_file = $(dir $@).depend/$(notdir $@).d\n-dep_args = -MF $(dep_file) -MMD -MP\n+dep_args = -MF $(dep_file) -MQ $@ -MMD -MP\n ifdef CHECK_HEADER_DEPENDENCIES\n $(error cannot compute header dependencies outside a normal build. \\\n Please unset CHECK_HEADER_DEPENDENCIES and try again)\n-- \n1.7.8.rc3\n"},{"id":"179727","messageId":"CACsJy8BLJmDc6jGOW+GzYC9yM2DE6U6ONmfakZvcKNxgVNgCnw@mail.gmail.com","threadId":"28969","inReplyTo":"m21ut5dyei.fsf@igel.home","subject":"Re: A flaw in dep generation with gcc -MMD?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-19T04:53:38Z","receivedAt":"2011-11-19T04:53:38Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Nov 19, 2011 at 2:27 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>\n>> OK it's not gcc problem. I upgraded to 4.5.3 and still had the same\n>> problem. I used ccache though. Without ccache, gcc produced correct\n>> .o.d files.\n>\n> I'm also using ccache (version 3.1.3) and get correct dependencies.\n\nI use ccache-2.4. Jonathan pointed out 3.x has been fixed elsewhere in\nthis thread . I'm going to ask Gentoo to stablize one of 3.x version.\n-- \nDuy\n"},{"id":"179728","messageId":"CACsJy8A63yY_FiB76nkkrZiwSHygZ4K-7+oqZrKS4ii_YCGVTQ@mail.gmail.com","threadId":"28969","inReplyTo":"20111118232324.GA8746@elie.hsd1.il.comcast.net","subject":"Re: [PATCH] Makefile: explicitly set target name for autogenerated dependencies","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-19T05:13:45Z","receivedAt":"2011-11-19T05:13:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Nov 19, 2011 at 6:23 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Luckily we can prevent trouble by explicitly supplying the name of the\n> target to ccache and gcc, using the -MQ option.  Do so.\n>\n> Reported-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> Hi,\n>\n> Nguyen Thai Ngoc Duy wrote:\n>\n>> My builtin/.depend/add.o.d says\n>>\n>> add.o: .... cache.h ...\n>>\n>> Shouldn't it be \"builtin/add.o: ... cache.h ...\"?\n>\n> The following seems to do the trick for me.  Thanks again for catching\n> it.\n\nWorks for me too.\n-- \nDuy\n"}]}