diff mbox

[v4,04/20] add configury

Message ID 1379945520-3839-5-git-send-email-tromey@redhat.com
State New
Headers show

Commit Message

Tom Tromey Sept. 23, 2013, 2:11 p.m. UTC
This adds the configury needed for automatic dependency tracking.  It
also adds some bits to the Makefile so we can begin converting
(removing) explicit dependencies.

	* Makefile.in (CCDEPMODE, DEPDIR, depcomp, COMPILE.base)
	(COMPILE, POSTCOMPILE): New variables.
	(.cc.o .c.o): Use COMPILE, POSTCOMPILE.
	(DEPFILES): New variable.
	Include ".Po" files.
	* configure.ac: Add checks for dependency checking.
	* configure, aclocal.m4: Regenerate.
---
 gcc/Makefile.in  |  32 +++++++++++-
 gcc/aclocal.m4   |   2 +
 gcc/configure    | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 gcc/configure.ac |  16 ++++++
 4 files changed, 195 insertions(+), 3 deletions(-)

Comments

Gerald Pfeifer Sept. 27, 2013, 7:45 p.m. UTC | #1
Hi Tom,

On Mon, 23 Sep 2013, Tom Tromey wrote:
> This adds the configury needed for automatic dependency tracking.  It
> also adds some bits to the Makefile so we can begin converting
> (removing) explicit dependencies.
> 
> 	* Makefile.in (CCDEPMODE, DEPDIR, depcomp, COMPILE.base)
> 	(COMPILE, POSTCOMPILE): New variables.
> 	(.cc.o .c.o): Use COMPILE, POSTCOMPILE.

I believe this may be breaking all my testers on FreeBSD 
(i386-unknown-freebsd10.0 for example).  The timing of when this
patchset went in fits pretty much when my builds started to break
and I am wondering about some code.

Here is the failure mode:

gmake[2]: Entering directory `/scratch/tmp/gerald/OBJ-0927-1848/gcc'
g++ -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common
-DHAVE_CONFIG_H -I. -Ic -I/scratch/tmp/gerald/gcc-HEAD/gcc ...[-I 
options]...
-o c/c-lang.o -MT c/c-lang.o -MMD -MP -MF c/.deps/c-lang.TPo
/scratch/tmp/gerald/gcc-HEAD/gcc/c/c-lang.c
cc1plus: error: unrecognized command line option "-Wno-narrowing"
gmake[2]: *** [c/c-lang.o] Error 1
gmake[1]: *** [install-gcc] Error 2
gmake: *** [install] Error 2

The issue is the invocation of g++ (the old system compiler, not what
we built) with -Wno-narrowing (a new option).

And looking at the code, I see

  +COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
  +ifeq ($(CCDEPMODE),depmode=gcc3)
  +# Note a subtlety here: we use $(@D) for the directory part, to make
  +# things like the go/%.o rule work properly; but we use $(*F) for the
  +# file part, as we just want the file part of the stem, not the entire
  +# file name.
  +COMPILE = $(COMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
  +POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
  +else
  +COMPILE = source='$<' object='$@' libtool=no \
  +    DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) $(COMPILE.base)
  +POSTCOMPILE =
  +endif

Where does $(ALL_COMPILERFLAGS) compile from?  If I read the code
right, we do disable these warnings for the stage1 build.  However,
the install compiler is the same -- so I guess we should disable
warnings there, too?

Gerald
Tom Tromey Sept. 27, 2013, 8:25 p.m. UTC | #2
Gerald> And looking at the code, I see
Gerald>   +COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
[...]
Gerald> Where does $(ALL_COMPILERFLAGS) compile from?

Look a little further down in the patch:

 .cc.o .c.o:
-	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
+	$(COMPILE) $<
+	$(POSTCOMPILE)


... that is, the patches didn't change this part.  ALL_COMPILERFLAGS was
used before and it is used now.  I don't think this series touched how
this variable is computed, either.

Gerald> If I read the code
Gerald> right, we do disable these warnings for the stage1 build.  However,
Gerald> the install compiler is the same -- so I guess we should disable
Gerald> warnings there, too?

I'm afraid I don't understand.


If I were debugging this then I think I would start by looking in
config.log to see why the compiler accepted -Wno-narrowing.

Actually, I looked in my own config.log and I see it isn't very
informative:

configure:6280: checking whether gcc supports -Wnarrowing
configure:6306: result: yes

I suppose I would hack in a "set -x" / "set +x" pair into configure
around the warning-checking section and then see what happens.

Tom
Paolo Bonzini Sept. 30, 2013, 7:45 a.m. UTC | #3
Il 27/09/2013 21:45, Gerald Pfeifer ha scritto:
> I believe this may be breaking all my testers on FreeBSD 
> (i386-unknown-freebsd10.0 for example).  The timing of when this
> patchset went in fits pretty much when my builds started to break
> and I am wondering about some code.
> 
> Here is the failure mode:
> 
> gmake[2]: Entering directory `/scratch/tmp/gerald/OBJ-0927-1848/gcc'
> g++ -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
> -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long
> -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common
> -DHAVE_CONFIG_H -I. -Ic -I/scratch/tmp/gerald/gcc-HEAD/gcc ...[-I 
> options]...
> -o c/c-lang.o -MT c/c-lang.o -MMD -MP -MF c/.deps/c-lang.TPo
> /scratch/tmp/gerald/gcc-HEAD/gcc/c/c-lang.c
> cc1plus: error: unrecognized command line option "-Wno-narrowing"
> gmake[2]: *** [c/c-lang.o] Error 1
> gmake[1]: *** [install-gcc] Error 2
> gmake: *** [install] Error 2
> 
> The issue is the invocation of g++ (the old system compiler, not what
> we built) with -Wno-narrowing (a new option).

Why is install building anything?

Paolo
Iain Sandoe Sept. 30, 2013, 3:47 p.m. UTC | #4
On 30 Sep 2013, at 08:45, Paolo Bonzini wrote:

> Il 27/09/2013 21:45, Gerald Pfeifer ha scritto:
>> I believe this may be breaking all my testers on FreeBSD 
>> (i386-unknown-freebsd10.0 for example).  The timing of when this
>> patchset went in fits pretty much when my builds started to break
>> and I am wondering about some code.
>> 
>> Here is the failure mode:
>> 
>> gmake[2]: Entering directory `/scratch/tmp/gerald/OBJ-0927-1848/gcc'
>> g++ -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC   -fno-exceptions -fno-rtti
>> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
>> -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long
>> -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common
>> -DHAVE_CONFIG_H -I. -Ic -I/scratch/tmp/gerald/gcc-HEAD/gcc ...[-I 
>> options]...
>> -o c/c-lang.o -MT c/c-lang.o -MMD -MP -MF c/.deps/c-lang.TPo
>> /scratch/tmp/gerald/gcc-HEAD/gcc/c/c-lang.c
>> cc1plus: error: unrecognized command line option "-Wno-narrowing"
>> gmake[2]: *** [c/c-lang.o] Error 1
>> gmake[1]: *** [install-gcc] Error 2
>> gmake: *** [install] Error 2
>> 
>> The issue is the invocation of g++ (the old system compiler, not what
>> we built) with -Wno-narrowing (a new option).
> 
> Why is install building anything?

I don't know if the case above is related, but AFAICT, java always builds ec1 at install time (and I wonder what the reason for  that is).
Iain
Gerald Pfeifer Oct. 14, 2013, 10:28 p.m. UTC | #5
On Fri, 27 Sep 2013, Tom Tromey wrote:
> Look a little further down in the patch:
> 
>  .cc.o .c.o:
> -	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
> +	$(COMPILE) $<
> +	$(POSTCOMPILE)
> 
> ... that is, the patches didn't change this part.  ALL_COMPILERFLAGS was
> used before and it is used now.  I don't think this series touched how
> this variable is computed, either.

Looks like this was a red herring.  Sorry for that.

> If I were debugging this then I think I would start by looking in
> config.log to see why the compiler accepted -Wno-narrowing.

On Mon, 30 Sep 2013, Paolo Bonzini wrote:
> Why is install building anything?

I believe this may be the key element.  Configury really is _not_
an area I am an expert in, but I did some experiments:

 - Revision r202892 | law | 2013-09-25 15:33:34 +0000 (Wed, 25 Sep 2013)
   builds just fine on my tester(s).

   Revision r202912 | tromey | 2013-09-25 16:33:30 +0000 (Wed, 25 Sep 2013)
   fails.  So, this definitely was introduced by this patch set.

 - When I do a gmake at the top level of the build tree, nothing is 
   rebuilt at all.  This only happens during `gmake install`

 - The problem is not actually the set of flags being used.  On a 
   different tester clang is the bootstrap compiler, and this is
   also the one invoked for `gmake install`.  If anything, shouldn't
   the just built compiler be used _if_ anything is left to compile?

Is nobody else seeing this?  Or is everyone just lucky enough to have
a recent version of GCC as the default compiler?

Gerald
Paolo Bonzini Oct. 15, 2013, 6:27 a.m. UTC | #6
Il 15/10/2013 00:28, Gerald Pfeifer ha scritto:
>  - The problem is not actually the set of flags being used.  On a 
>    different tester clang is the bootstrap compiler, and this is
>    also the one invoked for `gmake install`.  If anything, shouldn't
>    the just built compiler be used _if_ anything is left to compile?

Yes---but then, the question remains as to why anything is built at all.

Paolo
Tom Tromey Oct. 15, 2013, 1:20 p.m. UTC | #7
Gerald>  - When I do a gmake at the top level of the build tree, nothing is 
Gerald>    rebuilt at all.  This only happens during `gmake install`
[...]
Gerald> Is nobody else seeing this?  Or is everyone just lucky enough to have
Gerald> a recent version of GCC as the default compiler?

How exactly are you configuring and invoking "make"?
I will try to reproduce it.

Tom
Gerald Pfeifer Oct. 15, 2013, 10:55 p.m. UTC | #8
On Tue, 15 Oct 2013, Tom Tromey wrote:
>> Is nobody else seeing this?  Or is everyone just lucky enough to have
>> a recent version of GCC as the default compiler?
> How exactly are you configuring and invoking "make"?
> I will try to reproduce it.

Super, thanks Tom!

I've tried to reproduce this manually and had some mixed results, but 
basically my script does this:

  % mkdir /scratch2/tmp/gerald/OBJ-1014-1920
  % cd /scratch2/tmp/gerald/OBJ-1014-1920
  % $GCC_SOURCE/configure --prefix=/home/gerald/something
  % gmake bootstrap-lean
  % gmake install

Wait a minute!  

It _looks_ like I can get this to succeed using "gmake bootstrap" 
and have the very same script fail using "gmake bootstrap-lean".

Can you reproduce that?

Gerald
Tom Tromey Oct. 16, 2013, 8:42 p.m. UTC | #9
>>>>> "Gerald" == Gerald Pfeifer <gerald@pfeifer.com> writes:

Gerald>   % mkdir /scratch2/tmp/gerald/OBJ-1014-1920
Gerald>   % cd /scratch2/tmp/gerald/OBJ-1014-1920
Gerald>   % $GCC_SOURCE/configure --prefix=/home/gerald/something
Gerald>   % gmake bootstrap-lean
Gerald>   % gmake install

Gerald> Wait a minute!  

Gerald> It _looks_ like I can get this to succeed using "gmake bootstrap" 
Gerald> and have the very same script fail using "gmake bootstrap-lean".

Gerald> Can you reproduce that?

Yeah, the bootstrap-lean + install combination fails for me.

Tom
diff mbox

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 7b45229..654f04b 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -308,6 +308,11 @@  write_entries_to_file = $(shell rm -f $(2) || :) $(shell touch $(2)) \
 # UNSORTED
 # --------
 
+# Dependency tracking stuff.
+CCDEPMODE = @CCDEPMODE@
+DEPDIR = @DEPDIR@
+depcomp = $(SHELL) $(srcdir)/../depcomp
+
 # Some compilers can't handle cc -c blah.c -o foo/blah.o.
 # In stage2 and beyond, we force this to "-o $@" since we know we're using gcc.
 OUTPUT_OPTION = @OUTPUT_OPTION@
@@ -1071,8 +1076,23 @@  INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
 	   $(CLOOGINC) $(ISLINC)
 
+COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
+ifeq ($(CCDEPMODE),depmode=gcc3)
+# Note a subtlety here: we use $(@D) for the directory part, to make
+# things like the go/%.o rule work properly; but we use $(*F) for the
+# file part, as we just want the file part of the stem, not the entire
+# file name.
+COMPILE = $(COMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
+POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
+else
+COMPILE = source='$<' object='$@' libtool=no \
+    DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) $(COMPILE.base)
+POSTCOMPILE =
+endif
+
 .cc.o .c.o:
-	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
+	$(COMPILE) $<
+	$(POSTCOMPILE)
 
 #
 # Support for additional languages (other than C).
@@ -5386,7 +5406,17 @@  po/gcc.pot: force
 	AWK=$(AWK) $(SHELL) $(srcdir)/po/exgettext \
 		$(XGETTEXT) gcc $(srcdir)
 
+#
+
+# Dependency information.
+
 # In order for parallel make to really start compiling the expensive
 # objects from $(OBJS) as early as possible, build all their
 # prerequisites strictly before all objects.
 $(ALL_HOST_OBJS) : | $(generated_files)
+
+# Include the auto-generated dependencies for all host objects.
+DEPFILES = \
+  $(foreach obj,$(ALL_HOST_OBJS),\
+    $(dir $(obj))$(DEPDIR)/$(patsubst %.o,%.Po,$(notdir $(obj))))
+-include $(DEPFILES)
diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4
index a992c3a..1bcf905 100644
--- a/gcc/aclocal.m4
+++ b/gcc/aclocal.m4
@@ -106,10 +106,12 @@  m4_include([../ltversion.m4])
 m4_include([../lt~obsolete.m4])
 m4_include([../config/acx.m4])
 m4_include([../config/codeset.m4])
+m4_include([../config/depstand.m4])
 m4_include([../config/dfp.m4])
 m4_include([../config/gettext-sister.m4])
 m4_include([../config/iconv.m4])
 m4_include([../config/lcmessage.m4])
+m4_include([../config/lead-dot.m4])
 m4_include([../config/lib-ld.m4])
 m4_include([../config/lib-link.m4])
 m4_include([../config/lib-prefix.m4])
diff --git a/gcc/configure b/gcc/configure
index f0c3c3b..d2c08f3 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -735,6 +735,9 @@  LDEXP_LIB
 EXTRA_GCC_LIBS
 GNAT_LIBEXC
 COLLECT2_LIBS
+CCDEPMODE
+DEPDIR
+am__leading_dot
 CXXCPP
 AR
 NM
@@ -8873,6 +8876,136 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 # --------
+# Dependency checking.
+# --------
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depdir"
+
+
+ac_config_commands="$ac_config_commands gccdepdir"
+
+
+depcc="$CC"   am_compiler_list=
+
+am_depcomp=$ac_aux_dir/depcomp
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    if test $depmode = none; then break; fi
+
+    $as_echo "$as_me:$LINENO: trying $depmode" >&5
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "include sub/conftest.Po" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    depcmd="depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c"
+    echo "| $depcmd" | sed -e 's/  */ /g' >&5
+    if env $depcmd > conftest.err 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po >>conftest.err 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po >>conftest.err 2>&1 &&
+       ${MAKE-make} -s -f confmf >>conftest.err 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+	$as_echo "$as_me:$LINENO: success" >&5
+        break
+      fi
+    fi
+    $as_echo "$as_me:$LINENO: failure, diagnostics are:" >&5
+    sed -e 's/^/| /' < conftest.err >&5
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+if test x${am_cv_CC_dependencies_compiler_type-none} = xnone
+then as_fn_error "no usable dependency style found" "$LINENO" 5
+else CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# --------
 # UNSORTED
 # --------
 
@@ -17900,7 +18033,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17903 "configure"
+#line 18036 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18006,7 +18139,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18009 "configure"
+#line 18142 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -28434,6 +28567,8 @@  cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #
 # INIT-COMMANDS
 #
+ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
+subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
 subdirs='$subdirs'
 
 _ACEOF
@@ -28445,6 +28580,8 @@  for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
     "auto-host.h") CONFIG_HEADERS="$CONFIG_HEADERS auto-host.h:config.in" ;;
+    "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
+    "gccdepdir") CONFIG_COMMANDS="$CONFIG_COMMANDS gccdepdir" ;;
     "as") CONFIG_FILES="$CONFIG_FILES as:exec-tool.in" ;;
     "collect-ld") CONFIG_FILES="$CONFIG_FILES collect-ld:exec-tool.in" ;;
     "nm") CONFIG_FILES="$CONFIG_FILES nm:exec-tool.in" ;;
@@ -29028,6 +29165,13 @@  $as_echo "$as_me: executing $ac_file commands" >&6;}
 
 
   case $ac_file$ac_mode in
+    "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
+    "gccdepdir":C)
+  ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR
+  for lang in $subdirs c-family common
+  do
+      ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR
+  done ;;
     "as":F) chmod +x as ;;
     "collect-ld":F) chmod +x collect-ld ;;
     "nm":F) chmod +x nm ;;
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 5d3e5ad..dc8b38b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -972,6 +972,22 @@  AC_CHECK_HEADERS(ext/hash_map)
 AC_LANG_POP(C++)
 
 # --------
+# Dependency checking.
+# --------
+
+AC_LANG_PUSH(C++)
+ZW_CREATE_DEPDIR
+AC_CONFIG_COMMANDS([gccdepdir],[
+  ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs build/$DEPDIR
+  for lang in $subdirs c-family common
+  do
+      ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/mkinstalldirs $lang/$DEPDIR
+  done], [subdirs="$subdirs" ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR])
+
+ZW_PROG_COMPILER_DEPENDENCIES([CC])
+AC_LANG_POP(C++)
+
+# --------
 # UNSORTED
 # --------