Patchwork [RFA] Fix dependency tracking for objects in subdirectories

login
register
mail settings
Submitter Tom Tromey
Date Nov. 30, 2017, 6:52 p.m.
Message ID <20171130185211.5778-1-tom@tromey.com>
Download mbox | patch
Permalink /patch/24640/
State New
Headers show

Comments

Tom Tromey - Nov. 30, 2017, 6:52 p.m.
On irc, Pedro pointed out that dependencies for objects in
subdirectories didn't seem to be working.

The bug was that the "-include" for .deps files was using the wrong file
name for subdirectory objects; e.g., for cli/cli-decode.o it was trying
to open .deps/cli/cli-decode.o, whereas the correct file is
cli/.deps/cli-decode.o.

This patch changes how the dep files are found.  Tested by touching a
source file and rebuilding cli/cli-decode.o.

2017-11-30  Tom Tromey  <tom@tromey.com>

	* Makefile.in (all_deps_files): New variable.
	Include .Po files using all_deps_files.
---
 gdb/ChangeLog   | 5 +++++
 gdb/Makefile.in | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
Pedro Alves - Dec. 1, 2017, 12:04 p.m.
On 11/30/2017 06:52 PM, Tom Tromey wrote:
> On irc, Pedro pointed out that dependencies for objects in
> subdirectories didn't seem to be working.
> 
> The bug was that the "-include" for .deps files was using the wrong file
> name for subdirectory objects; e.g., for cli/cli-decode.o it was trying
> to open .deps/cli/cli-decode.o, whereas the correct file is
> cli/.deps/cli-decode.o.
> 
> This patch changes how the dep files are found.  Tested by touching a
> source file and rebuilding cli/cli-decode.o.
> 
> 2017-11-30  Tom Tromey  <tom@tromey.com>
> 
> 	* Makefile.in (all_deps_files): New variable.
> 	Include .Po files using all_deps_files.

OK.

Thanks,
Pedro Alves

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bd1eccfb68..a7d76c058c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-11-30  Tom Tromey  <tom@tromey.com>
+
+	* Makefile.in (all_deps_files): New variable.
+	Include .Po files using all_deps_files.
+
 2017-11-29  Tom Tromey  <tom@tromey.com>
 
 	* Makefile.in (distclean): Handle the case where rmdir fails.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 284559b030..5823098036 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2644,6 +2644,10 @@  endif
 all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
 	test-cp-name-parser.o
 
+# 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.  Use order-only
 # dependencies if available.  They require GNU make 3.80 or newer,
 # and the .VARIABLES variable was introduced at the same time.
@@ -2654,7 +2658,7 @@  $(all_object_files) : $(generated_files)
 endif
 
 # Dependencies.
--include $(patsubst %.o, $(DEPDIR)/%.Po, $(all_object_files))
+-include $(all_deps_files)
 
 # Disable implicit make rules.
 include $(srcdir)/disable-implicit-rules.mk