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]

PATCH: Compile testglue with -fexceptions


On systems where the exit code from a program cannot be directly
obtained, DejaGNU uses "testglue.c" to wrap "main" with a function
that prints the exit code.  On arm-none-eabi, in Thumb mode, two EH
tests were failing.  The cause turned out to be that those tests
depended on their being no handler for an exception, and, therefore,
std::terminate or the forced unwind handler being called, as the case
might be.  However, testglue.c was complied without -fexceptions, and
therefore there was no exception information for the oldest function
in the call stack, and disaster ensued.

I'm not sure why this only showed up in Thumb mode, or if similar
problems exist on other targets.  In any case, it seems clear that for
C++ tests, testglue.c should be compiled with -fexceptions.

Therefore, I plan to apply this patch in 24 hours, unless there are
objections.  I will also backport to the 4.1 and 4.2 branches.

Tested on arm-none-eabi.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2007-02-20  Mark Mitchell  <mark@codesourcery.com>

	* lib/wrapper.exp (${tool}_maybe_build_wrapper): Allow the caller
	to set options for compiling testglue.
	* lib/g++.exp (g++_init): Compile testglue with -fexceptions.
	* lib/obj-c++.exp (obj-c++_init): Likeiwse.

2007-02-20  Mark Mitchell  <mark@codesourcery.com>

	* testsuite/lib/libstdc++.exp (libstdc++_init): Compile testglue
	with -fexceptions.

Index: gcc/testsuite/lib/g++.exp
===================================================================
--- gcc/testsuite/lib/g++.exp	(revision 121831)
+++ gcc/testsuite/lib/g++.exp	(working copy)
@@ -221,7 +221,7 @@ proc g++_init { args } {
 	unset gluefile
     }
 
-    g++_maybe_build_wrapper "${tmpdir}/g++-testglue.o"
+    g++_maybe_build_wrapper "${tmpdir}/g++-testglue.o" "-fexceptions"
 
     if {![info exists CXXFLAGS]} {
 	set CXXFLAGS ""
Index: gcc/testsuite/lib/obj-c++.exp
===================================================================
--- gcc/testsuite/lib/obj-c++.exp	(revision 121831)
+++ gcc/testsuite/lib/obj-c++.exp	(working copy)
@@ -239,7 +239,7 @@ proc obj-c++_init { args } {
 	unset gluefile
     }
 
-    obj-c++_maybe_build_wrapper "${tmpdir}/obj-c++-testglue.o"
+    obj-c++_maybe_build_wrapper "${tmpdir}/obj-c++-testglue.o" "-fexceptions"
 
     set ALWAYS_OBJCXXFLAGS ""
 
Index: gcc/testsuite/lib/wrapper.exp
===================================================================
--- gcc/testsuite/lib/wrapper.exp	(revision 121831)
+++ gcc/testsuite/lib/wrapper.exp	(working copy)
@@ -18,18 +18,20 @@
 
 # ${tool}_maybe_build_wrapper -- Build wrapper object if the target needs it.
 
-proc ${tool}_maybe_build_wrapper { filename } {
+proc ${tool}_maybe_build_wrapper { filename args } {
     global gluefile wrap_flags
 
     if { [target_info needs_status_wrapper] != "" \
  	 && [target_info needs_status_wrapper] != "0" \
 	 && ![info exists gluefile] } {
 	set saved_wrap_compile_flags [target_info wrap_compile_flags]
+	set flags [join $args " "]
 	# The wrapper code may contain code that gcc objects on.  This
 	# became true for dejagnu-1.4.4.  The set of warnings and code
 	# that gcc objects on may change, so just make sure -w is always
 	# passed to turn off all warnings.
-	set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags -w"
+	set_currtarget_info wrap_compile_flags \
+	    "$saved_wrap_compile_flags -w $flags"
 	set result [build_wrapper $filename]
 	set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags"
 	if { $result != "" } {
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 121831)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -225,7 +225,7 @@ proc libstdc++_init { testfile } {
 	v3track PCH_CXXFLAGS 2
     }
 
-    libstdc++_maybe_build_wrapper "${objdir}/testglue.o"
+    libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
 }
 
 # Callback for cleanup routines.


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