This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Makefile] Stop unnecessarily rebuilding gcc, cc1, et al.


gcc.o, cppdefault.o, toplev.o, prefix.o, and intl.o all depend on Makefile since they use -D defines when they are built. These files depending on Makefile pessimizes developers since Makefile is often regen'd without actually modifying any of those particular defines. Nevertheless we ended up rebuilding libbackend and all the executables.

The simple solution was to create five new temporary files holding the contents of the defines with move-if-change for each of them. Then those five object files can properly depend on those files instead of Makefile.

In addition two generated .h files in fix-header were not using move-if-change, so also I fixed that.

Furthermore, I added "targetname" and "localedir" to libbackend.o's dependencies as it has those -D defines in its build rule. This file is only built with IMA, which AFAIK isn't working, but it falls under the obvious rule.

Tested using i686-pc-cygwin
There are no object file differences before or after this patch.
After the patch touching gcc/Makefile.in and rerunning make all-gcc in a prebuilt tree results in no changes to ANY .h, .exe or .o file (Hooray!)


OK to install?
2004-07-02  Kelley Cook  <kcook@gcc.gnu.org>

	* Makefile.in (ddefines): New temporary file with $DRIVER_DEFINES.
	* (prefixdefine): New temporary file with $prefix.
	* (targetname): New temporary file with $target_noncanonical.
	* (ppdefines): New temporary file with $PREPROCESSOR_DEFINES.
	* (localedir): New temporary file with $localedir.
	* (cppdefault.o, toplev.o, gcc.o: Depend on above instead of Makefile.
	* (prefix.o, intl.o, libbackend.o): Likewise.
	* (deduce.h): Use move-if-change.
	* (xsys-protos.h): Likewise.
	* (mostlyclean): Add new temp files.  Delete redundant comment.

--- ../../gcc-orig/gcc/Makefile.in	2004-06-23 16:12:41.000000000 -0400
+++ Makefile.in	2004-07-02 12:31:42.878273200 -0400
@@ -1466,13 +1466,17 @@ DRIVER_DEFINES = \
   `test "X$${SHLIB_LINK}" = "X" || test "@enable_shared@" != "yes" || echo "-DENABLE_SHARED_LIBGCC"` \
   `test "X$${SHLIB_MULTILIB}" = "X" || echo "-DNO_SHARED_LIBGCC_MULTILIB"`
 
+ddefines: Makefile
+	echo $(DRIVER_DEFINES) > tmp-ddefines
+	$(SHELL) $(srcdir)/../move-if-change tmp-ddefines ddefines
+
 gcc.o: gcc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h multilib.h \
-    Makefile $(lang_specs_files) specs.h prefix.h $(GCC_H)
+       ddefines $(lang_specs_files) specs.h prefix.h $(GCC_H)
 	(SHLIB_LINK='$(SHLIB_LINK)' \
 	SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-  $(DRIVER_DEFINES) \
-  -c $(srcdir)/gcc.c $(OUTPUT_OPTION))
+	$(DRIVER_DEFINES) \
+	-c $(srcdir)/gcc.c $(OUTPUT_OPTION))
 
 gccspec.o: gccspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H)
 	(SHLIB_LINK='$(SHLIB_LINK)' \
@@ -1554,7 +1558,11 @@ stringpool.o: stringpool.c $(CONFIG_H) $
 ggc-none.o: ggc-none.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(GGC_H)
 	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
-prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) Makefile prefix.h
+prefixdefine: Makefile
+	echo $(prefix) > tmp-prefixdefine
+	$(SHELL) $(srcdir)/../move-if-change tmp-prefixdefine prefixdefine
+
+prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) prefix.h prefixdefine
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	-DPREFIX=\"$(prefix)\" \
 	  -c $(srcdir)/prefix.c $(OUTPUT_OPTION)
@@ -1726,10 +1734,14 @@ opts.o : opts.c opts.h options.h toplev.
 targhooks.o : targhooks.c targhooks.h $(CONFIG_H) $(SYSTEM_H) \
 	coretypes.h $(TREE_H) $(TM_H) $(RTL_H) $(TM_P_H) function.h \
 	output.h toplev.h
-
+	
+targetname: Makefile
+	echo $(target_noncanonical) > tmp-targetname
+	$(SHELL) $(srcdir)/../move-if-change tmp-targetname targetname
+	
 toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) version.h $(RTL_H) \
    function.h $(FLAGS_H) xcoffout.h input.h $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) \
-   debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
+   debug.h insn-config.h intl.h $(RECOG_H) targetname toplev.h \
    dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
    graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) value-prof.h \
    $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
@@ -2118,7 +2130,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H) 
 # FIXME: writing proper dependencies for this is a *LOT* of work.
 libbackend.o : $(OBJS-common:.o=.c) $(out_file) \
   insn-config.h insn-flags.h insn-codes.h insn-constants.h \
-  insn-attr.h
+  insn-attr.h targetname localedir
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	  -DTARGET_NAME=\"$(target_noncanonical)\" \
 	  -DLOCALEDIR=\"$(localedir)\" \
@@ -2584,9 +2596,12 @@ min-insn-modes.o: min-insn-modes.c $(BCO
 	$(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \
 	    min-insn-modes.c $(OUTPUT_OPTION)
 
-#
-# Remake internationalization support.
-intl.o: intl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h Makefile
+localedir: Makefile
+	echo $(localedir) > tmp-localedir
+	$(SHELL) $(srcdir)/../move-if-change tmp-localedir localedir
+
+
+intl.o: intl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h localedir
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	  -DLOCALEDIR=\"$(localedir)\" \
 	  -c $(srcdir)/intl.c $(OUTPUT_OPTION)
@@ -2604,8 +2619,12 @@ PREPROCESSOR_DEFINES = \
   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
   @TARGET_SYSTEM_ROOT_DEFINE@
 
+ppdefines: Makefile
+	echo $(PREPROCESSOR_DEFINES) > tmp-ppdefines
+	$(SHELL) $(srcdir)/../move-if-change tmp-ppdefines ppdefines
+
 cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
-	cppdefault.h Makefile
+	cppdefault.h ppdefines
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	  $(PREPROCESSOR_DEFINES) \
 	  -c $(srcdir)/cppdefault.c $(OUTPUT_OPTION)
@@ -2796,7 +2815,7 @@ deduced.h: $(GCC_PASSES) $(srcdir)/scan-
 	  CC="$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -I. -I$(srcdir) -isystem include -isystem ${SYSTEM_HEADER_DIR}"; \
 	  export CC; \
 	  $(SHELL) $(srcdir)/scan-types.sh "$(srcdir)" >tmp-deduced.h; \
-	  mv tmp-deduced.h deduced.h; \
+	  $(SHELL) $(srcdir)/../move-if-change tmp-deduced.h deduced.h; \
 	else \
 	  $(STAMP) deduced.h; \
 	fi
@@ -2817,7 +2836,7 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/s
 	$(GCC_FOR_TARGET) fixtmp.c -w -U__SIZE_TYPE__ -U__PTRDIFF_TYPE__ -U__WCHAR_TYPE__ -E \
 	  | sed -e 's/	/ /g' -e 's/ *(/ (/g' -e 's/ [ ]*/ /g' -e 's/( )/()/' \
 	  | $(RUN_GEN) ./gen-protos >xsys-protos.hT
-	mv xsys-protos.hT xsys-protos.h
+	$(SHELL) $(srcdir)/../move-if-change xsys-protos.hT xsys-protos.h
 	rm -rf fixtmp.c
 
 # This is nominally a 'build' program, but it's run only when host==build,
@@ -2999,6 +3018,7 @@ mostlyclean: lang.mostlyclean
 # Delete the stamp and temporary files.
 	-rm -f s-* tmp-* stamp-* stmp-*
 	-rm -f */stamp-* */tmp-*
+	-rf -f ppdefines ddefines prefixdefine localedir targetname
 # Delete debugging dump files.
 	-rm -f *.[0-9][0-9].* */*.[0-9][0-9].*
 # Delete some files made during installation.
@@ -3019,7 +3039,6 @@ mostlyclean: lang.mostlyclean
 	-rm -f core */core
 # Delete file generated for gengtype.c
 	-rm -f gtyp-gen.h
-# Delete files generated by gengtype.c
 	-rm -f gtype-*
 	-rm -f gt-*
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]