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]

[toplevel PATCH] Lean bootstrap


This patch adds lean bootstraps to toplevel bootstrap.  This is less
obvious than it may seem.

First of all, I decided to only allow choosing between lean and normal
bootstrap at configure time (--enable-bootstrap=lean).  This to avoid
more recursive make invocations, because the design is a bit different
from what happens in the GCC directory.  This allows restarting a
bootstrap after stage1 has been deleted, but stage2 won't be rebuilt
(it needs stage1 around).

Since I was mucking with the configure script, I implemented the behavior that Alexandre Oliva suggested a while ago, that is only warn if --enable-bootstrap was given on a non-native configuration. This allows bootstrapping "--target=i386-pc-linux-gnu" on i686.

---

Secondly, I got rid of the timestamp files configure-stage* and
all-stage*. This for several reasons. First of all, they were
behaving as phony because they depended on the maybe dependencies, so
their very creation was useless. Second, they were useless because
the stageN-bubble rules were already enforcing a strict ordering
between the different stages (so we do not need configure-stage2-gcc
to depend on all-stage1-gcc): timestamps were not enough for parallel makes to work, stageN-bubble should (not tested yet).


They also made it more complex to implement restage targets: for
example, after 'make restage2', 'make bootstrap' would not have forced
rebuilding of stage3, so the timestamp files for stage3 and successive
stages had to be touched with a pretty complex mechanism involving
double-colon rules.  Removing these timestamp files, however, meant
that the restageN targets are just performing the same function of
all-stageN: so I wiped them out because I like the all-stageN name
better.

---

Bootstrapped i686-pc-linux-gnu, both lean and normal.  Ok for gcc and
src?

Paolo
2004-08-26  Paolo Bonzini  <bonzini@gnu.org>

	* Makefile.def (bootstrap stages): Add 'lean' parameter.
	* Makefile.tpl (configure-stageN-*, all-stageN-*): Turned into
	phony targets; do not generate timestamp files.
	(distclean-stageN): Remove references to their timestamp files.
	(restageN, touch-stageN): Remove.
	(stageN-bubble): Rewritten.
	(compare): Support lean bootstraps.
	* Makefile.in: Regenerate.

	* configure.in: Only warn when bootstrapping but
	build != host or build != target.  Support lean bootstraps.
	* configure: Regenerate.

Index: Makefile.def
===================================================================
RCS file: /cvs/gcc/gcc/Makefile.def,v
retrieving revision 1.34
diff -u -r1.34 Makefile.def
--- Makefile.def	17 Aug 2004 07:26:38 -0000	1.34
+++ Makefile.def	27 Aug 2004 13:31:49 -0000
@@ -445,14 +445,14 @@
 	stage_configure_flags="@stage2_werror_flag@" ;
 	stage_make_flags="" ; };
 bootstrap_stage = {
-	id=3 ; prev=2 ;
+	id=3 ; prev=2 ; lean=1 ;
 	compare_target=compare ;
 	bootstrap_target=bootstrap ;
 	cleanstrap_target=cleanstrap ;
 	stage_configure_flags="@stage2_werror_flag@" ;
 	stage_make_flags="" ; };
 bootstrap_stage = {
-	id=4 ; prev=3 ;
+	id=4 ; prev=3 ; lean=2 ;
 	compare_target=compare3 ;
 	bootstrap_target=bootstrap4 ;
 	stage_configure_flags="@stage2_werror_flag@" ;
Index: Makefile.tpl
===================================================================
RCS file: /cvs/gcc/gcc/Makefile.tpl,v
retrieving revision 1.111
diff -u -r1.111 Makefile.tpl
--- Makefile.tpl	17 Aug 2004 07:26:38 -0000	1.111
+++ Makefile.tpl	27 Aug 2004 13:31:51 -0000
@@ -1396,12 +1396,14 @@
 # are remade, but not reconfigured.  The next stage (if any) will not
 # be reconfigured as well.
 .PHONY: stage[+id+]-bubble
-stage[+id+]-bubble:: [+ IF prev +]stage[+prev+]-bubble[+ ENDIF +]
-	@case `echo all-stage[+id+]-*` in \
-	  'all-stage[+id+]-*') ;; \
-	  *) echo Remaking stage [+id+] ; rm -f all-stage[+id+]-* ;; \
-	esac ; \
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage[+id+]
+stage[+id+]-bubble:: [+ IF prev +]stage[+prev+]-bubble[+ ENDIF +][+IF lean +]
+	@bootstrap_lean@-rm -rf stage[+lean+]-* ; $(STAMP) stage[+lean+]-lean[+ ENDIF lean +]
+	@if test -f stage[+id+]-lean [+
+	  IF prev +]|| test -f stage[+prev+]-lean [+ ENDIF prev +] ; then \
+	  echo Skipping rebuild of stage[+id+] ; \
+	else \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage[+id+]; \
+	fi
 
 .PHONY: all-stage[+id+]
 all-stage[+id+]: [+ FOR host_modules +][+ IF bootstrap +]\
@@ -1409,19 +1411,17 @@
 ENDIF bootstrap+] [+ ENDFOR host_modules +]
 
 [+ FOR host_modules +][+ IF bootstrap +]
+.PHONY: configure-stage[+id+]-[+module+] maybe-configure-stage[+id+]-[+module+]
+.PHONY: all-stage[+id+]-[+module+] maybe-all-stage[+id+]-[+module+]
+
 maybe-configure-stage[+id+]-[+module+]:
 maybe-all-stage[+id+]-[+module+]:
 
 @if [+module+]-bootstrap
 maybe-configure-stage[+id+]-[+module+]: configure-stage[+id+]-[+module+]
-configure-stage[+id+]-[+module+]: [+ IF prev +] maybe-all-stage[+prev+]-[+module+] [+ ENDIF prev +]
-	$(MAKE) stage[+id+]-start
-	@if [ -f stage[+id+]-[+module+]/Makefile ] ; then \
-	  $(STAMP) configure-stage[+id+]-[+module+] ; \
-	  exit 0; \
-	else \
-	  true ; \
-	fi ; \
+configure-stage[+id+]-[+module+]:
+	@$(MAKE) stage[+id+]-start
+	@[ -f [+module+]/Makefile ] && exit 0 || : ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; [+ IF prev +] \
 	$(STAGE_HOST_EXPORTS) [+ ELSE prev +] \
@@ -1441,12 +1441,11 @@
 	esac; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) $${srcdiroption} \
-	  [+stage_configure_flags+] [+extra_configure_flags+] && \
-	  $(STAMP) ../configure-stage[+id+]-[+module+]
+	  [+stage_configure_flags+] [+extra_configure_flags+]
 
 maybe-all-stage[+id+]-[+module+]: all-stage[+id+]-[+module+]
 all-stage[+id+]-[+module+]: configure-stage[+id+]-[+module+]
-	$(MAKE) stage[+id+]-start
+	@$(MAKE) stage[+id+]-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; [+ IF prev +] \
 	$(STAGE_HOST_EXPORTS) [+ ELSE prev +] \
@@ -1454,8 +1453,7 @@
 	cd [+module+] && \
 	$(MAKE) $(FLAGS_TO_PASS) [+ IF prev +] \
 		$(POSTSTAGE1_FLAGS_TO_PASS) [+ ENDIF prev +] \
-		[+stage_make_flags+] [+extra_make_flags+] && \
-	$(STAMP) ../all-stage[+id+]-[+module+]
+		[+stage_make_flags+] [+extra_make_flags+]
 @endif [+module+]-bootstrap
 [+ ENDIF bootstrap +][+ ENDFOR host_modules +]
 
@@ -1463,8 +1461,12 @@
 # only possibility, but now it conflicts with no-bootstrap rules
 @if gcc-bootstrap
 [+ IF compare-target +]
-[+compare-target+]: all-stage[+id+]-gcc
-	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
+[+compare-target+]:
+	@if test -f stage[+prev+]-lean; then \
+	  echo Cannot compare object files as stage [+prev+] was deleted. ; \
+	  exit 0 ; \
+	fi; \
+	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	rm -f .bad_compare ; \
@@ -1483,49 +1485,23 @@
 	else \
 	  true; \
 	fi ; \
-	$(STAMP) [+compare-target+]
+	$(STAMP) [+compare-target+][+ IF prev +]
+	@bootstrap_lean@-rm -rf stage[+prev+]-* ; $(STAMP) stage[+prev+]-lean[+ ENDIF prev +]
 [+ ENDIF compare-target +]
 
 [+ IF bootstrap-target +]
 .PHONY: [+bootstrap-target+]
-[+bootstrap-target+]: stage[+id+]-bubble [+
-	  IF compare-target +] [+compare-target+] [+
-	  ENDIF compare-target +] all
+[+bootstrap-target+]: stage[+id+]-bubble [+compare-target+] all
 [+ ENDIF bootstrap-target +]
 
-.PHONY: restage[+id+] touch-stage[+id+] distclean-stage[+id+]
+.PHONY: distclean-stage[+id+]
 
 # Rules to wipe a stage and all the following ones, used for cleanstrap
 [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
 distclean-stage[+id+]::
 	[ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
-	rm -rf configure-stage[+id+]-* all-stage[+id+]-* stage[+id+]-* [+
-	  IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
-
-# Rules to renew the timestamp on a stage and all the following ones
-[+ IF prev +]touch-stage[+prev+]:: touch-stage[+id+] [+ ENDIF prev +]
-touch-stage[+id+]::
-	@case `echo configure-stage[+id+]-*` in \
-	  'configure-stage[+id+]-*') ;; \
-	  *) \
-	    echo '$(STAMP)' configure-stage[+id+]-* && \
-	    $(STAMP) configure-stage[+id+]-* ;; \
-	esac ; \
-	case `echo all-stage[+id+]-*` in \
-	  'all-stage[+id+]-*') ;; \
-	  *) \
-	    echo '$(STAMP)' all-stage[+id+]-* && \
-	    $(STAMP) all-stage[+id+]-* ;; \
-	esac
-
-# After building a stage, touch the following ones
-[+ IF prev +]restage[+prev+]:: touch-stage[+id+] [+ ENDIF prev +]
-restage[+id+]::
-	rm -rf all-stage[+id+]-* [+
+	rm -rf stage[+id+]-* [+
 	  IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
-	$(MAKE) $(RECURSE_FLAGS_TO_PASS) [+
-	  IF compare-target +][+compare-target+] [+
-	  ELSE +] all-stage[+id+] [+ ENDIF compare-target +]
 
 [+ IF cleanstrap-target +]
 .PHONY: [+cleanstrap-target+]
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/configure.in,v
retrieving revision 1.312
diff -u -r1.312 configure.in
--- configure.in	26 Aug 2004 23:57:46 -0000	1.312
+++ configure.in	27 Aug 2004 13:31:51 -0000
@@ -1695,28 +1695,62 @@
 # not to nest @if/@endif pairs, because configure will not warn you at all.
 
 AC_ARG_ENABLE([bootstrap],
-[  --enable-bootstrap     Enable bootstrapping [no]],,
-enable_bootstrap=no)
-if test -d ${srcdir}/gcc; then
-  case "$host:$target:$enable_bootstrap" in
-    $build:$build:yes | *:no) ;;
-    *:yes) AC_MSG_ERROR([cannot bootstrap a cross-compiler]) ;;
-    *) AC_MSG_ERROR([invalid option for --enable-bootstrap]) ;;
-  esac
-else
-  if test $enable_bootstrap = yes; then
-    AC_MSG_ERROR([cannot bootstrap without a compiler])
-  fi
-fi
+[  --enable-bootstrap[=lean]     Enable bootstrapping [no]],,
+enable_bootstrap=default)
+
+# Issue errors and warnings for invalid/strange bootstrap combinations.
+case "$configdirs" in
+  *gcc*) have_compiler=yes ;;
+  *) have_compiler=no ;;
+esac
+
+case "$have_compiler:$host:$target:$enable_bootstrap" in
+  *:*:*:no) ;;
+
+  # Default behavior.  (We'll) enable bootstrap if we have a compiler
+  # and we are in a native configuration.
+  yes:$build:$build:default)
+    # This will become 'yes'
+    enable_bootstrap=no ;;
+
+  *:*:*:default)
+    enable_bootstrap=no ;;
+
+  # We have a compiler and we are in a native configuration, bootstrap is ok
+  yes:$build:$build:yes | yes:$build:$build:lean)
+    ;;
+
+  # Other configurations, but we have a compiler.  Assume the user knows
+  # what he's doing.
+  yes:*:*:yes | yes:*:*:lean)
+    AC_MSG_WARN([trying to bootstrap a cross compiler])
+    ;;
+
+  # No compiler: if they passed --enable-bootstrap explicitly, fail
+  no:*:*:yes | no:*:*:lean)
+    AC_MSG_ERROR([cannot bootstrap without a compiler]) ;;
+
+  # Fail if wrong command line
+  *)
+    AC_MSG_ERROR([invalid option for --enable-bootstrap])
+    ;;
+esac
 
+# Adjust the toplevel makefile according to whether bootstrap was selected.
 case "$enable_bootstrap" in
   yes)
+    bootstrap_lean='#'
+    default_target=bootstrap
+    bootstrap_suffix=bootstrap ;;
+  lean)
+    bootstrap_lean=''
     default_target=bootstrap
     bootstrap_suffix=bootstrap ;;
   no)
     default_target=all
     bootstrap_suffix=no-bootstrap ;;
 esac
+AC_SUBST(bootstrap_lean)
 AC_SUBST(default_target)
 
 for module in ${build_configdirs} ; do

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