public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses
@ 2008-10-07  8:31 Alexandre Oliva
  2008-10-07  8:41 ` Ralf Wildenhues
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexandre Oliva @ 2008-10-07  8:31 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2360 bytes --]

This patch introduces support for BUILD_CONFIG, a Makefile macro that,
if set to say "a b", will cause config/a.mk and config/b.mk to be
included in the top-level Makefile.  The plan was to use this to add
-fcompare-debug to certain variables, and eventually add a configure
option to set a default (non-empty) value for BUILD_CONFIG.

I ran into a number of problems.  First of all, I needed CFLAGS and
CFLAGS_FOR_TARGET to vary across bootstrap levels, so that I could
build say stage2 without -fcompare-debug and stage3 with it.

Second, I found that LIBCFLAGS was not used consistently.  IMHO, we
should only use LIBCFLAGS for builds using the pre-installed host
compiler.  For target builds, we should use LIBCFLAGS_FOR_TARGET, and
for host builds in in stage2+ I can see that it makes sense to use
either STAGE_CFLAGS (being the preferred flags for GCC for that stage,
without any of the magic flags required by the compiler used to build
stage1) or CFLAGS_FOR_TARGET (being the preferred flags for the GCC
built in the previous stage).  I chose the former, for simplicity.

I also moved SYSROOT and DEBUG_PREFIX flags from *FLAGS_FOR_TARGET to
XGCC_FLAGS_FOR_TARGET, which is added to CC, CXX, GCJ and GFORTRAN
passed to target builds, along with the newly-introduced TFLAGS, which
may vary from stage to stage.

Overriding GCJ proved to be "interesting".  gcc/java/Make-lang.in
didn't want it overridden, using it internally as a target name, and
libjava/configure didn't use GCJ passed in the environment.  I fixed
both.

I also added a bunch of BUILD_CONFIGs to bootstrap with -O1 and -O3
(BOOT_CFLAGS overriders), bootstrap-debug (a much simpler
implementation of the previous bootstrap target, still using the
compare-debug script), bootstrap-debug-lib (a much simpler and faster
implementation of the previous bootstrap4-debug target, that uses
-fcompare-debug for both compiler and libraries verification in
stage3, with further optional testing in stage4),
bootstrap-debug-ckovw (that arranges for errors to be issued when
using a newly-built compiler without -fcompare-debug) and
bootstrap-time (that arranges for xgcc to dump compile, assembly and
link times to a global log file; this is useful to verify VTA compile
overhead in -fcompare-debug builds).

Here's the patch, omitting the generated files.  I'm installing it in
the VTA branch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bootstrap-configs.patch --]
[-- Type: text/x-patch, Size: 32002 bytes --]

for ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* Makefile.def (flags_to_pass): Remove redundant and incomplete
	STAGE1_CFLAGS, STAGE2_CFLAGS, STAGE3_CFLAGS, and STAGE4_CFLAGS.
	Add FLAGS_FOR_TARGET and BUILD_CONFIG.
	(bootstrap_stage): Remove bootstrap-debug custom stages.  Turn
	stage_configureflags, stage_cflags and stage_libcflags into
	explicit Makefile macros.
	* Makefile.tpl (HOST_EXPORTS, EXTRA_HOST_FLAGS): Pass GCJ and
	GFORTRAN.
	(POSTSTAGE1_HOST_EXPORTS): Add XGCC_FLAGS_FOR_TARGET and TFLAGS to
	CC.  Set CC_FOR_BUILD from CC.
	(BASE_TARGET_EXPORTS, RAW_CXX_TARGET_EXPORTS,
	NORMAL_TARGET_EXPORTS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS and CXXFLAGS to
	XGCC_FLAGS_FOR_TARGET.  Add it along with TFLAGS to CC, CXX, GCJ,
	and GFORTRAN.
	(TFLAGS, STAGE_CFLAGS, STAGE_TFLAGS, STAGE_CONFIGURE_FLAGS): New.
	(_LIBCFLAGS): Renamed to _TFLAGS.
	(do-compare-debug, do-compare3-debug): Drop.
	(CC, GCC_FOR_TARGET, CXX_FOR_TARGET, RAW_CXX_FOR_TARGET,
	GCJ_FOR_TARGET, GFORTRAN_FOR_TARGET): Remove FLAGS_FOR_TARGET.
	(FLAGS_FOR_TARGET, SYSROOT_CFLAGS_FOR_TARGET,
	DEBUG_PREFIX_CFLAGS_FOR_TARGET): Move down.
	(XGCC_FLAGS_FOR_TARGET): New.
	(BASE_FLAGS_TO_PASS): Pass STAGEid_CFLAGS, STAGEid_TFLAGS and TFLAGS.
	(EXTRA_HOST_FLAGS): Pass GCJ and GFORTRAN.
	(POSTSTAGE1_FLAGS_TO_PASS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS, CXXFLAGS, LIBCFLAGS,
	LIBCXXFLAGS to XGCC_FLAGS_FOR_TARGET.    Add it along with TFLAGS
	to CC, CXX, GCJ, and GFORTRAN.  Pass XGCC_FLAGS_FOR_TARGET and
	TFLAGS.
	(BUILD_CONFIG): Include if requested.
	(all): Set TFLAGS on bootstrap.
	(configure-stageid-prefixmodule): Pass TFLAGS, adjust FLAGS.
	(all-stageid-prefixmodule): Likewise.
	(do-clean, distclean-stageid): Set TFLAGS.
	(restrap): Fix whitespace.
	(bootstrap4-debug): Drop.
	* Makefile.in: Rebuilt.
	* config/mt-gnu (CXXFLAGS_FOR_TARGET): Adjust.
	* config/bootstrap-O1.mk: New.
	* config/bootstrap-O3.mk: New.
	* config/bootstrap-time.mk: New.
	* config/bootstrap-debug.mk: New.
	* config/bootstrap-debug-ckovw.mk: New.
	* config/bootstrap-debug-lib.mk: New.
	* libjava/configure.ac: Insert libgcjdir in the GCJ passed in the
	environment, rather than overriding completely.
	* libjava/configure: Rebuilt.

for gcc/java/ChangeLog.vta
from Alexandre Oliva  <aoliva@redhat.com>

	* Make-lang.in (GCJ): Renamed to...
	(XGCJ): ... this.

Index: Makefile.def
===================================================================
--- Makefile.def.orig	2008-10-03 15:38:23.000000000 -0300
+++ Makefile.def	2008-10-07 05:02:35.000000000 -0300
@@ -236,12 +236,8 @@ flags_to_pass = { flag= CXXFLAGS ; };
 flags_to_pass = { flag= LDFLAGS ; };
 flags_to_pass = { flag= LIBCFLAGS ; };
 flags_to_pass = { flag= LIBCXXFLAGS ; };
-flags_to_pass = { flag= STAGE1_CFLAGS ; };
 flags_to_pass = { flag= STAGE1_CHECKING ; };
 flags_to_pass = { flag= STAGE1_LANGUAGES ; };
-flags_to_pass = { flag= STAGE2_CFLAGS ; };
-flags_to_pass = { flag= STAGE3_CFLAGS ; };
-flags_to_pass = { flag= STAGE4_CFLAGS ; };
 flags_to_pass = { flag= GNATBIND ; };
 flags_to_pass = { flag= GNATMAKE ; };
 
@@ -254,6 +250,7 @@ flags_to_pass = { flag= CPPFLAGS_FOR_TAR
 flags_to_pass = { flag= CXX_FOR_TARGET ; };
 flags_to_pass = { flag= CXXFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= DLLTOOL_FOR_TARGET ; };
+flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= GCJ_FOR_TARGET ; };
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
@@ -269,6 +266,7 @@ flags_to_pass = { flag= WINDRES_FOR_TARG
 flags_to_pass = { flag= WINDMC_FOR_TARGET ; };
 
 // Miscellaneous
+flags_to_pass = { flag= BUILD_CONFIG ; };
 flags_to_pass = { flag= LANGUAGES ; optional=true ; };
 flags_to_pass = { flag= LEAN ; };
 
@@ -511,69 +509,21 @@ dependencies = { module=all-target-winsu
 dependencies = { module=all-target-winsup; on=all-target-libtermcap; };
 
 // Toplevel bootstrap
-bootstrap_stage = {
-	id=1 ;
-
-	// * We force-disable intermodule optimizations, even if
-	//   --enable-intermodule was passed, since the installed compiler
-	//   probably can't handle them.  Luckily, autoconf always respects
-	//   the last argument when conflicting --enable arguments are passed.
-	// * Likewise, we force-disable coverage flags, since the installed
-	//   compiler probably has never heard of them.
-	stage_configure_flags='--disable-intermodule $(STAGE1_CHECKING) \
-	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"' ;
-	stage_cflags='$(STAGE1_CFLAGS)' ;
-	stage_libcflags='$(STAGE1_LIBCFLAGS)' ; };
+bootstrap_stage = { id=1 ; };
 bootstrap_stage = {
 	id=2 ; prev=1 ;
-	bootstrap_target=bootstrap2 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE2_CFLAGS)" ;
-	stage_libcflags="$(STAGE2_LIBCFLAGS)" ; };
-bootstrap_stage = {
-	id=b2g0 ; prev=1 ;
-	bootstrap_target=bootstrap2-debug ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE2_CFLAGS) -g0" ;
-	stage_libcflags="$(STAGE2_LIBCFLAGS) -g0" ; };
+	bootstrap_target=bootstrap2 ; };
 bootstrap_stage = {
 	id=3 ; prev=2 ; lean=1 ;
 	compare_target=compare ;
 	bootstrap_target=bootstrap ;
-	cleanstrap_target=cleanstrap ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE3_CFLAGS)" ;
-	stage_libcflags="$(STAGE3_LIBCFLAGS)" ; };
-bootstrap_stage = {
-	id=b3g2 ; prev=b2g0 ; lean=1 ;
-	compare_target=compare-debug ;
-	bootstrap_target=bootstrap-debug ;
-	cleanstrap_target=cleanstrap-debug ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE3_CFLAGS) -g2" ;
-	stage_libcflags="$(STAGE3_LIBCFLAGS) -g2" ; };
+	cleanstrap_target=cleanstrap ; };
 bootstrap_stage = {
 	id=4 ; prev=3 ; lean=2 ;
 	compare_target=compare3 ;
-	bootstrap_target=bootstrap4 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE4_CFLAGS)" ;
-	stage_libcflags="$(STAGE4_CFLAGS)" ; };
-bootstrap_stage = {
-	id=b4g ; prev=b3g2 ; lean=2 ;
-	compare_target=compare3-debug ;
-	bootstrap_target=bootstrap4-debug ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE4_CFLAGS) -g2" ;
-	stage_libcflags="$(STAGE4_LIBCFLAGS) -g2" ; };
+	bootstrap_target=bootstrap4 ; };
 bootstrap_stage = {
-	id=profile ; prev=1 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags='$(STAGE2_CFLAGS) -fprofile-generate' ;
-	stage_libcflags='$(STAGE2_LIBCFLAGS)' ; };
+	id=profile ; prev=1 ; };
 bootstrap_stage = {
 	id=feedback ; prev=profile ;
-	bootstrap_target=profiledbootstrap ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags='$(STAGE3_CFLAGS) -fprofile-use' ;
-	stage_libcflags='$(STAGE3_LIBCFLAGS) -fprofile-use' ; };
+	bootstrap_target=profiledbootstrap ; };
Index: Makefile.tpl
===================================================================
--- Makefile.tpl.orig	2008-10-03 15:38:23.000000000 -0300
+++ Makefile.tpl	2008-10-07 05:02:35.000000000 -0300
@@ -6,7 +6,8 @@ in
 #
 # Makefile for directory with subdirs to build.
 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
+#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -171,6 +172,8 @@ HOST_EXPORTS = \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
 	CXX="$(CXX)"; export CXX; \
 	CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
+	GCJ="$(GCJ)"; export GCJ; \
+	GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
 	AR="$(AR)"; export AR; \
 	AS="$(AS)"; export AS; \
 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
@@ -202,11 +205,9 @@ HOST_EXPORTS = \
 POSTSTAGE1_HOST_EXPORTS = \
 	$(HOST_EXPORTS) \
 	CC="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
-	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
-	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) \
-	  $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
-	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ \
-	  -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \
+	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ \
+	  $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+	CC_FOR_BUILD="$$CC"; export CC_FOR_BUILD; \
 	LDFLAGS="$(BOOT_LDFLAGS)"; export LDFLAGS;
 
 # Target libraries are put under this directory:
@@ -220,13 +221,13 @@ BASE_TARGET_EXPORTS = \
 	$(BASE_EXPORTS) \
 	AR="$(AR_FOR_TARGET)"; export AR; \
 	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
-	CC="$(CC_FOR_TARGET)"; export CC; \
-	CFLAGS="$(CFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
 	CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
-	CXXFLAGS="$(CXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CXXFLAGS; \
-	GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
-	GFORTRAN="$(GFORTRAN_FOR_TARGET)"; export GFORTRAN; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	GCJ="$(GCJ_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GCJ; \
+	GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
 	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
@@ -242,11 +243,11 @@ BASE_TARGET_EXPORTS = \
 RAW_CXX_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
 	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
-	CXX="$(RAW_CXX_FOR_TARGET)"; export CXX;
+	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
 
 NORMAL_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
-	CXX="$(CXX_FOR_TARGET)"; export CXX;
+	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
 
 # Where to find GMP
 HOST_GMPLIBS = @gmplibs@
@@ -337,49 +338,65 @@ LIBCFLAGS = $(CFLAGS)
 CXXFLAGS = @CXXFLAGS@
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 
+TFLAGS =
+
+# Defaults for all stages; some are overridden below.
+
+STAGE_CFLAGS = $(BOOT_CFLAGS)
+STAGE_TFLAGS = $(TFLAGS)
+STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
+
+[+ FOR bootstrap-stage +]
+# Defaults for stage [+id+]; some are overridden below.
+STAGE[+id+]_CFLAGS = $(STAGE_CFLAGS)
+STAGE[+id+]_TFLAGS = $(STAGE_TFLAGS)
+STAGE[+id+]_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
+[+ ENDFOR bootstrap-stage +]
+
 # Only build the C compiler for stage1, because that is the only one that
 # we can guarantee will build with the native compiler, and also it is the
 # only thing useful for building stage2. STAGE1_CFLAGS (via CFLAGS),
 # MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
 # overrideable (for a bootstrap build stage1 also builds gcc.info).
 
+STAGE1_CFLAGS = @stage1_cflags@
 STAGE1_CHECKING=@stage1_checking@
 STAGE1_LANGUAGES=@stage1_languages@
+# * We force-disable intermodule optimizations, even if
+#   --enable-intermodule was passed, since the installed compiler
+#   probably can't handle them.  Luckily, autoconf always respects
+#   the last argument when conflicting --enable arguments are passed.
+# * Likewise, we force-disable coverage flags, since the installed
+#   compiler probably has never heard of them.
+STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
+	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
+
+STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
+STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
 
-STAGE1_CFLAGS=@stage1_cflags@
-STAGE2_CFLAGS=$(BOOT_CFLAGS)
-STAGE3_CFLAGS=$(BOOT_CFLAGS)
-STAGE4_CFLAGS=$(BOOT_CFLAGS)
-
-STAGE1_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE2_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE3_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE4_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
+STAGEfeedback_CFLAGS = $(STAGE3_CFLAGS) -fprofile-use
+STAGEfeedback_TFLAGS = $(STAGE3_TFLAGS)
 
 do-compare = @do_compare@
 do-compare3 = $(do-compare)
-do-compare-debug = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
-do-compare3-debug = $(do-compare-debug)
 
 # -----------------------------------------------
 # Programs producing files for the TARGET machine
 # -----------------------------------------------
 
-FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
-
 AR_FOR_TARGET=@AR_FOR_TARGET@
 AS_FOR_TARGET=@AS_FOR_TARGET@
-CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
+CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@
 
 # If GCC_FOR_TARGET is not overriden on the command line, then this
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ $(FLAGS_FOR_TARGET)
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@
+CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@
+RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@
+GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@
+GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
 LD_FOR_TARGET=@LD_FOR_TARGET@
 
@@ -397,13 +414,17 @@ COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_
 
 CFLAGS_FOR_TARGET = @CFLAGS_FOR_TARGET@
 CXXFLAGS_FOR_TARGET = @CXXFLAGS_FOR_TARGET@
-SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
-DEBUG_PREFIX_CFLAGS_FOR_TARGET = @DEBUG_PREFIX_CFLAGS_FOR_TARGET@
 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
 LDFLAGS_FOR_TARGET = 
 
+FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+DEBUG_PREFIX_CFLAGS_FOR_TARGET = @DEBUG_PREFIX_CFLAGS_FOR_TARGET@
+
+XGCC_FLAGS_FOR_TARGET = $(FLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
+
 # ------------------------------------
 # Miscellaneous targets and flag lists
 # ------------------------------------
@@ -453,7 +474,10 @@ HOST_LIB_PATH_[+module+] = \
 # Flags to pass down to all sub-makes.
 BASE_FLAGS_TO_PASS =[+ FOR flags_to_pass +][+ IF optional +] \
 	"`echo '[+flag+]=$([+flag+])' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"[+ ELSE optional +] \
-	"[+flag+]=$([+flag+])"[+ ENDIF optional+][+ ENDFOR flags_to_pass +] \
+	"[+flag+]=$([+flag+])"[+ ENDIF optional+][+ ENDFOR flags_to_pass +][+ FOR bootstrap-stage +] \
+	"STAGE[+id+]_CFLAGS=$(STAGE[+id+]_CFLAGS)" \
+	"STAGE[+id+]_TFLAGS=$(STAGE[+id+]_TFLAGS)"[+ ENDFOR bootstrap-stage +] \
+	"TFLAGS=$(TFLAGS)" \
 	"CONFIG_SHELL=$(SHELL)" \
 	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 
 
@@ -468,6 +492,8 @@ EXTRA_HOST_FLAGS = \
 	'CC=$(CC)' \
 	'CXX=$(CXX)' \
 	'DLLTOOL=$(DLLTOOL)' \
+	'GCJ=$(GCJ)' \
+	'GFORTRAN=$(GFORTRAN)' \
 	'LD=$(LD)' \
 	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
@@ -507,20 +533,24 @@ POSTSTAGE1_FLAGS_TO_PASS = \
 EXTRA_TARGET_FLAGS = \
 	'AR=$$(AR_FOR_TARGET)' \
 	'AS=$(COMPILER_AS_FOR_TARGET)' \
-	'CC=$$(CC_FOR_TARGET)' \
-	'CFLAGS=$$(CFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
-	'CXX=$$(CXX_FOR_TARGET)' \
-	'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
+	'CC=$$(CC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
+	'CXX=$$(CXX_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
 	'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
+	'GCJ=$$(GCJ_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'GFORTRAN=$$(GFORTRAN_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
 	'LD=$(COMPILER_LD_FOR_TARGET)' \
 	'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
-	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
-	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
+	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
+	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
-	'WINDMC=$$(WINDMC_FOR_TARGET)'
+	'WINDMC=$$(WINDMC_FOR_TARGET)' \
+	'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \
+	"TFLAGS=$$TFLAGS"
 
 TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
 
@@ -540,6 +570,13 @@ EXTRA_GCC_FLAGS = \
 
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
+@if gcc
+BUILD_CONFIG =
+ifneq ($(BUILD_CONFIG),)
+include $(foreach CONFIG, $(BUILD_CONFIG), $(srcdir)/config/$(CONFIG).mk)
+endif
+@endif gcc
+
 .PHONY: configure-host
 configure-host: [+
   FOR host_modules +] \
@@ -563,11 +600,17 @@ all:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	if [ -f stage_last ]; then \
+@if gcc-bootstrap
+	if [ -f stage_last ]; then : ; \
+	  TFLAGS="$(STAGE$(shell sed s,^stage,, stage_last)_TFLAGS)"; \
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
+@endif gcc-bootstrap
 	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target; \
-	fi
+@if gcc-bootstrap
+	fi; \
+@endif gcc-bootstrap
+	:
 
 .PHONY: all-build
 [+ FOR build_modules +]
@@ -848,6 +891,7 @@ configure-stage[+id+]-[+prefix+][+module
 	@$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+]
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	[+ IF check_multilibs
 	+]echo "Checking multilib configuration for [+module+]..."; \
 	$(CC_FOR_TARGET) --print-multi-lib > [+subdir+]/[+module+]/multilib.tmp 2> /dev/null ; \
@@ -863,11 +907,14 @@ configure-stage[+id+]-[+prefix+][+module
 	fi; \
 	[+ ENDIF check_multilibs +]test ! -f [+subdir+]/[+module+]/Makefile || exit 0; \
 	[+exports+][+ IF prev +] \
-	[+poststage1_exports+][+ ENDIF prev +] [+ IF prefix +] \
-	CFLAGS="[+stage_libcflags+] $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CFLAGS; \
-	CXXFLAGS="[+stage_libcflags+] $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CXXFLAGS; [+ ELSE +] \
-	CFLAGS="[+stage_cflags+]"; export CFLAGS; \
-	CXXFLAGS="[+stage_cflags+]"; export CXXFLAGS; [+ ENDIF +] \
+	[+poststage1_exports+][+ ENDIF prev +][+ IF prefix +] \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;[+ ELSE prefix +] \
+	CFLAGS="$(STAGE[+id+]_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE[+id+]_CFLAGS)"; export CXXFLAGS;[+ IF prev +] \
+	LIBCFLAGS="$(STAGE[+id+]_CFLAGS)"[+ ELSE prev +] \
+	LIBCFLAGS="$(LIBCFLAGS)"[+ ENDIF prev +]; export LIBCFLAGS;[+ ENDIF prefix +] \
 	echo Configuring stage [+id+] in [+subdir+]/[+module+] ; \
 	$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
 	cd [+subdir+]/[+module+] || exit 1; \
@@ -880,9 +927,10 @@ configure-stage[+id+]-[+prefix+][+module
 	libsrcdir="$$s/[+module+]"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  [+args+] --build=${build_alias} --host=[+host_alias+] \
-	  --target=[+target_alias+] $${srcdiroption} \
-	  [+ IF prev +]--with-build-libsubdir=$(HOST_SUBDIR)[+ ENDIF prev +] \
-	  [+stage_configure_flags+] [+extra_configure_flags+]
+	  --target=[+target_alias+] $${srcdiroption} [+ IF prev +]\
+	  --with-build-libsubdir=$(HOST_SUBDIR) [+ ENDIF prev +]\
+	  $(STAGE[+id+]_CONFIGURE_FLAGS)[+ IF extra_configure_flags +] \
+	  [+extra_configure_flags+][+ ENDIF extra_configure_flags +]
 @endif [+prefix+][+module+]-bootstrap
 [+ ENDFOR bootstrap_stage +]
 [+ ENDIF bootstrap +]
@@ -922,16 +970,25 @@ all-stage[+id+]-[+prefix+][+module+]: co
 	@[ $(current_stage) = stage[+id+] ] || $(MAKE) stage[+id+]-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	[+exports+][+ IF prev +] \
 	[+poststage1_exports+][+ ENDIF prev +] \
 	cd [+subdir+]/[+module+] && \
-	$(MAKE) $(BASE_FLAGS_TO_PASS) \
-		CFLAGS="[+stage_cflags+]" CXXFLAGS="[+stage_cflags+]" \
-		LIBCFLAGS="[+stage_libcflags+]" \
-		CFLAGS_FOR_TARGET="[+stage_libcflags+]" \
-		CXXFLAGS_FOR_TARGET="[+stage_libcflags+]" [+args+] [+
+	$(MAKE) $(BASE_FLAGS_TO_PASS)[+ IF prefix +] \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"[+ ELSE prefix +] \
+		CFLAGS="$(STAGE[+id+]_CFLAGS)" \
+		CXXFLAGS="$(STAGE[+id+]_CFLAGS)"[+ IF prev +] \
+		LIBCFLAGS="$(STAGE[+id+]_CFLAGS)"[+ ELSE prev +] \
+		LIBCFLAGS="$(LIBCFLAGS)"[+ ENDIF prev +][+ ENDIF prefix +] \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		[+args+] [+
 		IF prev +][+poststage1_args+][+ ENDIF prev
 		+] [+extra_make_flags+] \
+		TFLAGS="$(STAGE[+id+]_TFLAGS)" \
 		$(TARGET-stage[+id+]-[+prefix+][+module+])
 
 maybe-clean-stage[+id+]-[+prefix+][+module+]: clean-stage[+id+]-[+prefix+][+module+]
@@ -1394,6 +1451,7 @@ do-clean: clean-stage[+id+]
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 
 [+bootstrap-target+]-lean:
@@ -1404,6 +1462,7 @@ do-clean: clean-stage[+id+]
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 [+ ENDIF bootstrap-target +]
 
@@ -1426,6 +1485,7 @@ distclean-stage[+id+]::
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 [+ ENDIF cleanstrap-target +]
 @endif gcc-bootstrap
@@ -1461,8 +1521,8 @@ stage_current:
 .PHONY: restrap
 restrap::
 	@: $(MAKE); $(stage)
-	rm -rf stage1-$(TARGET_SUBDIR) [+ FOR bootstrap-stage +][+ IF prev
-	  +]stage[+id+]-* [+ ENDIF prev +][+ ENDFOR bootstrap-stage +]
+	rm -rf stage1-$(TARGET_SUBDIR)[+ FOR bootstrap-stage +][+ IF prev
+	  +] stage[+id+]-*[+ ENDIF prev +][+ ENDFOR bootstrap-stage +]
 restrap:: all
 @endif gcc-bootstrap
 
@@ -1629,53 +1689,6 @@ configure-gdb: $(CONFIGURE_GDB_TK)
 all-gdb: $(gdbnlmrequirements) $(GDB_TK)
 install-gdb: $(INSTALL_GDB_TK)
 
-@if gcc-bootstrap
-bootstrap4-debug-init = stgsrc=stageb3g2 stgdst=stageb4g
-bootstrap4-debug-lib-gcc-clean = stamp-gnatlib* stamp-tools ada/rts
-
-cp-lR = cp -lR
-
-.PHONY: prepare-bootstrap4-debug-lib
-prepare-bootstrap4-debug-lib:
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	: $(MAKE); $(stage); \
-	$(bootstrap4-debug-init) didgcc=false; \
-	for d3 in $$stgsrc-*; do \
-	  case $$d3 in "$$stgsrc-$(TARGET_SUBDIR)") continue ;; esac; \
-	  d4=`echo $$d3 | sed s,^$$stgsrc,$$stgdst,`; \
-	  if test -d $$d4; then \
-	    echo $$d4 already set up, skipping...; \
-	    continue; \
-	  fi; \
-	  d4t=$$d4.tmp; \
-	  rm -rf $$d4t || :; \
-	  $(cp-lR) $$d3/. $$d4t; \
-	  case $$d3 in "$$stgsrc-gcc") \
-	    (cd $$d4t && rm -rf $(bootstrap4-debug-lib-gcc-clean)) || :;; \
-	  esac; \
-	  mv $$d4t $$d4; \
-	done
-
-.PHONY: clean-bootstrap4-debug-lib
-clean-bootstrap4-debug-lib: prepare-bootstrap4-debug-lib
-	@$(bootstrap4-debug-init); \
-	rm -rf $$stgdst-$(TARGET_SUBDIR) || :; \
-	(cd $$stgdst-gcc && rm -rf $(bootstrap4-debug-lib-gcc-clean)) || :
-
-sed-script-prepare-bootstrap4-debug-lib-g0 = 's,%{g\*},,'
-sed-script-prepare-bootstrap4-debug-lib-novta = 's,%{g\*},& %{!fvar-tracking-assignments:%{!fno-var-tracking-assignments:-fno-var-tracking-assignments}},'
-sed-script-prepare-bootstrap4-debug-lib-custom = 's,x,x,'
-
-.PHONY: prepare-bootstrap4-debug-lib-g0 prepare-bootstrap4-debug-lib-novta prepare-bootstrap4-debug-lib-custom
-prepare-bootstrap4-debug-lib-g0 prepare-bootstrap4-debug-lib-novta \
-prepare-bootstrap4-debug-lib-custom: prepare-bootstrap4-debug-lib
-	@$(bootstrap4-debug-init); \
-	rm -f $$stgdst-gcc/specs; \
-	sed $(sed-script-$@) < $$stgsrc-gcc/specs > $$stgdst-gcc/specs
-
-@endif gcc-bootstrap
-
 # Serialization dependencies.  Host configures don't work well in parallel to
 # each other, due to contention over config.cache.  Target configures and 
 # build configures are similar.
Index: config/mt-gnu
===================================================================
--- config/mt-gnu.orig	2008-10-03 15:38:23.000000000 -0300
+++ config/mt-gnu	2008-10-07 05:02:35.000000000 -0300
@@ -1,2 +1 @@
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET) \
-	$(DEBUG_PREFIX_CFLAGS_FOR_TARGET) -D_GNU_SOURCE
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE
Index: config/bootstrap-O1.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-O1.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1 @@
+BOOT_CFLAGS := -O1 $(filter-out -O%, $(BOOT_CFLAGS))
Index: config/bootstrap-O3.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-O3.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1 @@
+BOOT_CFLAGS := -O3 $(filter-out -O%, $(BOOT_CFLAGS))
Index: config/bootstrap-time.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-time.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1,2 @@
+BOOT_CFLAGS += -time=$(shell pwd)/time.log
+TFLAGS += -time=$(shell pwd)/time.log
Index: config/bootstrap-debug.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1,2 @@
+STAGE2_CFLAGS += -gtoggle
+do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: config/bootstrap-debug-ckovw.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug-ckovw.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1,12 @@
+# These arrange for a simple warning to be issued if -fcompare-debug
+# is not given.
+# BOOT_CFLAGS += -fcompare-debug="-w%n-fcompare-debug not overridden"
+# TFLAGS += -fcompare-debug="-w%n-fcompare-debug not overridden"
+
+# GCC_COMPARE_DEBUG="-w%n-fcompare-debug not overridden";
+
+FORCE_COMPARE_DEBUG = \
+	GCC_COMPARE_DEBUG=$${GCC_COMPARE_DEBUG--fcompare-debug-not-overridden}; \
+	export GCC_COMPARE_DEBUG;
+POSTSTAGE1_HOST_EXPORTS += $(FORCE_COMPARE_DEBUG)
+BASE_TARGET_EXPORTS += $(FORCE_COMPARE_DEBUG)
Index: config/bootstrap-debug-lib.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug-lib.mk	2008-10-07 05:02:35.000000000 -0300
@@ -0,0 +1,12 @@
+# Stage1 compiler may not support this flag.
+# STAGE1_CFLAGS += -fcompare-debug=-gtoggle
+STAGE2_CFLAGS += -gtoggle -fcompare-debug=
+STAGE3_CFLAGS += -fcompare-debug=-gtoggle
+STAGE4_CFLAGS += -fcompare-debug=-fvar-tracking-assignments-toggle
+# This might be enough after testing:
+# TFLAGS += -fcompare-debug=-g0
+STAGE1_TFLAGS += -gtoggle -fcompare-debug=
+STAGE2_TFLAGS += -fcompare-debug=-fvar-tracking-assignments-toggle
+STAGE3_TFLAGS += -fcompare-debug=-gtoggle
+STAGE4_TFLAGS += -fcompare-debug=-fvar-tracking-assignments-toggle
+do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac.orig	2008-10-03 15:38:23.000000000 -0300
+++ libjava/configure.ac	2008-10-07 05:02:35.000000000 -0300
@@ -352,23 +352,30 @@ else
      which_gcj=path
   fi
 fi
+libgcjdir=`${PWDCMD-pwd}`
+case $libgcjdir in
+*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
+esac
+case $GCJ in
+*" -B"*)
+  GCJ=`echo "$GCJ" | sed "s, -B, -B$libgcjdir/&,"`
+  ;;
+*)
+  GCJ=$GCJ" -B$libgcjdir/"
+  ;;
+esac
 case "${which_gcj}" in
    built)
-      GCJ="$built_gcc_dir/gcj -B`${PWDCMD-pwd}`/ -B$built_gcc_dir/"
       GCJH='$(top_builddir)/$(MULTIBUILDTOP)../../$(host_subdir)/gcc/gcjh'
    ;;
    cross)
       if test "x${with_newlib}" = "xyes"; then
          # FIXME (comment): Why is this needed?
          GCC_UNWIND_INCLUDE=
-         GCJ="${target_noncanonical}-gcj"
-      else
-         GCJ="${target_noncanonical}-gcj -B`${PWDCMD-pwd}`/"
       fi
       GCJH='$(target_noncanonical)-gcjh'
    ;;
    path)
-      GCJ="gcj -B`${PWDCMD-pwd}`/"
       GCJH=gcjh
    ;;
 esac
Index: gcc/java/Make-lang.in
===================================================================
--- gcc/java/Make-lang.in.orig	2008-10-03 15:38:23.000000000 -0300
+++ gcc/java/Make-lang.in	2008-10-07 05:02:36.000000000 -0300
@@ -44,10 +44,10 @@
 JAVA_INSTALL_NAME := $(shell echo gcj|sed '$(program_transform_name)')
 JAVA_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcj|sed '$(program_transform_name)')
 
-GCJ = gcj
+XGCJ = gcj
 
 # Define the names for selecting java in LANGUAGES.
-java: jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) jcf-dump$(exeext)
+java: jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) jcf-dump$(exeext)
 
 # Define the name of target independent tools to be installed in $(bindir)
 # Names are subject to changes
@@ -62,17 +62,17 @@ jvspec.o: $(srcdir)/java/jvspec.c $(SYST
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
 		$(INCLUDES) $(srcdir)/java/jvspec.c $(OUTPUT_OPTION))
 
-# Create the compiler driver for $(GCJ).
-$(GCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \
+# Create the compiler driver for $(XGCJ).
+$(XGCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \
 	   prefix.o intl.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) jvspec.o \
 	  java/jcf-path.o prefix.o intl.o \
 	  version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
-# Create a version of the $(GCJ) driver which calls the cross-compiler.
-$(GCJ)-cross$(exeext): $(GCJ)$(exeext)
-	-rm -f $(GCJ)-cross$(exeext)
-	cp $(GCJ)$(exeext) $(GCJ)-cross$(exeext)
+# Create a version of the $(XGCJ) driver which calls the cross-compiler.
+$(XGCJ)-cross$(exeext): $(XGCJ)$(exeext)
+	-rm -f $(XGCJ)-cross$(exeext)
+	cp $(XGCJ)$(exeext) $(XGCJ)-cross$(exeext)
 
 java.srcextra:
 
@@ -115,8 +115,8 @@ jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(
 #\f
 # Build hooks:
 
-java.all.cross: $(GCJ)-cross$(exeext)
-java.start.encap: $(GCJ)$(exeext)
+java.all.cross: $(XGCJ)-cross$(exeext)
+java.start.encap: $(XGCJ)$(exeext)
 java.rest.encap:
 
 
@@ -157,11 +157,11 @@ check-java :
 
 # Install gcj as well as the target-independent tools.
 java.install-common: installdirs
-	-if [ -f $(GCJ)$(exeext) ]; then \
+	-if [ -f $(XGCJ)$(exeext) ]; then \
 	  rm -f $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
-	  $(INSTALL_PROGRAM) $(GCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
+	  $(INSTALL_PROGRAM) $(XGCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
 	  chmod a+x $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
-	  if [ -f $(GCJ)-cross$(exeext) ]; then \
+	  if [ -f $(XGCJ)-cross$(exeext) ]; then \
 	    true; \
 	  else \
 	    rm -f $(DESTDIR)$(bindir)/$(JAVA_TARGET_INSTALL_NAME)$(exeext); \
@@ -210,7 +210,7 @@ java.install-pdf: $(JAVA_PDFFILES)
 java.mostlyclean:
 	-rm -f java/*$(objext) $(DEMANGLER_PROG)
 	-rm -f java/*$(coverageexts)
-	-rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) \
+	-rm -f jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) \
           jcf-dump$(exeext) s-java
 java.clean:
 java.distclean:

[-- Attachment #3: Type: text/plain, Size: 257 bytes --]


-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member       ¡Sé Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix  LIBCFLAGS uses
  2008-10-07  8:31 [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses Alexandre Oliva
@ 2008-10-07  8:41 ` Ralf Wildenhues
  2008-10-07  9:01   ` Andreas Schwab
  2008-10-07 18:09   ` Alexandre Oliva
  2008-10-07  9:41 ` Paolo Bonzini
  2008-10-08  2:27 ` Adam Nemet
  2 siblings, 2 replies; 9+ messages in thread
From: Ralf Wildenhues @ 2008-10-07  8:41 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches

Hello Alexandre,

a couple of nits, if I may.

* Alexandre Oliva wrote on Tue, Oct 07, 2008 at 10:16:45AM CEST:

> for ChangeLog.vta
> from  Alexandre Oliva  <aoliva@redhat.com>
[...]
> 	* libjava/configure.ac: Insert libgcjdir in the GCJ passed in the
> 	environment, rather than overriding completely.
> 	* libjava/configure: Rebuilt.

Not in a separate ChangeLog file?

> --- libjava/configure.ac.orig	2008-10-03 15:38:23.000000000 -0300
> +++ libjava/configure.ac	2008-10-07 05:02:35.000000000 -0300
> @@ -352,23 +352,30 @@ else
>       which_gcj=path
>    fi
>  fi
> +libgcjdir=`${PWDCMD-pwd}`
> +case $libgcjdir in
> +*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
> +esac

Why was this escaping added?  It looks wrong.  At least if it's supposed
to fix some missing escaping inside config.status then that's the wrong
way to go.

> +case $GCJ in
> +*" -B"*)
> +  GCJ=`echo "$GCJ" | sed "s, -B, -B$libgcjdir/&,"`
> +  ;;
> +*)
> +  GCJ=$GCJ" -B$libgcjdir/"
> +  ;;
> +esac

Cheers,
Ralf

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix  LIBCFLAGS uses
  2008-10-07  8:41 ` Ralf Wildenhues
@ 2008-10-07  9:01   ` Andreas Schwab
  2008-10-07 18:09   ` Alexandre Oliva
  1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2008-10-07  9:01 UTC (permalink / raw)
  To: Ralf Wildenhues; +Cc: Alexandre Oliva, gcc-patches

Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:

>> --- libjava/configure.ac.orig	2008-10-03 15:38:23.000000000 -0300
>> +++ libjava/configure.ac	2008-10-07 05:02:35.000000000 -0300
>> @@ -352,23 +352,30 @@ else
>>       which_gcj=path
>>    fi
>>  fi
>> +libgcjdir=`${PWDCMD-pwd}`
>> +case $libgcjdir in
>> +*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
>> +esac
>
> Why was this escaping added?  It looks wrong.  At least if it's supposed
> to fix some missing escaping inside config.status then that's the wrong
> way to go.

It's a no-op anyway.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS  uses
  2008-10-07  8:31 [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses Alexandre Oliva
  2008-10-07  8:41 ` Ralf Wildenhues
@ 2008-10-07  9:41 ` Paolo Bonzini
  2009-05-12  5:48   ` Alexandre Oliva
  2008-10-08  2:27 ` Adam Nemet
  2 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2008-10-07  9:41 UTC (permalink / raw)
  To: gcc-patches

Alexandre Oliva wrote:
> This patch introduces support for BUILD_CONFIG, a Makefile macro that,
> if set to say "a b", will cause config/a.mk and config/b.mk to be
> included in the top-level Makefile.  The plan was to use this to add
> -fcompare-debug to certain variables, and eventually add a configure
> option to set a default (non-empty) value for BUILD_CONFIG.

I like it.  Please merge it into trunk when 4.5 stage1 starts.

Paolo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix  LIBCFLAGS uses
  2008-10-07  8:41 ` Ralf Wildenhues
  2008-10-07  9:01   ` Andreas Schwab
@ 2008-10-07 18:09   ` Alexandre Oliva
  2008-10-10 13:42     ` Alexandre Oliva
  1 sibling, 1 reply; 9+ messages in thread
From: Alexandre Oliva @ 2008-10-07 18:09 UTC (permalink / raw)
  To: Ralf Wildenhues; +Cc: gcc-patches

On Oct  7, 2008, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:

>> for ChangeLog.vta
>> * libjava/configure.ac: Insert libgcjdir in the GCJ passed in the
>> environment, rather than overriding completely.
>> * libjava/configure: Rebuilt.

> Not in a separate ChangeLog file?

Yeah, I was lazy.  There wasn't a libjava/ChangeLog.vta yet, and I
didn't think it was worth it to create one for this change.  For sure
it would be moved to libjava/ChangeLog at merge time.

>> +libgcjdir=`${PWDCMD-pwd}`
>> +case $libgcjdir in
>> +*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
>> +esac

> Why was this escaping added?  It looks wrong.

Because libgcjdir is only used in a 's,,,' sed command a few lines
down, so for safety we need commas in it to be quoted.  Just in case
the user has commas in the build dir.

>> +  GCJ=`echo "$GCJ" | sed "s, -B, -B$libgcjdir/&,"`

Or at least that was the plan.  Now I see it may be used out of sed
commands too:

>> +  GCJ=$GCJ" -B$libgcjdir/"

In this case, the backslashes will probably be harmless, but I guess
it's worth fixing or commenting on.  Will do.  Thanks.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member       ¡Sé Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses
  2008-10-07  8:31 [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses Alexandre Oliva
  2008-10-07  8:41 ` Ralf Wildenhues
  2008-10-07  9:41 ` Paolo Bonzini
@ 2008-10-08  2:27 ` Adam Nemet
  2008-10-10  9:23   ` Alexandre Oliva
  2 siblings, 1 reply; 9+ messages in thread
From: Adam Nemet @ 2008-10-08  2:27 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches

Alexandre Oliva <aoliva@redhat.com> writes:
> Second, I found that LIBCFLAGS was not used consistently.  IMHO, we
> should only use LIBCFLAGS for builds using the pre-installed host
> compiler.  For target builds, we should use LIBCFLAGS_FOR_TARGET, and
> for host builds in in stage2+ I can see that it makes sense to use
> either STAGE_CFLAGS (being the preferred flags for GCC for that stage,
> without any of the magic flags required by the compiler used to build
> stage1) or CFLAGS_FOR_TARGET (being the preferred flags for the GCC
> built in the previous stage).  I chose the former, for simplicity.

This is PR/37137.  Can this part of the fix be merged to trunk now?

I think you also need to update install.texi.  See my WIP patch for the same
issue.

Adam


Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(revision 140955)
+++ Makefile.tpl	(working copy)
@@ -370,7 +370,11 @@ STAGE2_CFLAGS=$(BOOT_CFLAGS)
 STAGE3_CFLAGS=$(BOOT_CFLAGS)
 STAGE4_CFLAGS=$(BOOT_CFLAGS)
 
-STAGE1_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
+# Used during stage1 with host libraries.
+STAGE1_LIBCFLAGS=@stage1_cflags@
+# Used during stage1 with target libraries.
+STAGE1_CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)
+
 STAGE2_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
 STAGE3_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
 STAGE4_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
@@ -945,9 +949,14 @@ all-stage[+id+]-[+prefix+][+module+]: co
 	cd [+subdir+]/[+module+] && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="[+stage_cflags+]" CXXFLAGS="[+stage_cflags+]" \
-		LIBCFLAGS="[+stage_libcflags+]" \
+		LIBCFLAGS="[+stage_libcflags+]"[+
+		IF (= (get "id") "1") +] \
+		CFLAGS_FOR_TARGET="$(STAGE1_CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(STAGE1_CFLAGS_FOR_TARGET)"[+
+		ELSE +] \
 		CFLAGS_FOR_TARGET="[+stage_libcflags+]" \
-		CXXFLAGS_FOR_TARGET="[+stage_libcflags+]" [+args+] [+
+		CXXFLAGS_FOR_TARGET="[+stage_libcflags+]"[+
+		ENDIF +] [+args+] [+
 		IF prev +][+poststage1_args+][+ ENDIF prev
 		+] [+extra_make_flags+] \
 		$(TARGET-stage[+id+]-[+prefix+][+module+])
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 140955)
+++ gcc/doc/install.texi	(working copy)
@@ -1848,7 +1848,7 @@ bootstrapped, you can use @code{CFLAGS_F
 compilation flags, as for non-bootstrapped target libraries.
 Again, if the native compiler miscompiles the stage1 compiler, you may
 need to work around this by avoiding non-working parts of the stage1
-compiler.  Use @code{STAGE1_LIBCFLAGS} to this end.
+compiler.  Use @code{STAGE1_CFLAGS_FOR_TARGET} to this end.
 
 If you used the flag @option{--enable-languages=@dots{}} to restrict
 the compilers to be built, only those you've actually enabled will be

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses
  2008-10-08  2:27 ` Adam Nemet
@ 2008-10-10  9:23   ` Alexandre Oliva
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Oliva @ 2008-10-10  9:23 UTC (permalink / raw)
  To: Adam Nemet; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On Oct  7, 2008, Adam Nemet <anemet@caviumnetworks.com> wrote:

> I think you also need to update install.texi.

Thanks for reminding me, I was indeed missing docs for the newly-added
BUILD_CONFIG as well.  Fixed as follows in the branch.  I also added
it the patch for the trunk I just posted in this thread, although
somewhat shortened, omitting features that are only in the VTA branch.
I also added a reference to bug 37137 to the top-level ChangeLog
entry, and dropped the cut&pasto that referenced bootstrap4-debug in
there.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bootstrap-configs-doc.patch --]
[-- Type: text/x-patch, Size: 3053 bytes --]

for  gcc/ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* doc/install.texi (STAGE1_TFLAGS, BUILD_CONFIG): Document.

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig	2008-07-29 18:13:15.000000000 -0300
+++ gcc/doc/install.texi	2008-10-10 05:04:29.000000000 -0300
@@ -1834,7 +1834,7 @@ bootstrapped, you can use @code{CFLAGS_F
 compilation flags, as for non-bootstrapped target libraries.
 Again, if the native compiler miscompiles the stage1 compiler, you may
 need to work around this by avoiding non-working parts of the stage1
-compiler.  Use @code{STAGE1_LIBCFLAGS} to this end.
+compiler.  Use @code{STAGE1_TFLAGS} to this end.
 
 If you used the flag @option{--enable-languages=@dots{}} to restrict
 the compilers to be built, only those you've actually enabled will be
@@ -1858,6 +1858,50 @@ the one you are building on: for example
 @code{powerpc64-unknown-linux-gnu} host.  In this case, pass
 @option{--enable-bootstrap} to the configure script.
 
+@code{BUILD_CONFIG} can be used to bring in additional customization to
+the build.  It can be set to a whitespace-separated list of names.  For
+each such @code{NAME}, top-level @file{config/@code{NAME}.mk} will be
+included by the top-level @file{Makefile}, bringing in any settings it
+contains.  Some examples are:
+
+@table @asis
+@item @samp{bootstrap-O1}
+Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
+@option{-O1} to it.  @samp{BUILD_CONFIG=bootstrap-O1} is equivalent to
+@samp{BOOT_CFLAGS='-g -O1'}.
+
+@item @samp{bootstrap-O3}
+Analogous to @code{bootstrap-O1}.
+
+@item @samp{bootstrap-debug}
+Builds stage2 without debug information, and uses
+@file{contrib/compare-debug} to compare object files.  If
+@code{BOOT_CFLAGS} is overridden so as to not enable debug information,
+stage2 will have it, and stage3 won't.
+
+@item @samp{bootstrap-debug-lib}
+Toggles debug information generation in stage2, like
+@file{bootstrap-debug}, and enables internal comparison
+(@option{-fcompare-debug}) with and without debug information in stage3,
+and internal comparison with and without variable tracking at
+assignments (VTA) on stage4.  As for libraries, it toggles debug
+information generation for libraries on stage1, enables internal
+comparison with and without VTA on stage2, internal comparison with and
+without debug information in stage3 (all libraries, unlike previous
+stages that only build libgcc), and internal comparison with and without
+VTA on stage4.
+
+@item @samp{bootstrap-debug-ckovw}
+Arranges for error messages to be issued if the compiler built on any
+stage is run without the option @option{-fcompare-debug}.  This is
+useful to verify the full coverage of the @code{bootstrap-debug-lib}
+option.
+
+@item @samp{bootstrap-time}
+Arranges for the run time of each program started by the GCC driver,
+built in any stage, to be logged to @file{time.log}, in the top level of
+the build tree.
+@end table
 
 @section Building a cross compiler
 

[-- Attachment #3: Type: text/plain, Size: 2146 bytes --]


for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR target/37137
	* doc/install.texi (STAGE1_TFLAGS, BUILD_CONFIG): Document.

Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig	2008-10-01 15:43:57.000000000 -0300
+++ gcc/doc/install.texi	2008-10-10 05:08:11.000000000 -0300
@@ -1848,7 +1848,7 @@ bootstrapped, you can use @code{CFLAGS_F
 compilation flags, as for non-bootstrapped target libraries.
 Again, if the native compiler miscompiles the stage1 compiler, you may
 need to work around this by avoiding non-working parts of the stage1
-compiler.  Use @code{STAGE1_LIBCFLAGS} to this end.
+compiler.  Use @code{STAGE1_TFLAGS} to this end.
 
 If you used the flag @option{--enable-languages=@dots{}} to restrict
 the compilers to be built, only those you've actually enabled will be
@@ -1872,6 +1872,24 @@ the one you are building on: for example
 @code{powerpc64-unknown-linux-gnu} host.  In this case, pass
 @option{--enable-bootstrap} to the configure script.
 
+@code{BUILD_CONFIG} can be used to bring in additional customization to
+the build.  It can be set to a whitespace-separated list of names.  For
+each such @code{NAME}, top-level @file{config/@code{NAME}.mk} will be
+included by the top-level @file{Makefile}, bringing in any settings it
+contains.  Some examples are:
+
+@table @asis
+@item @samp{bootstrap-O1}
+Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
+@option{-O1} to it.  @samp{BUILD_CONFIG=bootstrap-O1} is equivalent to
+@samp{BOOT_CFLAGS='-g -O1'}.
+
+@item @samp{bootstrap-O3}
+Analogous to @code{bootstrap-O1}.
+
+@item @samp{bootstrap-debug}
+Builds stage2 without debug information, and uses
+@file{contrib/compare-debug} to compare object files.
 
 @section Building a cross compiler
 


-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member       ¡Sé Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix  LIBCFLAGS uses
  2008-10-07 18:09   ` Alexandre Oliva
@ 2008-10-10 13:42     ` Alexandre Oliva
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Oliva @ 2008-10-10 13:42 UTC (permalink / raw)
  To: Ralf Wildenhues; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

[Re-posting, I'd failed to remove the generated files from the patch
before posting it, so it bounced.  Sorry.]

On Oct  7, 2008, Alexandre Oliva <aoliva@redhat.com> wrote:

>>> +  GCJ=$GCJ" -B$libgcjdir/"

> In this case, the backslashes will probably be harmless, but I guess
> it's worth fixing or commenting on.  Will do.  Thanks.

Here it is, installing the first patch below in the branch.  I found
out reconfiguring didn't work because CXX wasn't set in the
environment any more, so I fixed that as well.

This is feeling more and more like trunk material, given the open bugs
it fixes.  Does anyone think it's a bad idea to install the second
patch below in the trunk?  I guess I could split out the BUILD_CONFIG
part, but that's a small and safe part, useful on its own.

Tested (both) on x86_64-linux-gnu.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bootstrap-configs-fixquotes.patch --]
[-- Type: text/x-patch, Size: 11455 bytes --]

for  ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/multi.m4: Save CXX, GFORTRAN and GCJ in config.status.
	* libjava/configure.ac (libgcjdir): Quoting only for use in sed
	command.  Quote backslashes too.
	* libjava/configure: Rebuilt.

Index: config/multi.m4
===================================================================
--- config/multi.m4.orig	2007-11-23 18:17:05.000000000 -0200
+++ config/multi.m4	2008-10-10 02:14:51.000000000 -0300
@@ -1,5 +1,5 @@
 ##                                                          -*- Autoconf -*-
-# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -62,4 +62,7 @@ with_target_subdir="$with_target_subdir"
 ac_configure_args="${multilib_arg} ${ac_configure_args}"
 multi_basedir="$multi_basedir"
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-CC="$CC"])])dnl
+CC="$CC"
+CXX="$CXX"
+GFORTRAN="$GFORTRAN"
+GCJ="$GCJ"])])dnl
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac.orig	2008-10-07 15:52:05.000000000 -0300
+++ libjava/configure.ac	2008-10-10 01:33:08.000000000 -0300
@@ -353,12 +353,15 @@ else
   fi
 fi
 libgcjdir=`${PWDCMD-pwd}`
-case $libgcjdir in
-*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
-esac
 case $GCJ in
 *" -B"*)
-  GCJ=`echo "$GCJ" | sed "s, -B, -B$libgcjdir/&,"`
+  # Just in case there is a comma in the build dir, quote it for the
+  # sed command below.
+  case $libgcjdir in
+  *[[,\\]]*) qlibgcjdir=`echo "$libgcjdir" | sed 's:[[,\\]]:\\&:g'`;;
+  *) qlibgcjdir=$libgcjdir;;
+  esac
+  GCJ=`echo "$GCJ" | sed "s, -B, -B$qlibgcjdir/&,"`
   ;;
 *)
   GCJ=$GCJ" -B$libgcjdir/"
Index: libjava/configure
===================================================================
--- libjava/configure.orig	2008-10-07 15:52:30.000000000 -0300
+++ libjava/configure	2008-10-10 02:15:04.000000000 -0300
@@ -5380,12 +5380,15 @@ else
   fi
 fi
 libgcjdir=`${PWDCMD-pwd}`
-case $libgcjdir in
-*,*) libgcjdir=`echo "$libgcjdir" | sed 's:,:\\,:g'`;;
-esac
 case $GCJ in
 *" -B"*)
-  GCJ=`echo "$GCJ" | sed "s, -B, -B$libgcjdir/&,"`
+  # Just in case there is a comma in the build dir, quote it for the
+  # sed command below.
+  case $libgcjdir in
+  *[,\\]*) qlibgcjdir=`echo "$libgcjdir" | sed 's:[,\\]:\\&:g'`;;
+  *) qlibgcjdir=$libgcjdir;;
+  esac
+  GCJ=`echo "$GCJ" | sed "s, -B, -B$qlibgcjdir/&,"`
   ;;
 *)
   GCJ=$GCJ" -B$libgcjdir/"
@@ -6028,13 +6031,13 @@ if test "${lt_cv_nm_interface+set}" = se
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:6024: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:6034: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:6027: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:6037: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:6030: output\"" >&5)
+  (eval echo "\"\$as_me:6040: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -7078,7 +7081,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 7074 "configure"' > conftest.$ac_ext
+  echo '#line 7084 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8779,11 +8782,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8775: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8785: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8779: \$? = $ac_status" >&5
+   echo "$as_me:8789: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9101,11 +9104,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9097: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9107: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9101: \$? = $ac_status" >&5
+   echo "$as_me:9111: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9206,11 +9209,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9202: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9212: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9206: \$? = $ac_status" >&5
+   echo "$as_me:9216: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9261,11 +9264,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9257: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9267: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9261: \$? = $ac_status" >&5
+   echo "$as_me:9271: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -12113,7 +12116,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12109 "configure"
+#line 12119 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12213,7 +12216,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12209 "configure"
+#line 12219 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14251,11 +14254,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14247: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14257: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14251: \$? = $ac_status" >&5
+   echo "$as_me:14261: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14350,11 +14353,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14346: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14356: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14350: \$? = $ac_status" >&5
+   echo "$as_me:14360: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -14402,11 +14405,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14398: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14408: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14402: \$? = $ac_status" >&5
+   echo "$as_me:14412: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15790,11 +15793,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15786: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15796: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15790: \$? = $ac_status" >&5
+   echo "$as_me:15800: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16106,11 +16109,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16102: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16112: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16106: \$? = $ac_status" >&5
+   echo "$as_me:16116: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16205,11 +16208,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16201: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16211: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16205: \$? = $ac_status" >&5
+   echo "$as_me:16215: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16257,11 +16260,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16253: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16263: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16257: \$? = $ac_status" >&5
+   echo "$as_me:16267: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -18613,7 +18616,7 @@ if test "${enable_sjlj_exceptions+set}" 
   :
 else
   cat > conftest.$ac_ext << EOF
-#line 18609 "configure"
+#line 18619 "configure"
 struct S { ~S(); };
 void bar();
 void foo()
@@ -28947,6 +28950,9 @@ ac_configure_args="${multilib_arg} ${ac_
 multi_basedir="$multi_basedir"
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
 CC="$CC"
+CXX="$CXX"
+GFORTRAN="$GFORTRAN"
+GCJ="$GCJ"
 AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
 
 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: bootstrap-configs.patch --]
[-- Type: text/x-patch, Size: 30478 bytes --]

for ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR target/37137
	* Makefile.def (flags_to_pass): Remove redundant and incomplete
	STAGE1_CFLAGS, STAGE2_CFLAGS, STAGE3_CFLAGS, and STAGE4_CFLAGS.
	Add FLAGS_FOR_TARGET and BUILD_CONFIG.
	(bootstrap_stage): Remove bootstrap-debug custom stages.  Turn
	stage_configureflags, stage_cflags and stage_libcflags into
	explicit Makefile macros.
	* Makefile.tpl (HOST_EXPORTS, EXTRA_HOST_FLAGS): Pass GCJ and
	GFORTRAN.
	(POSTSTAGE1_HOST_EXPORTS): Add XGCC_FLAGS_FOR_TARGET and TFLAGS to
	CC.  Set CC_FOR_BUILD from CC.
	(BASE_TARGET_EXPORTS, RAW_CXX_TARGET_EXPORTS,
	NORMAL_TARGET_EXPORTS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS and CXXFLAGS to
	XGCC_FLAGS_FOR_TARGET.  Add it along with TFLAGS to CC, CXX, GCJ,
	and GFORTRAN.
	(TFLAGS, STAGE_CFLAGS, STAGE_TFLAGS, STAGE_CONFIGURE_FLAGS): New.
	(_LIBCFLAGS): Renamed to _TFLAGS.
	(do-compare-debug, do-compare3-debug): Drop.
	(CC, GCC_FOR_TARGET, CXX_FOR_TARGET, RAW_CXX_FOR_TARGET,
	GCJ_FOR_TARGET, GFORTRAN_FOR_TARGET): Remove FLAGS_FOR_TARGET.
	(FLAGS_FOR_TARGET, SYSROOT_CFLAGS_FOR_TARGET,
	DEBUG_PREFIX_CFLAGS_FOR_TARGET): Move down.
	(XGCC_FLAGS_FOR_TARGET): New.
	(BASE_FLAGS_TO_PASS): Pass STAGEid_CFLAGS, STAGEid_TFLAGS and TFLAGS.
	(EXTRA_HOST_FLAGS): Pass GCJ and GFORTRAN.
	(POSTSTAGE1_FLAGS_TO_PASS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS, CXXFLAGS, LIBCFLAGS,
	LIBCXXFLAGS to XGCC_FLAGS_FOR_TARGET.    Add it along with TFLAGS
	to CC, CXX, GCJ, and GFORTRAN.  Pass XGCC_FLAGS_FOR_TARGET and
	TFLAGS.
	(BUILD_CONFIG): Include if requested.
	(all): Set TFLAGS on bootstrap.
	(configure-stageid-prefixmodule): Pass TFLAGS, adjust FLAGS.
	(all-stageid-prefixmodule): Likewise.
	(do-clean, distclean-stageid): Set TFLAGS.
	(restrap): Fix whitespace.
	* Makefile.in: Rebuilt.

for config/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* multi.m4: Save CXX, GFORTRAN and GCJ in config.status.
	* mt-gnu (CXXFLAGS_FOR_TARGET): Adjust.
	* bootstrap-O1.mk: New.
	* bootstrap-O3.mk: New.
	* bootstrap-debug.mk: New.

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR target/37137
	* doc/install.texi (STAGE1_TFLAGS, BUILD_CONFIG): Document.

for gcc/java/ChangeLog
from Alexandre Oliva  <aoliva@redhat.com>

	* Make-lang.in (GCJ): Renamed to...
	(XGCJ): ... this.

for libjava/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* configure.ac: Insert libgcjdir in the GCJ passed in the
	environment, rather than overriding completely.
	* configure: Rebuilt.

Index: Makefile.def
===================================================================
--- Makefile.def.orig	2008-10-10 04:04:33.000000000 -0300
+++ Makefile.def	2008-10-10 05:08:10.000000000 -0300
@@ -246,12 +246,8 @@ flags_to_pass = { flag= CXXFLAGS ; };
 flags_to_pass = { flag= LDFLAGS ; };
 flags_to_pass = { flag= LIBCFLAGS ; };
 flags_to_pass = { flag= LIBCXXFLAGS ; };
-flags_to_pass = { flag= STAGE1_CFLAGS ; };
 flags_to_pass = { flag= STAGE1_CHECKING ; };
 flags_to_pass = { flag= STAGE1_LANGUAGES ; };
-flags_to_pass = { flag= STAGE2_CFLAGS ; };
-flags_to_pass = { flag= STAGE3_CFLAGS ; };
-flags_to_pass = { flag= STAGE4_CFLAGS ; };
 flags_to_pass = { flag= GNATBIND ; };
 flags_to_pass = { flag= GNATMAKE ; };
 
@@ -264,6 +260,7 @@ flags_to_pass = { flag= CPPFLAGS_FOR_TAR
 flags_to_pass = { flag= CXX_FOR_TARGET ; };
 flags_to_pass = { flag= CXXFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= DLLTOOL_FOR_TARGET ; };
+flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= GCJ_FOR_TARGET ; };
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
@@ -279,6 +276,7 @@ flags_to_pass = { flag= WINDRES_FOR_TARG
 flags_to_pass = { flag= WINDMC_FOR_TARGET ; };
 
 // Miscellaneous
+flags_to_pass = { flag= BUILD_CONFIG ; };
 flags_to_pass = { flag= LANGUAGES ; optional=true ; };
 flags_to_pass = { flag= LEAN ; };
 
@@ -526,62 +524,21 @@ dependencies = { module=all-target-winsu
 dependencies = { module=all-target-winsup; on=all-target-libtermcap; };
 
 // Toplevel bootstrap
-bootstrap_stage = {
-	id=1 ;
-
-	// * We force-disable intermodule optimizations, even if
-	//   --enable-intermodule was passed, since the installed compiler
-	//   probably can't handle them.  Luckily, autoconf always respects
-	//   the last argument when conflicting --enable arguments are passed.
-	// * Likewise, we force-disable coverage flags, since the installed
-	//   compiler probably has never heard of them.
-	stage_configure_flags='--disable-intermodule $(STAGE1_CHECKING) \
-	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"' ;
-	stage_cflags='$(STAGE1_CFLAGS)' ;
-	stage_libcflags='$(STAGE1_LIBCFLAGS)' ; };
+bootstrap_stage = { id=1 ; };
 bootstrap_stage = {
 	id=2 ; prev=1 ;
-	bootstrap_target=bootstrap2 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE2_CFLAGS)" ;
-	stage_libcflags="$(STAGE2_LIBCFLAGS)" ; };
-bootstrap_stage = {
-	id=b2g0 ; prev=1 ;
-	bootstrap_target=bootstrap2-debug ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE2_CFLAGS) -g0" ;
-	stage_libcflags="$(STAGE2_LIBCFLAGS) -g0" ; };
+	bootstrap_target=bootstrap2 ; };
 bootstrap_stage = {
 	id=3 ; prev=2 ; lean=1 ;
 	compare_target=compare ;
 	bootstrap_target=bootstrap ;
-	cleanstrap_target=cleanstrap ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE3_CFLAGS)" ;
-	stage_libcflags="$(STAGE3_LIBCFLAGS)" ; };
-bootstrap_stage = {
-	id=b3g2 ; prev=b2g0 ; lean=1 ;
-	compare_target=compare-debug ;
-	bootstrap_target=bootstrap-debug ;
-	cleanstrap_target=cleanstrap-debug ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE3_CFLAGS) -g2" ;
-	stage_libcflags="$(STAGE3_LIBCFLAGS) -g2" ; };
+	cleanstrap_target=cleanstrap ; };
 bootstrap_stage = {
 	id=4 ; prev=3 ; lean=2 ;
 	compare_target=compare3 ;
-	bootstrap_target=bootstrap4 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags="$(STAGE4_CFLAGS)" ;
-	stage_libcflags="$(STAGE4_CFLAGS)" ; };
+	bootstrap_target=bootstrap4 ; };
 bootstrap_stage = {
-	id=profile ; prev=1 ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags='$(STAGE2_CFLAGS) -fprofile-generate' ;
-	stage_libcflags='$(STAGE2_LIBCFLAGS)' ; };
+	id=profile ; prev=1 ; };
 bootstrap_stage = {
 	id=feedback ; prev=profile ;
-	bootstrap_target=profiledbootstrap ;
-	stage_configure_flags="@stage2_werror_flag@" ;
-	stage_cflags='$(STAGE3_CFLAGS) -fprofile-use' ;
-	stage_libcflags='$(STAGE3_LIBCFLAGS) -fprofile-use' ; };
+	bootstrap_target=profiledbootstrap ; };
Index: Makefile.tpl
===================================================================
--- Makefile.tpl.orig	2008-10-10 04:04:32.000000000 -0300
+++ Makefile.tpl	2008-10-10 05:08:11.000000000 -0300
@@ -6,7 +6,8 @@ in
 #
 # Makefile for directory with subdirs to build.
 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
+#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -177,6 +178,8 @@ HOST_EXPORTS = \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
 	CXX="$(CXX)"; export CXX; \
 	CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
+	GCJ="$(GCJ)"; export GCJ; \
+	GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
 	AR="$(AR)"; export AR; \
 	AS="$(AS)"; export AS; \
 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
@@ -212,11 +215,9 @@ HOST_EXPORTS = \
 POSTSTAGE1_HOST_EXPORTS = \
 	$(HOST_EXPORTS) \
 	CC="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
-	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
-	CC_FOR_BUILD="$(STAGE_CC_WRAPPER) \
-	  $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
-	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ \
-	  -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \
+	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ \
+	  $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+	CC_FOR_BUILD="$$CC"; export CC_FOR_BUILD; \
 	LDFLAGS="$(BOOT_LDFLAGS)"; export LDFLAGS;
 
 # Target libraries are put under this directory:
@@ -230,13 +231,13 @@ BASE_TARGET_EXPORTS = \
 	$(BASE_EXPORTS) \
 	AR="$(AR_FOR_TARGET)"; export AR; \
 	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
-	CC="$(CC_FOR_TARGET)"; export CC; \
-	CFLAGS="$(CFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
 	CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
-	CXXFLAGS="$(CXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CXXFLAGS; \
-	GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
-	GFORTRAN="$(GFORTRAN_FOR_TARGET)"; export GFORTRAN; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	GCJ="$(GCJ_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GCJ; \
+	GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \
 	DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
 	LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
@@ -252,11 +253,11 @@ BASE_TARGET_EXPORTS = \
 RAW_CXX_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
 	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
-	CXX="$(RAW_CXX_FOR_TARGET)"; export CXX;
+	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
 
 NORMAL_TARGET_EXPORTS = \
 	$(BASE_TARGET_EXPORTS) \
-	CXX="$(CXX_FOR_TARGET)"; export CXX;
+	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
 
 # Where to find GMP
 HOST_GMPLIBS = @gmplibs@
@@ -356,48 +357,65 @@ LIBCFLAGS = $(CFLAGS)
 CXXFLAGS = @CXXFLAGS@
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 
+TFLAGS =
+
+# Defaults for all stages; some are overridden below.
+
+STAGE_CFLAGS = $(BOOT_CFLAGS)
+STAGE_TFLAGS = $(TFLAGS)
+STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
+
+[+ FOR bootstrap-stage +]
+# Defaults for stage [+id+]; some are overridden below.
+STAGE[+id+]_CFLAGS = $(STAGE_CFLAGS)
+STAGE[+id+]_TFLAGS = $(STAGE_TFLAGS)
+STAGE[+id+]_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
+[+ ENDFOR bootstrap-stage +]
+
 # Only build the C compiler for stage1, because that is the only one that
 # we can guarantee will build with the native compiler, and also it is the
 # only thing useful for building stage2. STAGE1_CFLAGS (via CFLAGS),
 # MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
 # overrideable (for a bootstrap build stage1 also builds gcc.info).
 
+STAGE1_CFLAGS = @stage1_cflags@
 STAGE1_CHECKING=@stage1_checking@
 STAGE1_LANGUAGES=@stage1_languages@
+# * We force-disable intermodule optimizations, even if
+#   --enable-intermodule was passed, since the installed compiler
+#   probably can't handle them.  Luckily, autoconf always respects
+#   the last argument when conflicting --enable arguments are passed.
+# * Likewise, we force-disable coverage flags, since the installed
+#   compiler probably has never heard of them.
+STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
+	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
+
+STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
+STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
 
-STAGE1_CFLAGS=@stage1_cflags@
-STAGE2_CFLAGS=$(BOOT_CFLAGS)
-STAGE3_CFLAGS=$(BOOT_CFLAGS)
-STAGE4_CFLAGS=$(BOOT_CFLAGS)
-
-STAGE1_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE2_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE3_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
-STAGE4_LIBCFLAGS=$(CFLAGS_FOR_TARGET)
+STAGEfeedback_CFLAGS = $(STAGE3_CFLAGS) -fprofile-use
+STAGEfeedback_TFLAGS = $(STAGE3_TFLAGS)
 
 do-compare = @do_compare@
 do-compare3 = $(do-compare)
-do-compare-debug = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
 
 # -----------------------------------------------
 # Programs producing files for the TARGET machine
 # -----------------------------------------------
 
-FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
-
 AR_FOR_TARGET=@AR_FOR_TARGET@
 AS_FOR_TARGET=@AS_FOR_TARGET@
-CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
+CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@
 
 # If GCC_FOR_TARGET is not overriden on the command line, then this
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
-GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ $(FLAGS_FOR_TARGET)
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@
+CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@
+RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@
+GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@
+GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
 LD_FOR_TARGET=@LD_FOR_TARGET@
 
@@ -415,13 +433,17 @@ COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_
 
 CFLAGS_FOR_TARGET = @CFLAGS_FOR_TARGET@
 CXXFLAGS_FOR_TARGET = @CXXFLAGS_FOR_TARGET@
-SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
-DEBUG_PREFIX_CFLAGS_FOR_TARGET = @DEBUG_PREFIX_CFLAGS_FOR_TARGET@
 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
 LDFLAGS_FOR_TARGET = 
 
+FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
+DEBUG_PREFIX_CFLAGS_FOR_TARGET = @DEBUG_PREFIX_CFLAGS_FOR_TARGET@
+
+XGCC_FLAGS_FOR_TARGET = $(FLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
+
 # ------------------------------------
 # Miscellaneous targets and flag lists
 # ------------------------------------
@@ -471,7 +493,10 @@ HOST_LIB_PATH_[+module+] = \
 # Flags to pass down to all sub-makes.
 BASE_FLAGS_TO_PASS =[+ FOR flags_to_pass +][+ IF optional +] \
 	"`echo '[+flag+]=$([+flag+])' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"[+ ELSE optional +] \
-	"[+flag+]=$([+flag+])"[+ ENDIF optional+][+ ENDFOR flags_to_pass +] \
+	"[+flag+]=$([+flag+])"[+ ENDIF optional+][+ ENDFOR flags_to_pass +][+ FOR bootstrap-stage +] \
+	"STAGE[+id+]_CFLAGS=$(STAGE[+id+]_CFLAGS)" \
+	"STAGE[+id+]_TFLAGS=$(STAGE[+id+]_TFLAGS)"[+ ENDFOR bootstrap-stage +] \
+	"TFLAGS=$(TFLAGS)" \
 	"CONFIG_SHELL=$(SHELL)" \
 	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 
 
@@ -486,6 +511,8 @@ EXTRA_HOST_FLAGS = \
 	'CC=$(CC)' \
 	'CXX=$(CXX)' \
 	'DLLTOOL=$(DLLTOOL)' \
+	'GCJ=$(GCJ)' \
+	'GFORTRAN=$(GFORTRAN)' \
 	'LD=$(LD)' \
 	'LIPO=$(LIPO)' \
 	'NM=$(NM)' \
@@ -525,20 +552,24 @@ POSTSTAGE1_FLAGS_TO_PASS = \
 EXTRA_TARGET_FLAGS = \
 	'AR=$$(AR_FOR_TARGET)' \
 	'AS=$(COMPILER_AS_FOR_TARGET)' \
-	'CC=$$(CC_FOR_TARGET)' \
-	'CFLAGS=$$(CFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
-	'CXX=$$(CXX_FOR_TARGET)' \
-	'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
+	'CC=$$(CC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
+	'CXX=$$(CXX_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
 	'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
+	'GCJ=$$(GCJ_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
+	'GFORTRAN=$$(GFORTRAN_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
 	'LD=$(COMPILER_LD_FOR_TARGET)' \
 	'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
-	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
-	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
+	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
+	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
-	'WINDMC=$$(WINDMC_FOR_TARGET)'
+	'WINDMC=$$(WINDMC_FOR_TARGET)' \
+	'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \
+	"TFLAGS=$$TFLAGS"
 
 TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
 
@@ -558,6 +589,13 @@ EXTRA_GCC_FLAGS = \
 
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
+@if gcc
+BUILD_CONFIG =
+ifneq ($(BUILD_CONFIG),)
+include $(foreach CONFIG, $(BUILD_CONFIG), $(srcdir)/config/$(CONFIG).mk)
+endif
+@endif gcc
+
 .PHONY: configure-host
 configure-host: [+
   FOR host_modules +] \
@@ -581,11 +619,17 @@ all:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	if [ -f stage_last ]; then \
+@if gcc-bootstrap
+	if [ -f stage_last ]; then : ; \
+	  TFLAGS="$(STAGE$(shell sed s,^stage,, stage_last)_TFLAGS)"; \
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
+@endif gcc-bootstrap
 	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target; \
-	fi
+@if gcc-bootstrap
+	fi; \
+@endif gcc-bootstrap
+	:
 
 .PHONY: all-build
 [+ FOR build_modules +]
@@ -866,6 +910,7 @@ configure-stage[+id+]-[+prefix+][+module
 	@$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+]
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	[+ IF check_multilibs
 	+]echo "Checking multilib configuration for [+module+]..."; \
 	$(CC_FOR_TARGET) --print-multi-lib > [+subdir+]/[+module+]/multilib.tmp 2> /dev/null ; \
@@ -881,11 +926,14 @@ configure-stage[+id+]-[+prefix+][+module
 	fi; \
 	[+ ENDIF check_multilibs +]test ! -f [+subdir+]/[+module+]/Makefile || exit 0; \
 	[+exports+][+ IF prev +] \
-	[+poststage1_exports+][+ ENDIF prev +] [+ IF prefix +] \
-	CFLAGS="[+stage_libcflags+] $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CFLAGS; \
-	CXXFLAGS="[+stage_libcflags+] $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)"; export CXXFLAGS; [+ ELSE +] \
-	CFLAGS="[+stage_cflags+]"; export CFLAGS; \
-	CXXFLAGS="[+stage_cflags+]"; export CXXFLAGS; [+ ENDIF +] \
+	[+poststage1_exports+][+ ENDIF prev +][+ IF prefix +] \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;[+ ELSE prefix +] \
+	CFLAGS="$(STAGE[+id+]_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE[+id+]_CFLAGS)"; export CXXFLAGS;[+ IF prev +] \
+	LIBCFLAGS="$(STAGE[+id+]_CFLAGS)"[+ ELSE prev +] \
+	LIBCFLAGS="$(LIBCFLAGS)"[+ ENDIF prev +]; export LIBCFLAGS;[+ ENDIF prefix +] \
 	echo Configuring stage [+id+] in [+subdir+]/[+module+] ; \
 	$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
 	cd [+subdir+]/[+module+] || exit 1; \
@@ -898,9 +946,10 @@ configure-stage[+id+]-[+prefix+][+module
 	libsrcdir="$$s/[+module+]"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  [+args+] --build=${build_alias} --host=[+host_alias+] \
-	  --target=[+target_alias+] $${srcdiroption} \
-	  [+ IF prev +]--with-build-libsubdir=$(HOST_SUBDIR)[+ ENDIF prev +] \
-	  [+stage_configure_flags+] [+extra_configure_flags+]
+	  --target=[+target_alias+] $${srcdiroption} [+ IF prev +]\
+	  --with-build-libsubdir=$(HOST_SUBDIR) [+ ENDIF prev +]\
+	  $(STAGE[+id+]_CONFIGURE_FLAGS)[+ IF extra_configure_flags +] \
+	  [+extra_configure_flags+][+ ENDIF extra_configure_flags +]
 @endif [+prefix+][+module+]-bootstrap
 [+ ENDFOR bootstrap_stage +]
 [+ ENDIF bootstrap +]
@@ -940,16 +989,25 @@ all-stage[+id+]-[+prefix+][+module+]: co
 	@[ $(current_stage) = stage[+id+] ] || $(MAKE) stage[+id+]-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	[+exports+][+ IF prev +] \
 	[+poststage1_exports+][+ ENDIF prev +] \
 	cd [+subdir+]/[+module+] && \
-	$(MAKE) $(BASE_FLAGS_TO_PASS) \
-		CFLAGS="[+stage_cflags+]" CXXFLAGS="[+stage_cflags+]" \
-		LIBCFLAGS="[+stage_libcflags+]" \
-		CFLAGS_FOR_TARGET="[+stage_libcflags+]" \
-		CXXFLAGS_FOR_TARGET="[+stage_libcflags+]" [+args+] [+
+	$(MAKE) $(BASE_FLAGS_TO_PASS)[+ IF prefix +] \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"[+ ELSE prefix +] \
+		CFLAGS="$(STAGE[+id+]_CFLAGS)" \
+		CXXFLAGS="$(STAGE[+id+]_CFLAGS)"[+ IF prev +] \
+		LIBCFLAGS="$(STAGE[+id+]_CFLAGS)"[+ ELSE prev +] \
+		LIBCFLAGS="$(LIBCFLAGS)"[+ ENDIF prev +][+ ENDIF prefix +] \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		[+args+] [+
 		IF prev +][+poststage1_args+][+ ENDIF prev
 		+] [+extra_make_flags+] \
+		TFLAGS="$(STAGE[+id+]_TFLAGS)" \
 		$(TARGET-stage[+id+]-[+prefix+][+module+])
 
 maybe-clean-stage[+id+]-[+prefix+][+module+]: clean-stage[+id+]-[+prefix+][+module+]
@@ -1411,6 +1469,7 @@ do-clean: clean-stage[+id+]
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 
 [+bootstrap-target+]-lean:
@@ -1421,6 +1480,7 @@ do-clean: clean-stage[+id+]
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 [+ ENDIF bootstrap-target +]
 
@@ -1443,6 +1503,7 @@ distclean-stage[+id+]::
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE[+id+]_TFLAGS)"; \
 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
 [+ ENDIF cleanstrap-target +]
 @endif gcc-bootstrap
@@ -1478,8 +1539,8 @@ stage_current:
 .PHONY: restrap
 restrap::
 	@: $(MAKE); $(stage)
-	rm -rf stage1-$(TARGET_SUBDIR) [+ FOR bootstrap-stage +][+ IF prev
-	  +]stage[+id+]-* [+ ENDIF prev +][+ ENDFOR bootstrap-stage +]
+	rm -rf stage1-$(TARGET_SUBDIR)[+ FOR bootstrap-stage +][+ IF prev
+	  +] stage[+id+]-*[+ ENDIF prev +][+ ENDFOR bootstrap-stage +]
 restrap:: all
 @endif gcc-bootstrap
 
Index: config/mt-gnu
===================================================================
--- config/mt-gnu.orig	2008-10-10 04:04:33.000000000 -0300
+++ config/mt-gnu	2008-10-10 05:08:11.000000000 -0300
@@ -1,2 +1 @@
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET) \
-	$(DEBUG_PREFIX_CFLAGS_FOR_TARGET) -D_GNU_SOURCE
+CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE
Index: config/bootstrap-O1.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-O1.mk	2008-10-10 05:08:11.000000000 -0300
@@ -0,0 +1 @@
+BOOT_CFLAGS := -O1 $(filter-out -O%, $(BOOT_CFLAGS))
Index: config/bootstrap-O3.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-O3.mk	2008-10-10 05:08:11.000000000 -0300
@@ -0,0 +1 @@
+BOOT_CFLAGS := -O3 $(filter-out -O%, $(BOOT_CFLAGS))
Index: config/bootstrap-debug.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug.mk	2008-10-10 05:08:11.000000000 -0300
@@ -0,0 +1,2 @@
+STAGE2_CFLAGS += -g0
+do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac.orig	2008-10-10 04:04:33.000000000 -0300
+++ libjava/configure.ac	2008-10-10 05:08:11.000000000 -0300
@@ -352,23 +352,33 @@ else
      which_gcj=path
   fi
 fi
+libgcjdir=`${PWDCMD-pwd}`
+case $GCJ in
+*" -B"*)
+  # Just in case there is a comma in the build dir, quote it for the
+  # sed command below.
+  case $libgcjdir in
+  *[[,\\]]*) qlibgcjdir=`echo "$libgcjdir" | sed 's:[[,\\]]:\\&:g'`;;
+  *) qlibgcjdir=$libgcjdir;;
+  esac
+  GCJ=`echo "$GCJ" | sed "s, -B, -B$qlibgcjdir/&,"`
+  ;;
+*)
+  GCJ=$GCJ" -B$libgcjdir/"
+  ;;
+esac
 case "${which_gcj}" in
    built)
-      GCJ="$built_gcc_dir/gcj -B`${PWDCMD-pwd}`/ -B$built_gcc_dir/"
       GCJH='$(top_builddir)/$(MULTIBUILDTOP)../../$(host_subdir)/gcc/gcjh'
    ;;
    cross)
       if test "x${with_newlib}" = "xyes"; then
          # FIXME (comment): Why is this needed?
          GCC_UNWIND_INCLUDE=
-         GCJ="${target_noncanonical}-gcj"
-      else
-         GCJ="${target_noncanonical}-gcj -B`${PWDCMD-pwd}`/"
       fi
       GCJH='$(target_noncanonical)-gcjh'
    ;;
    path)
-      GCJ="gcj -B`${PWDCMD-pwd}`/"
       GCJH=gcjh
    ;;
 esac
Index: gcc/java/Make-lang.in
===================================================================
--- gcc/java/Make-lang.in.orig	2008-10-10 04:04:33.000000000 -0300
+++ gcc/java/Make-lang.in	2008-10-10 05:08:11.000000000 -0300
@@ -44,10 +44,10 @@
 JAVA_INSTALL_NAME := $(shell echo gcj|sed '$(program_transform_name)')
 JAVA_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcj|sed '$(program_transform_name)')
 
-GCJ = gcj
+XGCJ = gcj
 
 # Define the names for selecting java in LANGUAGES.
-java: jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) jcf-dump$(exeext)
+java: jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) jcf-dump$(exeext)
 
 # Define the name of target independent tools to be installed in $(bindir)
 # Names are subject to changes
@@ -62,17 +62,17 @@ jvspec.o: $(srcdir)/java/jvspec.c $(SYST
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
 		$(INCLUDES) $(srcdir)/java/jvspec.c $(OUTPUT_OPTION))
 
-# Create the compiler driver for $(GCJ).
-$(GCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \
+# Create the compiler driver for $(XGCJ).
+$(XGCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \
 	   prefix.o intl.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) jvspec.o \
 	  java/jcf-path.o prefix.o intl.o \
 	  version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
-# Create a version of the $(GCJ) driver which calls the cross-compiler.
-$(GCJ)-cross$(exeext): $(GCJ)$(exeext)
-	-rm -f $(GCJ)-cross$(exeext)
-	cp $(GCJ)$(exeext) $(GCJ)-cross$(exeext)
+# Create a version of the $(XGCJ) driver which calls the cross-compiler.
+$(XGCJ)-cross$(exeext): $(XGCJ)$(exeext)
+	-rm -f $(XGCJ)-cross$(exeext)
+	cp $(XGCJ)$(exeext) $(XGCJ)-cross$(exeext)
 
 java.srcextra:
 
@@ -115,8 +115,8 @@ jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(
 #\f
 # Build hooks:
 
-java.all.cross: $(GCJ)-cross$(exeext)
-java.start.encap: $(GCJ)$(exeext)
+java.all.cross: $(XGCJ)-cross$(exeext)
+java.start.encap: $(XGCJ)$(exeext)
 java.rest.encap:
 
 
@@ -157,11 +157,11 @@ check-java :
 
 # Install gcj as well as the target-independent tools.
 java.install-common: installdirs
-	-if [ -f $(GCJ)$(exeext) ]; then \
+	-if [ -f $(XGCJ)$(exeext) ]; then \
 	  rm -f $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
-	  $(INSTALL_PROGRAM) $(GCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
+	  $(INSTALL_PROGRAM) $(XGCJ)$(exeext) $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
 	  chmod a+x $(DESTDIR)$(bindir)/$(JAVA_INSTALL_NAME)$(exeext); \
-	  if [ -f $(GCJ)-cross$(exeext) ]; then \
+	  if [ -f $(XGCJ)-cross$(exeext) ]; then \
 	    true; \
 	  else \
 	    rm -f $(DESTDIR)$(bindir)/$(JAVA_TARGET_INSTALL_NAME)$(exeext); \
@@ -210,7 +210,7 @@ java.install-pdf: $(JAVA_PDFFILES)
 java.mostlyclean:
 	-rm -f java/*$(objext) $(DEMANGLER_PROG)
 	-rm -f java/*$(coverageexts)
-	-rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) \
+	-rm -f jc1$(exeext) $(XGCJ)$(exeext) jvgenmain$(exeext) \
           jcf-dump$(exeext) s-java
 java.clean:
 java.distclean:
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig	2008-10-01 15:43:57.000000000 -0300
+++ gcc/doc/install.texi	2008-10-10 05:08:11.000000000 -0300
@@ -1848,7 +1848,7 @@ bootstrapped, you can use @code{CFLAGS_F
 compilation flags, as for non-bootstrapped target libraries.
 Again, if the native compiler miscompiles the stage1 compiler, you may
 need to work around this by avoiding non-working parts of the stage1
-compiler.  Use @code{STAGE1_LIBCFLAGS} to this end.
+compiler.  Use @code{STAGE1_TFLAGS} to this end.
 
 If you used the flag @option{--enable-languages=@dots{}} to restrict
 the compilers to be built, only those you've actually enabled will be
@@ -1872,6 +1872,24 @@ the one you are building on: for example
 @code{powerpc64-unknown-linux-gnu} host.  In this case, pass
 @option{--enable-bootstrap} to the configure script.
 
+@code{BUILD_CONFIG} can be used to bring in additional customization to
+the build.  It can be set to a whitespace-separated list of names.  For
+each such @code{NAME}, top-level @file{config/@code{NAME}.mk} will be
+included by the top-level @file{Makefile}, bringing in any settings it
+contains.  Some examples are:
+
+@table @asis
+@item @samp{bootstrap-O1}
+Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
+@option{-O1} to it.  @samp{BUILD_CONFIG=bootstrap-O1} is equivalent to
+@samp{BOOT_CFLAGS='-g -O1'}.
+
+@item @samp{bootstrap-O3}
+Analogous to @code{bootstrap-O1}.
+
+@item @samp{bootstrap-debug}
+Builds stage2 without debug information, and uses
+@file{contrib/compare-debug} to compare object files.
 
 @section Building a cross compiler
 
Index: config/multi.m4
===================================================================
--- config/multi.m4.orig	2008-10-10 04:04:33.000000000 -0300
+++ config/multi.m4	2008-10-10 05:08:11.000000000 -0300
@@ -1,5 +1,5 @@
 ##                                                          -*- Autoconf -*-
-# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
+# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -62,4 +62,7 @@ with_target_subdir="$with_target_subdir"
 ac_configure_args="${multilib_arg} ${ac_configure_args}"
 multi_basedir="$multi_basedir"
 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-CC="$CC"])])dnl
+CC="$CC"
+CXX="$CXX"
+GFORTRAN="$GFORTRAN"
+GCJ="$GCJ"])])dnl

[-- Attachment #4: Type: text/plain, Size: 257 bytes --]


-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member       ¡Sé Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS  uses
  2008-10-07  9:41 ` Paolo Bonzini
@ 2009-05-12  5:48   ` Alexandre Oliva
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Oliva @ 2009-05-12  5:48 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 3302 bytes --]

On Oct  7, 2008, Paolo Bonzini <bonzini@gnu.org> wrote:

> Alexandre Oliva wrote:
>> This patch introduces support for BUILD_CONFIG, a Makefile macro that,
>> if set to say "a b", will cause config/a.mk and config/b.mk to be
>> included in the top-level Makefile.  The plan was to use this to add
>> -fcompare-debug to certain variables, and eventually add a configure
>> option to set a default (non-empty) value for BUILD_CONFIG.

> I like it.  Please merge it into trunk when 4.5 stage1 starts.

Here's the patch I'm installing.  It's the same as last time, except for
variations in line numbers and a fix for an error I got in processing
the docs.  It's very large because of the regenerated files, so I'm
compressing it.

for ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR target/37137
	* Makefile.def (flags_to_pass): Remove redundant and incomplete
	STAGE1_CFLAGS, STAGE2_CFLAGS, STAGE3_CFLAGS, and STAGE4_CFLAGS.
	Add FLAGS_FOR_TARGET and BUILD_CONFIG.
	(bootstrap_stage): Remove bootstrap-debug custom stages.  Turn
	stage_configureflags, stage_cflags and stage_libcflags into
	explicit Makefile macros.
	* Makefile.tpl (HOST_EXPORTS, EXTRA_HOST_FLAGS): Pass GCJ and
	GFORTRAN.
	(POSTSTAGE1_HOST_EXPORTS): Add XGCC_FLAGS_FOR_TARGET and TFLAGS to
	CC.  Set CC_FOR_BUILD from CC.
	(BASE_TARGET_EXPORTS, RAW_CXX_TARGET_EXPORTS,
	NORMAL_TARGET_EXPORTS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS and CXXFLAGS to
	XGCC_FLAGS_FOR_TARGET.  Add it along with TFLAGS to CC, CXX, GCJ,
	and GFORTRAN.
	(TFLAGS, STAGE_CFLAGS, STAGE_TFLAGS, STAGE_CONFIGURE_FLAGS): New.
	(_LIBCFLAGS): Renamed to _TFLAGS.
	(do-compare-debug, do-compare3-debug): Drop.
	(CC, GCC_FOR_TARGET, CXX_FOR_TARGET, RAW_CXX_FOR_TARGET,
	GCJ_FOR_TARGET, GFORTRAN_FOR_TARGET): Remove FLAGS_FOR_TARGET.
	(FLAGS_FOR_TARGET, SYSROOT_CFLAGS_FOR_TARGET,
	DEBUG_PREFIX_CFLAGS_FOR_TARGET): Move down.
	(XGCC_FLAGS_FOR_TARGET): New.
	(BASE_FLAGS_TO_PASS): Pass STAGEid_CFLAGS, STAGEid_TFLAGS and TFLAGS.
	(EXTRA_HOST_FLAGS): Pass GCJ and GFORTRAN.
	(POSTSTAGE1_FLAGS_TO_PASS): Move SYSROOT_CFLAGS_FOR_TARGET and
	DEBUG_PREFIX_CFLAGS_FOR_TARGET from CFLAGS, CXXFLAGS, LIBCFLAGS,
	LIBCXXFLAGS to XGCC_FLAGS_FOR_TARGET.    Add it along with TFLAGS
	to CC, CXX, GCJ, and GFORTRAN.  Pass XGCC_FLAGS_FOR_TARGET and
	TFLAGS.
	(BUILD_CONFIG): Include if requested.
	(all): Set TFLAGS on bootstrap.
	(configure-stageid-prefixmodule): Pass TFLAGS, adjust FLAGS.
	(all-stageid-prefixmodule): Likewise.
	(do-clean, distclean-stageid): Set TFLAGS.
	(restrap): Fix whitespace.
	* Makefile.in: Rebuilt.

for config/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* multi.m4: Save CXX, GFORTRAN and GCJ in config.status.
	* mt-gnu (CXXFLAGS_FOR_TARGET): Adjust.
	* bootstrap-O1.mk: New.
	* bootstrap-O3.mk: New.
	* bootstrap-debug.mk: New.

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR target/37137
	* doc/install.texi (STAGE1_TFLAGS, BUILD_CONFIG): Document.

for gcc/java/ChangeLog
from Alexandre Oliva  <aoliva@redhat.com>

	* Make-lang.in (GCJ): Renamed to...
	(XGCJ): ... this.

for libjava/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* configure.ac: Insert libgcjdir in the GCJ passed in the
	environment, rather than overriding completely.
	* configure: Rebuilt.


[-- Attachment #2: bootstrap-configs.patch.bz2 --]
[-- Type: application/x-bzip2, Size: 25229 bytes --]

[-- Attachment #3: Type: text/plain, Size: 258 bytes --]



-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-05-12  5:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-07  8:31 [vta] revamp bootstrap-debug with -fcompare-debug, fix LIBCFLAGS uses Alexandre Oliva
2008-10-07  8:41 ` Ralf Wildenhues
2008-10-07  9:01   ` Andreas Schwab
2008-10-07 18:09   ` Alexandre Oliva
2008-10-10 13:42     ` Alexandre Oliva
2008-10-07  9:41 ` Paolo Bonzini
2009-05-12  5:48   ` Alexandre Oliva
2008-10-08  2:27 ` Adam Nemet
2008-10-10  9:23   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).