git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Makefile: add option to disable automatic dependency generation

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 18, 2011, 04:57 UTC
Message-ID
<20111118045742.GA25145@elie.hsd1.il.comcast.net>
In-Reply-To
<CACsJy8A44PFtYrm8NQU+48sVkOe8mjJyO9opO5-TwRtAd-TKsQ@mail.gmail.com>

Duy noticed that now that the COMPUTE_HEADER_DEPENDENCIES feature is turned on automatically for compilers that support it (see v1.7.8-rc0~142^2~1, 2011-08-18), there is no easy way to force it off. For example, setting COMPUTE_HEADER_DEPENDENCIES to the empty string in config.mak just tells the makefile to treat it as undefined and run a test command to see if the -MMD option is supported.

Introduce a new NO_COMPUTE_HEADER_DEPENDENCIES variable that forces the feature off. The new semantics:

 - If NO_COMPUTE_HEADER_DEPENDENCIES is set to a nonempty string,
   the -MMD option will not be used.  The build relies on hard-coded
   dependencies in the "ifndef USE_COMPUTED_HEADER_DEPENDENCIES"
   section of the Makefile instead.
 - If COMPUTE_HEADER_DEPENDENCIES is empty and NO_COMPUTE_... is
   nonempty, the build uses gcc's on-the-fly dependency generation
   feature.
 - If neither is nonempty, the makefile runs a quick test command
   to decide whether the compiler supports the -MMD option and
   whether to enable this feature.
Inspired-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Nguyen Thai Ngoc Duy wrote:
> Hmm.. I guess it's my compiler's fault then. Next question, how can I
> disable this feature?

"make COMPUTE_HEADER_DEPENDENCIES=" works. But there's no way aside from "override COMPUTE_HEADER_DEPENDENCIES=" to do that in config.mak. And yuck.

By the way, I'm not convinced it's your compiler's fault. It might be my compiler's fault. More reading to do...

 Makefile |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index ee34eab8..e4a658f6 100644
--- a/Makefile
+++ b/Makefile
@@ -250,6 +250,13 @@ all::
 #   DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
 #   DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
 #
+# Define COMPUTE_HEADER_DEPENDENCIES if your compiler supports the -MMD option
+# and you want to avoid rebuilding objects when an unrelated header file
+# changes.
+#
+# Define NO_COMPUTE_HEADER_DEPENDENCIES if you want to disable automatic
+# dependency generation even though your compiler is detected to support it.
+#
 # Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 # dependency rules.
 #
@@ -1245,10 +1252,16 @@ endif
 endif
 
 ifdef CHECK_HEADER_DEPENDENCIES
+NO_COMPUTE_HEADER_DEPENDENCIES = YesPlease
+endif
+
+ifdef NO_COMPUTE_HEADER_DEPENDENCIES
 COMPUTE_HEADER_DEPENDENCIES =
 USE_COMPUTED_HEADER_DEPENDENCIES =
-else
+endif
+
 ifndef COMPUTE_HEADER_DEPENDENCIES
+ifndef NO_COMPUTE_HEADER_DEPENDENCIES
 dep_check = $(shell $(CC) $(ALL_CFLAGS) \
 	-c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
 	echo $$?)
-- 
1.7.8.rc2
Previous: Nguyen Thai Ngoc DuyNext: Jonathan Nieder
Message 11 of 19 in “A flaw in dep generation with gcc -MMD?”
  1. Nguyen Thai Ngoc DuyNov 18, 2011
  2. Jonathan NiederNov 18, 2011
  3. Nguyen Thai Ngoc DuyNov 18, 2011
  4. Miles BaderNov 18, 2011
  5. Nguyen Thai Ngoc DuyNov 18, 2011
  6. Nguyen Thai Ngoc DuyNov 18, 2011
  7. Samuel BronsonNov 18, 2011
  8. Jonathan NiederNov 18, 2011
  9. Andreas SchwabNov 18, 2011
  10. Nguyen Thai Ngoc DuyNov 19, 2011
  11. Makefile: add option to disable automatic dependency generationJonathan Nieder, Nov 18, 2011
  12. Jonathan NiederNov 18, 2011
  13. Junio C HamanoNov 18, 2011
  14. Jonathan NiederNov 18, 2011
  15. Makefile: add option to disable automatic dependency generationJonathan Nieder, Nov 18, 2011
  16. Makefile: add missing header file dependenciesJonathan Nieder, Nov 18, 2011
  17. Nguyen Thai Ngoc DuyNov 18, 2011
  18. Makefile: explicitly set target name for autogenerated dependenciesJonathan Nieder, Nov 18, 2011
  19. Nguyen Thai Ngoc DuyNov 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.