Currently the dependencies of each build/*.o object file are manually
maintained within the Makefile and are rather incomplete.  For instance
build/vec.o doesn't depend on hash-table.h even though vec.c includes
it.  Because of this I ran into a rebuild failure after changing
hash-table.h.

Any reason why automatic dependency generation is not used for the
build/*.o objects too?  Here's a rather simple patch that achieves this.
The trick is to override the COMPILE.base variable in the build/%.o rule
and simply invoke the COMPILE and POSTCOMPILE commands in the recipe
just like the regular .c.o rule does.  Even so, the manual dependencies
can't be completely removed because there are a number of header files
that are autogenerated so if they are not explicitly depended upon they
will never be generated, like bconfig.h.

Bootstrapped on x86_64-pc-linux-gnu FWIW.

gcc/ChangeLog:

        * Makefile.in (build/%.o): Override the COMPILE.base variable
        and change the recipe to just invoke $(COMPILE) followed by
        $(POSTCOMPILE).  Always depend on %.c.
---
 gcc/Makefile.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 8d7cc51..b2a940a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2527,9 +2527,12 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_H) 
multilib.h \
 #
 # How to compile object files to run on the build machine.
 
-build/%.o :  # dependencies provided by explicit rule later
-       $(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
-               -o $@ $<
+build/%.o: COMPILE.base = $(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) \
+           $(BUILD_CPPFLAGS) -o $@
+build/%.o: %.c
+       $(COMPILE) $<
+       $(POSTCOMPILE)
+
 
 ## build/version.o is compiled by the $(COMPILER_FOR_BUILD) but needs
 ## several C macro definitions, just like version.o
-- 
2.10.0.rc1.53.gfcb49dc

Reply via email to