[2/7] gdb, gdbserver: require gcc-style dependency generation, drop the depcomp fallback

Message ID 20260831185300.572297-3-simon.marchi@efficios.com
State New
Headers
Series Some Makefile cleanups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Simon Marchi Aug. 31, 2026, 6:51 p.m. UTC
  gdb/Makefile.in and gdbserver/Makefile.in have similar code to do manual
gcc3-style dependency tracking, or fallback to the depcomp tool for
other dependency tracking modes.  I believe that in this day and age, we
can assume that all compilers we support know about gcc3-style
dependency tracking.

Obviously, gcc and clang both know about it.  The other compilers I am
aware of (I don't even know if they can build GDB) are Intel icc and IBM
XL, and they both appear to have known about it for a while.

I therefore propose to get rid of the fallback, which results in simpler
Makefiles.

In both directories, remove the depcomp fallback branch and merge the gcc3
definitions into the base COMPILE.post and POSTCOMPILE definitions.

The DEPMODE and depcomp variables are not needed anymore.

Remove the ZW_PROG_COMPILER_DEPENDENCIES calls in the configure.ac
files, which were used to probe for the supported dependency mechanisme
and substitute @CCDEPMODE@.

ZW_CREATE_DEPDIR is still needed: it is what creates the top-level
dependency directory from config.status.  It also sets the DEPDIR
variable indirectly, via AM_SET_DEPDIR.

Change-Id: I2e0a42156af571e7147c83852fc9536b50af7c2e
---
 gdb/Makefile.in        |  30 +++---------
 gdb/configure          | 101 +----------------------------------------
 gdb/configure.ac       |   1 -
 gdbserver/Makefile.in  |  30 +++---------
 gdbserver/configure    |  98 ---------------------------------------
 gdbserver/configure.ac |   2 -
 6 files changed, 16 insertions(+), 246 deletions(-)
  

Comments

Tom Tromey Sept. 1, 2026, 4:32 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> gdb/Makefile.in and gdbserver/Makefile.in have similar code to do manual
Simon> gcc3-style dependency tracking, or fallback to the depcomp tool for
Simon> other dependency tracking modes.  I believe that in this day and age, we
Simon> can assume that all compilers we support know about gcc3-style
Simon> dependency tracking.

Simon> Obviously, gcc and clang both know about it.  The other compilers I am
Simon> aware of (I don't even know if they can build GDB) are Intel icc and IBM
Simon> XL, and they both appear to have known about it for a while.

I wonder if the Windows or Solaris compilers work.

Anyway, I'm fine with this.  I tend to doubt anybody uses anything else,
on the theory that if they did, we'd probably have seen patches to work
around problems.  I suppose we can revert this or just ask people to
write wrapper scripts for any compiler not supporting this feature.

The depcomp stuff was more important for C and the olden times when
other compilers were in use.

Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Simon Marchi Sept. 1, 2026, 8:16 p.m. UTC | #2
On 2026-09-01 12:32, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
> 
> Simon> gdb/Makefile.in and gdbserver/Makefile.in have similar code to do manual
> Simon> gcc3-style dependency tracking, or fallback to the depcomp tool for
> Simon> other dependency tracking modes.  I believe that in this day and age, we
> Simon> can assume that all compilers we support know about gcc3-style
> Simon> dependency tracking.
> 
> Simon> Obviously, gcc and clang both know about it.  The other compilers I am
> Simon> aware of (I don't even know if they can build GDB) are Intel icc and IBM
> Simon> XL, and they both appear to have known about it for a while.
> 
> I wonder if the Windows or Solaris compilers work.

If by Windows you mean MSVC, I would be really surprised.

I did not know about the Sun Studio compiler, but I would assume that
people juste use gcc to build gdb on Solaris.  Rainer, is that true?

> Anyway, I'm fine with this.  I tend to doubt anybody uses anything else,
> on the theory that if they did, we'd probably have seen patches to work
> around problems.  I suppose we can revert this or just ask people to
> write wrapper scripts for any compiler not supporting this feature.
> 
> The depcomp stuff was more important for C and the olden times when
> other compilers were in use.
> 
> Approved-By: Tom Tromey <tom@tromey.com>

Thanks,

Simon
  
Rainer Orth Sept. 2, 2026, 7:37 a.m. UTC | #3
Hi Simon,

> I did not know about the Sun Studio compiler, but I would assume that
> people juste use gcc to build gdb on Solaris.  Rainer, is that true?

I guess so, at least I've done that for a very long time.  Just in case,
I tried building gdb trunk with Studio CC 12.6.  It failed since it only
supports C++14 while gdb requires C++17.

	Rainer
  
Simon Marchi Sept. 2, 2026, 12:26 p.m. UTC | #4
On 2026-09-02 03:37, Rainer Orth wrote:
> Hi Simon,
> 
>> I did not know about the Sun Studio compiler, but I would assume that
>> people juste use gcc to build gdb on Solaris.  Rainer, is that true?
> 
> I guess so, at least I've done that for a very long time.  Just in case,
> I tried building gdb trunk with Studio CC 12.6.  It failed since it only
> supports C++14 while gdb requires C++17.

Thanks, that settles it :)

Simon
  

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c6bfc2949fcc..5741ee5e2e92 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -103,9 +103,7 @@  CXX = @CXX@
 CXX_DIALECT = @CXX_DIALECT@
 
 # Dependency tracking information.
-DEPMODE = @CCDEPMODE@
 DEPDIR = @DEPDIR@
-depcomp = $(SHELL) $(srcdir)/../depcomp
 
 # Directory containing source files.
 srcdir = @srcdir@
@@ -114,11 +112,14 @@  top_srcdir = @top_srcdir@
 
 include $(srcdir)/silent-rules.mk
 
-# Note that these are overridden by GNU make-specific code below if
-# GNU make is used.  The overrides implement dependency tracking.
+# Note that we put the dependencies into a .Tpo file, then move them into
+# place if the compile succeeds.  We need this because gcc does not
+# atomically write the dependency output file.
 COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT)
-COMPILE.post = -c -o $@
-POSTCOMPILE = @true
+COMPILE.post = -c -o $@ \
+	-MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo
+POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \
+	$(@D)/$(DEPDIR)/$(basename $(@F)).Po
 
 # CXXFLAGS is at the very end on purpose, so that user-supplied flags can
 # override internal flags.
@@ -2828,23 +2829,6 @@  all_gdbtk_cflags = $(IDE_CFLAGS) $(ITCL_CFLAGS) \
 # Dependency tracking.
 #
 
-ifeq ($(DEPMODE),depmode=gcc3)
-# Note that we put the dependencies into a .Tpo file, then move them
-# into place if the compile succeeds.  We need this because gcc does
-# not atomically write the dependency output file.
-override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \
-	-MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo
-override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \
-	$(@D)/$(DEPDIR)/$(basename $(@F)).Po
-else
-override COMPILE.pre = source='$<' object='$@' libtool=no \
-	DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) \
-	$(CXX) -x c++ $(CXX_DIALECT)
-# depcomp handles atomicity for us, so we don't need a postcompile
-# step.
-override POSTCOMPILE =
-endif
-
 # A list of all the objects we might care about in this build, for
 # dependency tracking.
 all_object_files = gdb.o $(LIBGDB_OBS) gdbtk/generic/gdbtk-main.o
diff --git a/gdb/configure b/gdb/configure
index 7dc7781cb09f..94cc893a8715 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -795,7 +795,6 @@  SET_MAKE
 PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
-CCDEPMODE
 DEPDIR
 am__leading_dot
 LTLIBXXHASH
@@ -11878,7 +11877,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11881 "configure"
+#line 11880 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11984,7 +11983,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11987 "configure"
+#line 11986 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22700,102 +22699,6 @@  DEPDIR="${am__leading_dot}deps"
 ac_config_commands="$ac_config_commands depdir"
 
 
-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 ${am_cv_CC_dependencies_compiler_type+:} false; 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
-
 
 # Since the first call to PKG_CHECK_MODULES may not happen (is guarded by
 # a condition), we must call PKG_PROG_PKG_CONFIG explicitly to probe for
diff --git a/gdb/configure.ac b/gdb/configure.ac
index c70aa30fc96a..d8b2498f415b 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -61,7 +61,6 @@  GDB_AC_COMMON
 
 # Dependency checking.
 ZW_CREATE_DEPDIR
-ZW_PROG_COMPILER_DEPENDENCIES([CC])
 
 # Since the first call to PKG_CHECK_MODULES may not happen (is guarded by
 # a condition), we must call PKG_PROG_PKG_CONFIG explicitly to probe for
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
index e45c89dc321d..b06e0b86e45b 100644
--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -48,9 +48,7 @@  AR_FLAGS = rc
 STRIP = @STRIP@
 
 # Dependency tracking information.
-DEPMODE = @CCDEPMODE@
 DEPDIR = @DEPDIR@
-depcomp = $(SHELL) $(srcdir)/../depcomp
 
 # Directory containing source files.  Don't clean up the spacing,
 # this exact string is matched for by the "configure" script.
@@ -63,11 +61,14 @@  top_builddir = .
 
 include $(srcdir)/../gdb/silent-rules.mk
 
-# Note that these are overridden by GNU make-specific code below if
-# GNU make is used.  The overrides implement dependency tracking.
+# Note that we put the dependencies into a .Tpo file, then move them into
+# place if the compile succeeds.  We need this because gcc does not
+# atomically write the dependency output file.
 COMPILE.pre = $(CXX) $(CXX_DIALECT)
-COMPILE.post = -c -o $@
-POSTCOMPILE = @true
+COMPILE.post = -c -o $@ \
+	-MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo
+POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \
+	$(@D)/$(DEPDIR)/$(basename $(@F)).Po
 
 INCLUDE_SERVER_H = -include $(srcdir)/server.h
 
@@ -596,23 +597,6 @@  gdbreplay.o: gdbreplay.cc
 # Dependency tracking.
 #
 
-ifeq ($(DEPMODE),depmode=gcc3)
-# Note that we put the dependencies into a .Tpo file, then move them
-# into place if the compile succeeds.  We need this because gcc does
-# not atomically write the dependency output file.
-override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \
-	-MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo
-override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \
-	$(@D)/$(DEPDIR)/$(basename $(@F)).Po
-else
-override COMPILE.pre = source='$<' object='$@' libtool=no \
-	DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) \
-	$(CXX) $(CXX_DIALECT)
-# depcomp handles atomicity for us, so we don't need a postcompile
-# step.
-override POSTCOMPILE =
-endif
-
 # A list of all the objects we might care about in this build, for
 # dependency tracking.
 all_object_files = $(OBS) $(GDBREPLAY_OBS) $(IPA_OBJS)
diff --git a/gdbserver/configure b/gdbserver/configure
index 46faecc3a207..3cf8df2c3ae1 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -637,7 +637,6 @@  REPORT_BUGS_TO
 PKGVERSION
 WERROR_CFLAGS
 WARN_CFLAGS
-CCDEPMODE
 CONFIG_SRC_SUBDIR
 CATOBJEXT
 GENCAT
@@ -12821,103 +12820,6 @@  CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
 ac_config_commands="$ac_config_commands gdbdepdir"
 
 
-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 ${am_cv_CC_dependencies_compiler_type+:} false; 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
-
-
 for ac_header in  \
   arpa/inet.h \
   fcntl.h \
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index 9979afe7ece9..a549a8712fc1 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -76,8 +76,6 @@  AC_CONFIG_COMMANDS([gdbdepdir],[
   done],
   [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"])
 
-ZW_PROG_COMPILER_DEPENDENCIES([CC])
-
 AC_CHECK_HEADERS([ \
   arpa/inet.h \
   fcntl.h \