From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OVYmI/TNlWqVRRgAWB0awg (envelope-from ) for ; Mon, 31 Aug 2026 14:54:44 -0400 Received: by simark.ca (Postfix, from userid 112) id 8CBA31E033; Mon, 31 Aug 2026 14:54:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 596361E033 for ; Mon, 31 Aug 2026 14:54:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF4DF4BA798A for ; Mon, 31 Aug 2026 18:54:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF4DF4BA798A Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D58414BA2E38 for ; Mon, 31 Aug 2026 18:53:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D58414BA2E38 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D58414BA2E38 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788202391; cv=none; b=FcQcZL1AW8LRE6A4u/wuYxy4NqxJC+h9zanPy8p/03Oieuml9CGGw02U4EYSME+rVAUC1lybGCtw/VCmg8yuLXBnU6vG/QaFSNJ+k/oeL0NoZa2wnsNheuYOk3Am3RzJAWor33jnEI4IuU1Bm3Ff1v+OIQk47fBDm1kiEDfclf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788202391; c=relaxed/simple; bh=+gEdjpK10zBTOxiqzvqFucVfarIpSRv0ftdK1qLGYUk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=GNP8HVSQ4txmfr3UKktBi6eM9PGaQ3SP/ZZ7tJrTMQ08mP2rQfDEaQcDphv6DSp8kZTmXOvZNfZsfM9RswChDQP4ZKtvwxDeWJOeAEIM0yBGrme/TiTTpLX5Z42wHcE8pUfbDSKs0zfy48WzI+JEKvt4Bl1RfAtAr4zdsRPLGeQ= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D58414BA2E38 Received: by simark.ca (Postfix) id DC9451E173; Mon, 31 Aug 2026 14:53:05 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 7/7] gdb, gdbserver: create the dependency directories from the Makefiles Date: Mon, 31 Aug 2026 14:51:46 -0400 Message-ID: <20260831185300.572297-8-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831185300.572297-1-simon.marchi@efficios.com> References: <20260831185300.572297-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@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. - Since we now have a variable (ALL_DEPDIRS) listing all .deps directories, use it where convenient in the clean and distclean targets. 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, 31 insertions(+), 69 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index cf10bc17320b..3585f2015ff0 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,11 +2408,8 @@ 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)/*; \ - done + rm -f $(addsuffix /*,$(ALL_DEPDIRS)) + rm -f $(addsuffix /*.o,$(CONFIG_SRC_SUBDIR)) # This used to depend on c-exp.c m2-exp.c TAGS # I believe this is wrong; the makefile standards for distclean just @@ -2431,10 +2423,7 @@ 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 + rm -rf $(ALL_DEPDIRS) maintainer-clean: local-maintainer-clean do-maintainer-clean distclean realclean: maintainer-clean @@ -2816,12 +2805,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..9417a93268cd 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,12 @@ 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)/*; \ - done + rm -f $(addsuffix /*,$(ALL_DEPDIRS)) + rm -f $(addsuffix /*.o,$(CONFIG_SRC_SUBDIR)) 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 + rm -rf $(ALL_DEPDIRS) config.h: stamp-h ; @true stamp-h: config.in config.status @@ -596,8 +591,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 \ -- 2.55.0