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


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

[vta, vta4.4] default to bootstrap-debug and more


This patch sets BUILD_CONFIG=bootstrap-debug by default when building
gcc.

It also implements other alternatives to bootstrap-debug that get better
testing coverage for internal representation: bootstrap-debug-big, that
saves (big!) dumps across stages and compares them later, as RTH
suggested, and bootstrap-debug-lean, that uses -fcompare-debug to
perform the same testing but trading disk space for recompilation in
stage3.   The latter is kind of split out of bootstrap-debug-lib, that
now only affects libraries.

In order to implement bootstrap-debug-big, I had to tweak
-fdump-final-insns so that, instead of requiring an output argument, it
worked without one.  This proved to be a bit of a pain to handle
correctly, requiring some hacking in the initial self specs to present a
nice interface.

This is the patch I'm installing in the branches.  I'll soon merge it
with the VTA buildconfig patches and submit it for the trunk.

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

	* config/bootstrap-debug.mk: Add comments.
	* config/bootstrap-debug-big.mk: New.
	* config/bootstrap-debug-lean.mk: New.
	* config/bootstrap-debug-ckovw.mk: Add comments.
	* config/bootstrap-debug-lib.mk: Drop CFLAGS for stages.  Use -g0
	for TFLAGS in stage1.  Drop -fvar-tracking-assignments-toggle.
	* contrib/compare-debug: Look for .gkd files and compare them.
	* Makefile.tpl (BUILD_CONFIG): Default to bootstrap-debug.
	* Makefile.in: Rebuilt.

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

	* doc/invoke.texi (bootstrap-debug): More details.
	(bootstrap-debug-big, bootstrap-debug-lean): Document.
	(bootstrap-debug-lib): More details.
	(bootstrap-debug-ckovw): Update.
	* gcc.c (invoke_as): Call compare-debug-dump-opt for
	-fdump-final-insns too.
	(driver_self_specs): Map -fdump-final-insns to
	-fdump-final-insns=..
	(compare_debug_dump_opt_spec_function): Test for . argument and
	compute output name.  Compute temp output spec without flag name.
	* doc/invoke.texi (fdump-final-insns): Document argument-less use.
	* toplev.c (process_options): Don't open final insns dump file if
	we're not going to write to it.

Index: config/bootstrap-debug.mk
===================================================================
--- config/bootstrap-debug.mk.orig	2009-06-11 06:52:50.000000000 -0300
+++ config/bootstrap-debug.mk	2009-06-11 07:36:18.000000000 -0300
@@ -1,2 +1,12 @@
+# This BUILD_CONFIG option builds checks that toggling debug
+# information generation doesn't affect the generated object code.
+
+# It is very lightweight: in addition to not performing any additional
+# compilation (unlike bootstrap-debug-lean), it actually speeds up
+# stage2, for no debug information is generated when compiling with
+# the unoptimized stage1.
+
+# For more thorough testing, see bootstrap-debug-lean.mk
+
 STAGE2_CFLAGS += -gtoggle
 do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: config/bootstrap-debug-big.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug-big.mk	2009-06-11 07:36:18.000000000 -0300
@@ -0,0 +1,8 @@
+# This BUILD_CONFIG option is a bit like bootstrap-debug-lean, but it
+# trades space for speed: instead of recompiling programs during
+# stage3, it generates dumps during stage2 and stage3, saving them all
+# until the final compare.
+
+STAGE2_CFLAGS += -gtoggle -fdump-final-insns
+STAGE3_CFLAGS += -fdump-final-insns
+do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: config/bootstrap-debug-lean.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ config/bootstrap-debug-lean.mk	2009-06-11 07:36:18.000000000 -0300
@@ -0,0 +1,11 @@
+# This BUILD_CONFIG option is a bit like bootstrap-debug, but in
+# addition to comparing stripped object files, it also compares
+# compiler internal state during stage3.
+
+# This makes it slower than bootstrap-debug, for there's additional
+# dumping and recompilation during stage3.  bootstrap-debug-big can
+# avoid the recompilation, if plenty of disk space is available.
+
+STAGE2_CFLAGS += -gtoggle -fcompare-debug=
+STAGE3_CFLAGS += -fcompare-debug
+do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: config/bootstrap-debug-ckovw.mk
===================================================================
--- config/bootstrap-debug-ckovw.mk.orig	2009-06-11 06:52:50.000000000 -0300
+++ config/bootstrap-debug-ckovw.mk	2009-06-11 07:36:18.000000000 -0300
@@ -1,3 +1,7 @@
+# This BUILD_CONFIG option is to be used along with
+# bootstrap-debug-lean and bootstrap-debug-lib in a full bootstrap, to
+# check that all host and target files are built with -fcompare-debug.
+
 # 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"
Index: config/bootstrap-debug-lib.mk
===================================================================
--- config/bootstrap-debug-lib.mk.orig	2009-06-11 06:52:50.000000000 -0300
+++ config/bootstrap-debug-lib.mk	2009-06-11 07:36:18.000000000 -0300
@@ -1,13 +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
-# Don't use -gtoggle for target libs, this breaks crtstuff on ppc.
-STAGE1_TFLAGS += -fcompare-debug=
-STAGE2_TFLAGS += -fcompare-debug=-fvar-tracking-assignments-toggle
+# This BUILD_CONFIG option tests that target libraries built during
+# stage3 would have generated the same executable code if they were
+# compiled with -g0.
+
+# It uses -g0 rather than -gtoggle because -g is default on target
+# library builds, and toggling it where it's supposed to be disabled
+# breaks e.g. crtstuff on ppc.
+
+STAGE1_TFLAGS += -g0 -fcompare-debug=
+STAGE2_TFLAGS += -fcompare-debug=
 STAGE3_TFLAGS += -fcompare-debug=-g0
-STAGE4_TFLAGS += -fcompare-debug=-fvar-tracking-assignments-toggle
 do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
Index: contrib/compare-debug
===================================================================
--- contrib/compare-debug.orig	2009-06-11 06:52:50.000000000 -0300
+++ contrib/compare-debug	2009-06-11 07:36:18.000000000 -0300
@@ -2,7 +2,7 @@
 
 # Compare stripped copies of two given object files.
 
-# Copyright (C) 2007, 2008 Free Software Foundation
+# Copyright (C) 2007, 2008, 2009 Free Software Foundation
 # Originally by Alexandre Oliva <aoliva@redhat.com>
 
 # This file is part of GCC.
@@ -149,4 +149,12 @@ $rm "$1.$suf1" "$2.$suf2"
 
 trap "exit $status; exit" 0 1 2 15
 
+if test -f "$1".gkd || test -f "$2".gkd; then
+  if cmp "$1".gkd "$2".gkd; then
+    :
+  else
+    status=$?
+  fi
+fi
+
 exit $status
Index: Makefile.tpl
===================================================================
--- Makefile.tpl.orig	2009-06-11 06:52:50.000000000 -0300
+++ Makefile.tpl	2009-06-11 07:36:18.000000000 -0300
@@ -590,7 +590,7 @@ EXTRA_GCC_FLAGS = \
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
 @if gcc
-BUILD_CONFIG =
+BUILD_CONFIG = bootstrap-debug
 ifneq ($(BUILD_CONFIG),)
 include $(foreach CONFIG, $(BUILD_CONFIG), $(srcdir)/config/$(CONFIG).mk)
 endif
Index: Makefile.in
===================================================================
--- Makefile.in.orig	2009-06-11 06:52:50.000000000 -0300
+++ Makefile.in	2009-06-11 07:36:18.000000000 -0300
@@ -735,7 +735,7 @@ EXTRA_GCC_FLAGS = \
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
 @if gcc
-BUILD_CONFIG =
+BUILD_CONFIG = bootstrap-debug
 ifneq ($(BUILD_CONFIG),)
 include $(foreach CONFIG, $(BUILD_CONFIG), $(srcdir)/config/$(CONFIG).mk)
 endif
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig	2009-06-11 06:52:50.000000000 -0300
+++ gcc/doc/install.texi	2009-06-11 07:36:18.000000000 -0300
@@ -2022,28 +2022,48 @@ Removes any @option{-O}-started option f
 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.
+Verifies that the compiler generates the same executable code, whether
+or not it is asked to emit debug information.  To this end, this option
+builds stage2 host programs without debug information, and uses
+@file{contrib/compare-debug} to compare them with the stripped stage3
+object files.  If @code{BOOT_CFLAGS} is overridden so as to not enable
+debug information, stage2 will have it, and stage3 won't.  This option
+is enabled by default when GCC bootstrapping is enabled: in addition to
+better test coverage, it makes default bootstraps faster and leaner.
+
+@item @samp{bootstrap-debug-big}
+In addition to the checking performed by @code{bootstrap-debug}, this
+option saves internal compiler dumps during stage2 and stage3 and
+compares them as well, which helps catch additional potential problems,
+but at a great cost in terms of disk space.
+
+@item @samp{bootstrap-debug-lean}
+This option saves disk space compared with @code{bootstrap-debug-big},
+but at the expense of some recompilation.  Instead of saving the dumps
+of stage2 and stage3 until the final compare, it uses
+@option{-fcompare-debug} to generate, compare and remove the dumps
+during stage3, repeating the compilation that already took place in
+stage2, whose dumps were not saved.
 
 @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.
+This option tests executable code invariance over debug information
+generation on target libraries, just like @code{bootstrap-debug-lean}
+tests it on host programs.  It builds stage3 libraries with
+@option{-fcompare-debug}, and it can be used along with any of the
+@code{bootstrap-debug} options above.
+
+There aren't @code{-lean} or @code{-big} counterparts to this option
+because most libraries are only build in stage3, so bootstrap compares
+would not get significant coverage.  Moreover, the few libraries built
+in stage2 are used in stage3 host programs, so we wouldn't want to
+compile stage2 libraries with different options for comparison purposes.
 
 @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.
+useful to verify the full @option{-fcompare-debug} testing coverage.  It
+must be used along with @code{bootstrap-debug-lean} and
+@code{bootstrap-debug-lib}.
 
 @item @samp{bootstrap-time}
 Arranges for the run time of each program started by the GCC driver,
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c.orig	2009-06-11 06:52:50.000000000 -0300
+++ gcc/gcc.c	2009-06-11 08:42:13.000000000 -0300
@@ -891,10 +891,10 @@ static const char *asm_options =
 
 static const char *invoke_as =
 #ifdef AS_NEEDS_DASH_FOR_PIPED_INPUT
-"%{fcompare-debug=*:%:compare-debug-dump-opt()}\
+"%{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\
  %{!S:-o %|.s |\n as %(asm_options) %|.s %A }";
 #else
-"%{fcompare-debug=*:%:compare-debug-dump-opt()}\
+"%{fcompare-debug=*|fdump-final-insns=*:%:compare-debug-dump-opt()}\
  %{!S:-o %|.s |\n as %(asm_options) %m.s %A }";
 #endif
 
@@ -926,6 +926,7 @@ static const char *const multilib_defaul
 #endif
 
 static const char *const driver_self_specs[] = {
+  "%{fdump-final-insns:-fdump-final-insns=.} %<fdump-final-insns",
   DRIVER_SELF_SPECS, GOMP_SELF_SPECS
 };
 
@@ -8665,29 +8666,38 @@ compare_debug_dump_opt_spec_function (in
   if (arg != 0)
     fatal ("too many arguments to %%:compare-debug-dump-opt");
 
-  if (!compare_debug)
-    return NULL;
-
   do_spec_2 ("%{fdump-final-insns=*:%*}");
   do_spec_1 (" ", 0, NULL);
 
-  if (argbuf_index > 0)
+  if (argbuf_index > 0 && strcmp (argv[argbuf_index - 1], "."))
     {
+      if (!compare_debug)
+	return NULL;
+
       name = xstrdup (argv[argbuf_index - 1]);
       ret = NULL;
     }
   else
     {
-#define OPT "-fdump-final-insns="
-      ret = "-fdump-final-insns=%g.gkd";
+      const char *ext = NULL;
+
+      if (argbuf_index > 0)
+	{
+	  do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}");
+	  ext = ".gkd";
+	}
+      else if (!compare_debug)
+	return NULL;
+      else
+	do_spec_2 ("%g.gkd");
 
-      do_spec_2 (ret + sizeof (OPT) - 1);
       do_spec_1 (" ", 0, NULL);
-#undef OPT
 
       gcc_assert (argbuf_index > 0);
 
-      name = xstrdup (argbuf[argbuf_index - 1]);
+      name = concat (argbuf[argbuf_index - 1], ext, NULL);
+
+      ret = concat ("-fdump-final-insns=", name, NULL);
     }
 
   which = compare_debug < 0;
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi.orig	2009-06-11 07:13:30.000000000 -0300
+++ gcc/doc/invoke.texi	2009-06-11 08:34:02.000000000 -0300
@@ -4376,9 +4376,12 @@ other options are processed, and it does
 many times it is given.  This is mainly intended to be used with
 @option{-fcompare-debug}.
 
-@item -fdump-final-insns=@var{file}
-@opindex fdump-final-insns=
-Dump the final internal representation (RTL) to @var{file}.
+@item -fdump-final-insns@r{[}=@var{file}@r{]}
+@opindex fdump-final-insns
+Dump the final internal representation (RTL) to @var{file}.  If the
+optional argument is omitted (or if @var{file} is @code{.}), the name
+of the dump file will be determined by appending @code{.gkd} to the
+compilation output file name.
 
 @item -fcompare-debug@r{[}=@var{opts}@r{]}
 @opindex fcompare-debug
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c.orig	2009-06-11 07:05:16.000000000 -0300
+++ gcc/toplev.c	2009-06-11 08:38:01.000000000 -0300
@@ -1874,7 +1874,7 @@ process_options (void)
 	debug_info_level = DINFO_LEVEL_NONE;
     }
 
-  if (flag_dump_final_insns)
+  if (flag_dump_final_insns && !flag_syntax_only && !no_backend)
     {
       FILE *final_output = fopen (flag_dump_final_insns, "w");
       if (!final_output)
-- 
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

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