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]

Re: [PATCH] new-bootstrap with preinstalling


What about this one? It checks in configure whether to use mv (a bit less comfortable) or ln (a bit less portable).

Ok if the gcc patch is reviewed and considered fine?

Thanks,

Paolo
Index: Makefile.tpl
===================================================================
RCS file: /cvs/gcc/gcc/Makefile.tpl,v
retrieving revision 1.94
diff -u -r1.94 Makefile.tpl
--- Makefile.tpl	26 Apr 2004 12:08:07 -0000	1.94
+++ Makefile.tpl	11 May 2004 15:54:55 -0000
@@ -1281,14 +1281,22 @@
 # GCC bootstrap support
 # ---------------------
 
-# We name the directories for the various stages "stage1-gcc",
-# "stage2-gcc","stage3-gcc", etc.  
-# Unfortunately, the 'compare' process will fail (on debugging information)
-# if any directory names are different!
-# So in the building rule for each stage, we relocate them before and after.
-# The current one is 'gcc', while the previous one is 'prev-gcc'.  (The
-# current one must be 'gcc' for now because the scripts in that directory
-# assume it.)
+# We track the current stage (the one in 'gcc') in the stage_last file.
+# We name the build directories for the various stages "stage1-gcc",
+# "stage2-gcc","stage3-gcc", etc.  gcc is installed to a special staging
+# area (a 'stage1' or 'stage2' directory) at the end of stage1 and stage2
+# builds.  To avoid bootstrap comparison failures, we must compile stage1
+# and stage2 with the final prefix, and invoke them with -B.  The idea is
+# that in the future all prebootstrap packages will be gathered into this
+# staging area, so that assemblers and linkers can be bootstrapped as well
+# as the compiler (both in a combined tree, or separately).
+
+# Since the 'compare' process will fail (on debugging information) if any
+# directory names are different, we need to link the staging area to a
+# constant name ('stage-prev'), and to make the name of the build directories
+# constant as well. For the latter, we use naked names like 'gcc', because
+# the scripts in that directory assume it.
+
 # At the end of the bootstrap, 'stage3-gcc' must be moved to 'gcc' so that
 # libraries can find it.  Ick!
 
@@ -1314,16 +1322,25 @@
 # * Likewise, we force-disable coverage flags, since the installed compiler
 #   probably has never heard of them.
 # * We build only C (and possibly Ada).
+
+new-stage1-start:
+	[ -f stage_last ] && $(MAKE) new-`cat stage_last`-end; \
+	echo stage1 > stage_last ; \
+	[ -d stage1-gcc ] || mkdir stage1-gcc; \
+	set stage1-gcc gcc ; @CREATE_LINK_TO_DIR@
+
+new-stage1-end:
+	set gcc stage1-gcc ; @UNDO_LINK_TO_DIR@; \
+	rm -f stage_last
+
 configure-stage1-gcc:
-	echo configure-stage1-gcc > stage_last ; \
+	$(MAKE) new-stage1-start ; \
 	if [ -f stage1-gcc/Makefile ] ; then \
 	  $(STAMP) configure-stage1-gcc ; \
 	  exit 0; \
 	else \
 	  true ; \
 	fi ; \
-	[ -d stage1-gcc ] || mkdir stage1-gcc; \
-	mv stage1-gcc gcc ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -1359,10 +1376,8 @@
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) $${srcdiroption} \
 	  --disable-intermodule --disable-coverage \
-	  --enable-languages="$(STAGE1_LANGUAGES)"; \
-	cd .. ; \
-	mv gcc stage1-gcc ; \
-	$(STAMP) configure-stage1-gcc
+	  --enable-languages="$(STAGE1_LANGUAGES)" \
+	  --program-transform-name=s,y,y, && $(STAMP) ../configure-stage1-gcc
 
 # Real targets act phony if they depend on phony targets; this hack
 # prevents gratuitous rebuilding of stage 1.
@@ -1371,32 +1386,38 @@
 	$(STAMP) prebootstrap
 
 all-stage1-gcc: configure-stage1-gcc prebootstrap
-	echo all-stage1-gcc > stage_last ; \
+	$(MAKE) new-stage1-start ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	mv stage1-gcc gcc ; \
 	cd gcc && \
 	$(MAKE) $(GCC_FLAGS_TO_PASS) \
-		CFLAGS="$(STAGE1_CFLAGS)" && $(STAMP) ../all-stage1-gcc ; \
-	result=$$? ; \
-	cd .. ; \
-	mv gcc stage1-gcc ; \
-	exit $$result
+		CFLAGS="$(STAGE1_CFLAGS)" && \
+	$(STAMP) ../all-stage1-gcc && \
+	$(MAKE) $(GCC_FLAGS_TO_PASS) DESTDIR="$$r/stage1" install
 
 # TODO: Deal with STAGE_PREFIX (which is only for ada, incidentally)
 # Possibly pass --enable-werror-always (depending on --enable-werror);
 # that's what @stage2_werror_flag@ is for
+new-stage2-start:
+	[ -f stage_last ] && $(MAKE) new-`cat stage_last`-end; \
+	echo stage2 > stage_last ; \
+	[ -d stage2-gcc ] || mkdir stage2-gcc; \
+	set stage2-gcc gcc ; @CREATE_LINK_TO_DIR@ ; \
+	set stage1 stage-prev ; @CREATE_LINK_TO_DIR@
+
+new-stage2-end:
+	set gcc stage2-gcc ; @UNDO_LINK_TO_DIR@ ; \
+	set stage-prev stage1 ; @UNDO_LINK_TO_DIR@; \
+	rm -f stage_last
+
 configure-stage2-gcc: all-stage1-gcc
-	echo configure-stage2-gcc > stage_last ; \
+	$(MAKE) new-stage2-start
 	if [ -f stage2-gcc/Makefile ] ; then \
 	  $(STAMP) configure-stage2-gcc ; \
 	  exit 0; \
 	else \
 	  true ; \
 	fi ; \
-	[ -d stage2-gcc ] || mkdir stage2-gcc; \
-	mv stage2-gcc gcc ; \
-	mv stage1-gcc prev-gcc ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -1414,8 +1435,8 @@
 	WINDRES="$(WINDRES)"; export WINDRES; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
-	CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
-	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \
+	CC="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)"; export CC; \
+	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)"; export CC_FOR_BUILD; \
 	echo Configuring stage 2 in gcc; \
 	cd gcc || exit 1; \
 	case $(srcdir) in \
@@ -1430,47 +1451,48 @@
 	    libsrcdir="$$s/gcc";; \
 	esac; \
 	$(SHELL) $${libsrcdir}/configure \
-	  $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \
-	cd .. ; \
-	mv gcc stage2-gcc ; \
-	mv prev-gcc stage1-gcc ; \
-	$(STAMP) configure-stage2-gcc
+	  $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ \
+	  --program-transform-name=s,y,y, && $(STAMP) ../configure-stage2-gcc
 
 # Flags to pass to stage2 and later makes.
 BOOT_CFLAGS= -g -O2
 POSTSTAGE1_FLAGS_TO_PASS = \
+        CC="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)" \
+        CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)" \
 	CFLAGS="$(BOOT_CFLAGS)" \
+	STAGE_PREFIX=$$r/prev-gcc/ \
 	ADAC="\$$(CC)"
 
 all-stage2-gcc: all-stage1-gcc configure-stage2-gcc
-	echo all-stage2-gcc > stage_last ; \
+	$(MAKE) new-stage2-start ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	mv stage2-gcc gcc ; \
-	mv stage1-gcc prev-gcc ; \
 	cd gcc && \
-	$(MAKE) $(GCC_FLAGS_TO_PASS) \
-		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
-		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
-		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage2-gcc ; \
-	result=$$? ; \
-	cd .. ; \
-	mv prev-gcc stage1-gcc ; \
-	mv gcc stage2-gcc ; \
-	exit $$result
+	$(MAKE) $(GCC_FLAGS_TO_PASS) $(POSTSTAGE1_FLAGS_TO_PASS) && \
+	$(STAMP) ../all-stage2-gcc && \
+	$(MAKE) $(GCC_FLAGS_TO_PASS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+	        DESTDIR="$$r/stage2" install
+
+new-stage3-start:
+	[ -f stage_last ] && $(MAKE) new-`cat stage_last`-end; \
+	echo stage3 > stage_last ; \
+	[ -d stage3-gcc ] || mkdir stage3-gcc; \
+	set stage3-gcc gcc ; @CREATE_LINK_TO_DIR@ ; \
+	set stage2 stage-prev ; @CREATE_LINK_TO_DIR@
+
+new-stage3-end:
+	set gcc stage3-gcc ; @UNDO_LINK_TO_DIR@ ; \
+	set stage-prev stage2 ; @UNDO_LINK_TO_DIR@; \
+	rm -f stage_last
 
 configure-stage3-gcc: all-stage2-gcc
-	echo configure-stage3-gcc > stage_last ; \
+	$(MAKE) new-stage3-start ; \
 	if [ -f stage3-gcc/Makefile ] ; then \
 	  $(STAMP) configure-stage3-gcc ; \
 	  exit 0; \
 	else \
 	  true ; \
 	fi ; \
-	[ -d stage3-gcc ] || mkdir stage3-gcc; \
-	mv stage3-gcc gcc ; \
-	mv stage2-gcc prev-gcc ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -1488,8 +1510,8 @@
 	WINDRES="$(WINDRES)"; export WINDRES; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
-	CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
-	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \
+	CC="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)"; export CC; \
+	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/stage-prev/$(bindir)/gcc$(exeext) -B$$r/stage-prev/$(prefix)"; export CC_FOR_BUILD; \
 	echo Configuring stage 3 in gcc; \
 	cd gcc || exit 1; \
 	case $(srcdir) in \
@@ -1504,34 +1526,22 @@
 	    libsrcdir="$$s/gcc";; \
 	esac; \
 	$(SHELL) $${libsrcdir}/configure \
-	  $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \
-	cd .. ; \
-	mv gcc stage3-gcc ; \
-	mv prev-gcc stage2-gcc ; \
-	$(STAMP) configure-stage3-gcc
+	  $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ \
+	  && $(STAMP) ../configure-stage3-gcc
 
 all-stage3-gcc: all-stage2-gcc configure-stage3-gcc
-	echo all-stage3-gcc > stage_last ; \
+	$(MAKE) new-stage3-start ; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	mv stage2-gcc prev-gcc ; \
-	mv stage3-gcc gcc ; \
 	cd gcc && \
-	$(MAKE) $(GCC_FLAGS_TO_PASS) \
-		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
-		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
-		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage3-gcc \
-	result=$$? ; \
-	cd .. ; \
-	mv prev-gcc stage2-gcc ; \
-	mv gcc stage3-gcc ; \
-	exit $$result
+	$(MAKE) $(GCC_FLAGS_TO_PASS) $(POSTSTAGE1_FLAGS_TO_PASS) && \
+	$(STAMP) ../all-stage3-gcc
 
 # We only want to compare .o files, so set this!
 objext = .o
 
 compare: all-stage3-gcc
+	[ -f stage_last ] && $(MAKE) new-`cat stage_last`-end
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	rm -f .bad_compare ; \
@@ -1550,16 +1560,15 @@
 	else \
 	  true; \
 	fi ; \
-        $(STAMP) compare
+	$(STAMP) compare
 
 .PHONY: new-bootstrap
 # This target exists so that everything can be made in one pass.
 # 'all-gcc' has to avoid stomping on the bootstrap-generated gcc for
 # this to work.
 new-bootstrap: compare
-	mv stage3-gcc gcc ; \
-	$(MAKE) all ; \
-	mv gcc stage3-gcc
+	rm -f gcc ; ln -sf stage3-gcc gcc ; \
+	$(MAKE) all
 
 new-cleanstrap:
 	rm -rf configure-stage1-gcc all-stage1-gcc stage1-gcc \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/configure.in,v
retrieving revision 1.285
diff -u -r1.285 configure.in
--- configure.in	27 Apr 2004 18:20:35 -0000	1.285
+++ configure.in	11 May 2004 15:54:56 -0000
@@ -25,6 +25,7 @@
 
 # Get 'install' or 'install-sh' and its variants.
 AC_PROG_INSTALL
+AC_PROG_LN_S
 
 sinclude(config/acx.m4)
 
@@ -2140,6 +2141,20 @@
     ;;
 esac
 AC_SUBST(stage1_cflags)
+
+# It makes debugging easier if we create as symlinks the stage directories
+# gcc for stageN-gcc and stage-prev for stage(N-1).  In case this is not
+# possible, however, we can resort to mv.
+case "${LN_S}" in
+  "ln -s")
+    CREATE_LINK_TO_DIR='ln -s $$1 $$2'
+    UNDO_LINK_TO_DIR='rm -f $$1' ;;
+  *)
+    CREATE_LINK_TO_DIR='mv $$1 $$2'
+    UNDO_LINK_TO_DIR='mv $$1 $$2' ;;
+esac
+AC_SUBST(CREATE_LINK_TO_DIR)
+AC_SUBST(UNDO_LINK_TO_DIR)
 
 # Enable -Werror in bootstrap stage2 and later.
 # Change the default to "no" on release branches.

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