From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 7/7] gdb, gdbserver: create the dependency directories from the Makefiles
Date: Tue, 1 Sep 2026 16:37:20 -0400 [thread overview]
Message-ID: <5ac89acc-90e4-4650-9345-ea15b4101c67@simark.ca> (raw)
In-Reply-To: <c1444b43-671d-49bf-88e5-b67d21c45677@simark.ca>
On 2026-09-01 16:18, Simon Marchi wrote:
>
>
> On 2026-09-01 12:47, Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>>
>> Simon> Note that this changes the command to create directories from "$(SHELL)
>> Simon> $(srcdir)/../install-sh -d" to "mkdir -p". If there is a reason to use
>> Simon> install-sh to create directories in the build directory, I think it
>> Simon> should be documented, otherwise it just looks strange.
>>
>> In the old days, 'mkdir -p' wasn't portable. That's why mkinstalldirs
>> existed. Not sure why this code used install-sh.
>>
>> I don't know if 'mkdir -p' can be used today, though I tend to assume it
>> can; and anyway it's easy to switch to mkinstalldirs if need be.
>>
>> Simon> @@ -2413,11 +2408,8 @@ clean mostlyclean: $(CONFIG_CLEAN)
>> Simon> rm -f gdb$(EXEEXT) core make.log
>> Simon> rm -f gdb[0-9]$(EXEEXT)
>> Simon> rm -f xml-builtin.c stamp-xml
>> Simon> - rm -f $(DEPDIR)/*
>> Simon> - for i in $(CONFIG_SRC_SUBDIR); do \
>> Simon> - rm -f $$i/*.o; \
>> Simon> - rm -f $$i/$(DEPDIR)/*; \
>> Simon> - done
>> Simon> + rm -f $(addsuffix /*,$(ALL_DEPDIRS))
>> Simon> + rm -f $(addsuffix /*.o,$(CONFIG_SRC_SUBDIR))
>>
>> Simon> # This used to depend on c-exp.c m2-exp.c TAGS
>> Simon> # I believe this is wrong; the makefile standards for distclean just
>> Simon> @@ -2431,10 +2423,7 @@ distclean: clean
>> Simon> rm -f config.log config.cache
>> Simon> rm -f config.lt libtool
>> Simon> rm -f Makefile
>> Simon> - rm -rf $(DEPDIR)
>> Simon> - for i in $(CONFIG_SRC_SUBDIR); do \
>> Simon> - if test -d $$i/$(DEPDIR); then rmdir $$i/$(DEPDIR); fi \
>> Simon> - done
>> Simon> + rm -rf $(ALL_DEPDIRS)
>>
>> I don't think it should be necessary to update both 'clean' and
>> 'distclean'. The latter should depend on the former.
>>
>> The old rule was "if configure made it, distclean removes it; if make
>> made it, clean removes it". So I think the distclean change should be
>> dropped.
>>
>> I'm unsure if this rule was ever really was discussed outside the
>> Automake list back in ancient times, I think François Pinard came up
>> with it.
>
> It makes sense for distclean to be a superset of clean, in which case it
> doesn't need to repeat the same commands. I'll send an updated version
> of just this patch.
Here is a new version of the patch that removes the dep dirs in the
clean target.
From e5749ada86787578d3b0badd5412c56cfb07a9a7 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Mon, 31 Aug 2026 14:51:46 -0400
Subject: [PATCH] gdb, gdbserver: create the dependency directories from the
Makefiles
To: gdb-patches@sourceware.org
Some .deps directories are created at configure time:
- gdb/configure.ac and gdbserver/configure.ac call ZW_CREATE_DEPDIR,
which creates the top-level one from config.status.
- gdbserver/configure.ac has an additional AC_CONFIG_COMMANDS to create
the .deps dirs for its subdirectories listed in CONFIG_SRC_SUBDIR
(arch, gdbsupport, nat and target).
Meanwhile, gdb creates the sub-directory ones from the Makefile, through an
order-only prerequisite on the rule for compiling .c files.
If the user deletes a .deps directory created by configure
(config.status, really), then the build breaks:
$ rm -rf gdb/.deps
$ make
CXX gdb.o
gdb.c:39:1: fatal error: opening dependency file ./.deps/gdb.Tpo: No such file or directory
On the other hand, it works for those .deps created by a Makefile (they
are re-created as needed).
This patch changes how we create .deps directories to make it simpler,
more robust and consistent.
In both gdb and gdbserver:
- Add an ALL_DEPDIRS variable, listing the .deps directories, and a
rule to create them.
- Make ALL_DEPDIRS an order-only prerequisite of $(all_object_files),
such that the .deps directories will be created before compiling any
.o file.
- Following the rule "things created by make are removed by the clean
target" and "things created by configure are removed by the distclean
target", make the clean targets remove the dependency directories. I
opted for an `rm -f` followed by a loop of `rmdir` instead of just
one `rm -rf $(ALL_DEPDIRS)`. If someone or something messes up
$ALL_DEPDIRS in the future, there is less chances of things going
catastrophically wrong.
Note that this changes the command to create directories from "$(SHELL)
$(srcdir)/../install-sh -d" to "mkdir -p". If there is a reason to use
install-sh to create directories in the build directory, I think it
should be documented, otherwise it just looks strange.
The configure-time creation is not needed anymore. Replace the
ZW_CREATE_DEPDIR calls with AM_SET_DEPDIR, which is what actually
provides DEPDIR, and drop gdbserver's gdbdepdir AC_CONFIG_COMMANDS.
That leaves gdbserver's CONFIG_SRC_SUBDIR with no user in configure, so
define it directly in gdbserver/Makefile.in, like gdb already does.
Change-Id: I71e76a9a37a525f58c9c66e5556e8da965cc2ca3
---
gdb/Makefile.in | 33 ++++++++++++++++-----------------
gdb/configure | 6 ------
gdb/configure.ac | 2 +-
gdbserver/Makefile.in | 25 +++++++++++++++----------
gdbserver/configure | 21 ---------------------
gdbserver/configure.ac | 13 +------------
6 files changed, 33 insertions(+), 67 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index cf10bc17320b..8b7d9f47f594 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -590,7 +590,6 @@ HAVE_GSTACK = @HAVE_GSTACK@
CONFIG_SRC_SUBDIR = arch cli dwarf2 mi compile tui unittests guile python \
target nat gdbtk/generic
-CONFIG_DEP_SUBDIR = $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
# -I. for config files.
# -I$(srcdir) for gdb internal headers.
@@ -2092,15 +2091,11 @@ PYTHON_CFLAGS = @PYTHON_CFLAGS@
all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.gdb gcore gstack gdb-add-index
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do
-# Rule for compiling .c files in the top-level gdb directory.
-# The order-only dependencies ensure that we create the build subdirectories.
-%.o: %.c | $(CONFIG_DEP_SUBDIR)
+# Rule for compiling .c files.
+%.o: %.c
$(COMPILE) $<
$(POSTCOMPILE)
-$(CONFIG_DEP_SUBDIR):
- $(ECHO_GEN) $(SHELL) $(srcdir)/../install-sh -d $@
-
# Python files need special flags.
python/%.o: INTERNAL_CFLAGS += $(PYTHON_CFLAGS)
@@ -2413,10 +2408,10 @@ clean mostlyclean: $(CONFIG_CLEAN)
rm -f gdb$(EXEEXT) core make.log
rm -f gdb[0-9]$(EXEEXT)
rm -f xml-builtin.c stamp-xml
- rm -f $(DEPDIR)/*
- for i in $(CONFIG_SRC_SUBDIR); do \
- rm -f $$i/*.o; \
- rm -f $$i/$(DEPDIR)/*; \
+ rm -f $(addsuffix /*.o,$(CONFIG_SRC_SUBDIR))
+ rm -f $(addsuffix /*,$(ALL_DEPDIRS))
+ for d in $(ALL_DEPDIRS); do \
+ if test -d "$$d"; then rmdir "$$d" || exit 1; fi; \
done
# This used to depend on c-exp.c m2-exp.c TAGS
@@ -2431,10 +2426,6 @@ distclean: clean
rm -f config.log config.cache
rm -f config.lt libtool
rm -f Makefile
- rm -rf $(DEPDIR)
- for i in $(CONFIG_SRC_SUBDIR); do \
- if test -d $$i/$(DEPDIR); then rmdir $$i/$(DEPDIR); fi \
- done
maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
realclean: maintainer-clean
@@ -2816,12 +2807,20 @@ all_gdbtk_cflags = $(IDE_CFLAGS) $(ITCL_CFLAGS) \
# dependency tracking.
all_object_files = gdb.o $(LIBGDB_OBS) gdbtk/generic/gdbtk-main.o
+# All the directories in which we put dependency files.
+ALL_DEPDIRS = $(DEPDIR) $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
+
+$(ALL_DEPDIRS):
+ $(ECHO_GEN) mkdir -p $@
+
# All the .deps files to include.
all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\
$(dir $(dep))/$(DEPDIR)/$(notdir $(dep)))
-# Ensure that generated files are created early.
-$(all_object_files): | $(generated_files)
+# Ensure that the generated files and the dependency directories are created
+# early. Creating a dependency directory also creates the directory the
+# objects go in.
+$(all_object_files): | $(generated_files) $(ALL_DEPDIRS)
# Dependencies.
-include $(all_deps_files)
diff --git a/gdb/configure b/gdb/configure
index 94cc893a8715..4078a8af9f4a 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -22696,9 +22696,6 @@ rmdir .tst 2>/dev/null
DEPDIR="${am__leading_dot}deps"
-ac_config_commands="$ac_config_commands depdir"
-
-
# 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
@@ -34692,7 +34689,6 @@ fi
ac_aux_dir='$ac_aux_dir'
-ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
# Capture the value of obsolete ALL_LINGUAS because we need it to compute
# POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
# from automake.
@@ -34712,7 +34708,6 @@ do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
- "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
"default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"jit-reader.h") CONFIG_FILES="$CONFIG_FILES jit-reader.h:jit-reader.in" ;;
"nm.h") CONFIG_LINKS="$CONFIG_LINKS nm.h:$GDB_NM_FILE" ;;
@@ -36161,7 +36156,6 @@ compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
_LT_EOF
;;
- "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
"default-1":C)
for ac_file in $CONFIG_FILES; do
# Support "outfile[:infile[:infile...]]"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index d8b2498f415b..f15a2e16947c 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -60,7 +60,7 @@ AX_CXX_COMPILE_STDCXX(17, , mandatory)
GDB_AC_COMMON
# Dependency checking.
-ZW_CREATE_DEPDIR
+AM_SET_DEPDIR
# 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 5054597bf6ef..5c3252d64454 100644
--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -27,7 +27,7 @@ program_transform_name = @program_transform_name@
bindir = @bindir@
libdir = @libdir@
-CONFIG_SRC_SUBDIR = @CONFIG_SRC_SUBDIR@
+CONFIG_SRC_SUBDIR = arch gdbsupport nat target
install_sh = @install_sh@
@@ -428,17 +428,14 @@ mostlyclean clean:
rm -f $(IPA_LIB)
rm -f *-generated.cc
rm -f stamp-xml
- rm -f $(DEPDIR)/*.Po
- for i in $(CONFIG_SRC_SUBDIR); do \
- rm -f $$i/*.o; \
- rm -f $$i/$(DEPDIR)/*; \
+ rm -f $(addsuffix /*.o,$(CONFIG_SRC_SUBDIR))
+ rm -f $(addsuffix /*,$(ALL_DEPDIRS))
+ for d in $(ALL_DEPDIRS); do \
+ if test -d "$$d"; then rmdir "$$d" || exit 1; fi; \
done
maintainer-clean realclean distclean: clean
rm -f Makefile config.status config.h stamp-h config.log config.cache
- for i in $(CONFIG_SRC_SUBDIR); do \
- rmdir $$i/$(DEPDIR); \
- done
config.h: stamp-h ; @true
stamp-h: config.in config.status
@@ -596,8 +593,16 @@ gdbreplay.o: gdbreplay.cc
# dependency tracking.
all_object_files = $(OBS) $(GDBREPLAY_OBS) $(IPA_OBJS)
-# Ensure that generated files are created early.
-$(all_object_files): | $(generated_files)
+# All the directories in which we put dependency files.
+ALL_DEPDIRS = $(DEPDIR) $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR))
+
+$(ALL_DEPDIRS):
+ $(ECHO_GEN) mkdir -p $@
+
+# Ensure that the generated files and the dependency directories are created
+# early. Creating a dependency directory also creates the directory the
+# objects go in.
+$(all_object_files): | $(generated_files) $(ALL_DEPDIRS)
# All the .deps files to include.
all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\
diff --git a/gdbserver/configure b/gdbserver/configure
index 3cf8df2c3ae1..dd749fcb55bc 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -637,7 +637,6 @@ REPORT_BUGS_TO
PKGVERSION
WERROR_CFLAGS
WARN_CFLAGS
-CONFIG_SRC_SUBDIR
CATOBJEXT
GENCAT
INSTOBJEXT
@@ -10956,9 +10955,6 @@ rmdir .tst 2>/dev/null
DEPDIR="${am__leading_dot}deps"
-ac_config_commands="$ac_config_commands depdir"
-
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
@@ -12813,13 +12809,6 @@ $as_echo "$LINGUAS" >&6; }
fi
-# Create sub-directories for objects and dependencies.
-CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
-
-
-ac_config_commands="$ac_config_commands gdbdepdir"
-
-
for ac_header in \
arpa/inet.h \
fcntl.h \
@@ -15459,7 +15448,6 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#
# INIT-COMMANDS
#
-ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
# Capture the value of obsolete ALL_LINGUAS because we need it to compute
# POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
# from automake.
@@ -15467,7 +15455,6 @@ ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR
# Capture the value of LINGUAS because we need it to compute CATALOGS.
LINGUAS="${LINGUAS-%UNSET%}"
-ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"
_ACEOF
@@ -15478,9 +15465,7 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
- "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
"default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
- "gdbdepdir") CONFIG_COMMANDS="$CONFIG_COMMANDS gdbdepdir" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -16038,7 +16023,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
case $ac_file$ac_mode in
"config.h":H) echo > stamp-h ;;
- "depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
"default-1":C)
for ac_file in $CONFIG_FILES; do
# Support "outfile[:infile[:infile...]]"
@@ -16140,11 +16124,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
;;
esac
done ;;
- "gdbdepdir":C)
- for subdir in ${CONFIG_SRC_SUBDIR}
- do
- $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
- done ;;
esac
done # for ac_tag
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index a549a8712fc1..f1466e8568d4 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -60,22 +60,11 @@ ACX_NONCANONICAL_TARGET
ACX_NONCANONICAL_HOST
# Dependency checking.
-ZW_CREATE_DEPDIR
+AM_SET_DEPDIR
dnl Set up for gettext.
ZW_GNU_GETTEXT_SISTER_DIR
-# Create sub-directories for objects and dependencies.
-CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
-AC_SUBST(CONFIG_SRC_SUBDIR)
-
-AC_CONFIG_COMMANDS([gdbdepdir],[
- for subdir in ${CONFIG_SRC_SUBDIR}
- do
- $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
- done],
- [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"])
-
AC_CHECK_HEADERS([ \
arpa/inet.h \
fcntl.h \
base-commit: 6f24afa4391bd33f1263378280b99385d2c13055
prerequisite-patch-id: 4f4b30b2ac5cedd183ab34dc0a5e1995ab17c343
prerequisite-patch-id: ea27f63da8112eedd7bcb94b112158765f636d9f
prerequisite-patch-id: 16938c0ecc58221f58f9b6990586df156aa87efe
prerequisite-patch-id: 7d6a54a68713775ca87608cac8707973068e5cca
prerequisite-patch-id: 8c9c3cb5533f832ca7060dbc5ac26b5160817c79
--
2.55.0
next prev parent reply other threads:[~2026-09-01 20:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 18:51 [PATCH 0/7] Some Makefile cleanups Simon Marchi
2026-08-31 18:51 ` [PATCH 1/7] gdb: update README about the GNU make requirement Simon Marchi
2026-09-01 12:26 ` Eli Zaretskii
2026-09-01 13:36 ` Simon Marchi
2026-08-31 18:51 ` [PATCH 2/7] gdb, gdbserver: require gcc-style dependency generation, drop the depcomp fallback Simon Marchi
2026-09-01 16:32 ` Tom Tromey
2026-09-01 20:16 ` Simon Marchi
2026-09-02 7:37 ` Rainer Orth
2026-09-02 12:26 ` Simon Marchi
2026-08-31 18:51 ` [PATCH 3/7] gdbserver: fix missing dependency tracking for gdbreplay.o Simon Marchi
2026-09-01 16:33 ` Tom Tromey
2026-08-31 18:51 ` [PATCH 4/7] gdb, gdbserver: always use order-only prerequisites for generated files Simon Marchi
2026-09-01 16:34 ` Tom Tromey
2026-08-31 18:51 ` [PATCH 5/7] gdb, gdbserver: remove the .NOEXPORT target Simon Marchi
2026-09-01 16:37 ` Tom Tromey
2026-08-31 18:51 ` [PATCH 6/7] gdb: remove the explicit ada-exp.o rule Simon Marchi
2026-09-01 16:38 ` Tom Tromey
2026-08-31 18:51 ` [PATCH 7/7] gdb, gdbserver: create the dependency directories from the Makefiles Simon Marchi
2026-09-01 16:47 ` Tom Tromey
2026-09-01 20:18 ` Simon Marchi
2026-09-01 20:37 ` Simon Marchi [this message]
2026-09-02 18:36 ` Tom Tromey
2026-09-03 13:45 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ac89acc-90e4-4650-9345-ea15b4101c67@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox