Re: [PATCH resend] Makefile: Use computed header dependencies if the compiler supports it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 14, 2011 at 03:02:55PM -0500, Jonathan Nieder wrote:
> Fredrik Kuivinen wrote:
> > On Sun, Aug 14, 2011 at 21:00, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:
> 
> >> I wonder if we can make do with a faster check, like
> >>
> >>        $(CC) -c -MF /dev/null -MMD -MP git.c --help >/dev/null 2>&1
> >>
> >> What do you think?
> [...]
> > Without patch (with COMPUTE_HEADER_DEPENDENCIES=Yes):
> 
> The case to compare against is when COMPUTE_HEADER_DEPENDENCIES is not
> set, I'd think, since that is the status quo.  And I was talking about
> commands like "make clean" that do not care about that feature, not
> "make all".

There is no measurable difference between setting and unsetting
COMPUTE_HEADER_DEPENDENCIES for me (not surprising as nothing is
actually built). "make clean" (in a clean tree) takes more time than
"make" (in a fully built tree), so the relative overhead in the make
clean case is even smaller. The absolute overhead is, of course, the
same.

> [...]
> > With patch, but changed to use git.c instead of ++empty.c:
> 
> Did you try with "--help"?

Oh, I missed "--help". But for me gcc always exits with status code 0
when I give it "--help", regardless of what other flags I
provide. Therefore, I don't see how "--help" can be used to test for
support of -MMD.

Here is an updated patch. It avoids the ++empty.c file by giving "-x
c" to the compiler. It also avoids the auto-detection when
COMPUTE_HEADER_DEPENDENCIES is set, so if you want to avoid the
overhead you can set that in you config.mak.


-- 8< --

Subject: [PATCH] Makefile: Use computed header dependencies if the compiler supports it

Previously you had to manually define COMPUTE_HEADER_DEPENDENCIES to
enable this feature. It seemed a bit sad that such a useful feature
had to be enabled manually.

To avoid the small overhead we don't do the auto-detection if
COMPUTE_HEADER_DEPENDENCIES is already set.

Signed-off-by: Fredrik Kuivinen <frekui@xxxxxxxxx>
---
 Makefile |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 89cc624..c131439 100644
--- a/Makefile
+++ b/Makefile
@@ -250,10 +250,6 @@ 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 CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
 # dependency rules.
 #
@@ -1236,6 +1232,15 @@ endif
 ifdef CHECK_HEADER_DEPENDENCIES
 COMPUTE_HEADER_DEPENDENCIES =
 USE_COMPUTED_HEADER_DEPENDENCIES =
+else
+ifndef COMPUTE_HEADER_DEPENDENCIES
+dep_check = $(shell sh -c \
+	'$(CC) -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
+	echo $$?')
+ifeq ($(dep_check),0)
+COMPUTE_HEADER_DEPENDENCIES=YesPlease
+endif
+endif
 endif
 
 ifdef COMPUTE_HEADER_DEPENDENCIES
-- 
1.7.5.3.368.g8b1b7.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]