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]

V3 PATCH: Use PCH when testing installed compilers


This patch causes the libstdc++ testsuite to pass "-include
stdc++.pch" to an installed compiler, when appropriate.  (At present,
there is an inconsistency between installed and build-tree testing;
build-tree testing will use PCH while installed testing will not.)

As previously requested, this patch makes it possible to control the
PCH flags via site.exp.

I did not remove the --cxxpchflags option to testsuite_flags (which
would allow the removal of a few bits of autoconf hair as well)
because check_performance and check_compile still use that.  However,
I'm happy to remove --cxxpchflags as well, and follow through the
resulting cleanups, if that would be preferred. 

OK?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-05-26  Mark Mitchell  <mark@codesourcery.com>

	* docs/html/test.html: Mention PCH_CXXFLAGS.
	* testsuite/lib/libstdc++.exp: Set PCH_CXXFLAGS by probing for an
	available stcd++.h PCH.
	* testsuite/libstdc++-dg/normal.exp: Use PCH_CXXFLAGS.

Index: docs/html/test.html
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/test.html,v
retrieving revision 1.11
diff -c -5 -p -r1.11 test.html
*** docs/html/test.html	5 May 2005 03:57:28 -0000	1.11
--- docs/html/test.html	26 May 2005 21:12:09 -0000
*************** Example 4: Testing for compilation error
*** 425,436 ****
  // { dg-do compile }
  // { dg-error "no match for" "" { target *-*-* } 41 }
  
  Example 5: Testing with special command line settings, or without the
  use of pre-compiled headers, in particular the stdc++.h.gch file. Any
! options here will override the DEFAULT_CXXFLAGS set up in the
! normal.exp file.
  // { dg-options "-O0" { target *-*-* } }
  </pre>
  
     <p>
      More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.
--- 425,436 ----
  // { dg-do compile }
  // { dg-error "no match for" "" { target *-*-* } 41 }
  
  Example 5: Testing with special command line settings, or without the
  use of pre-compiled headers, in particular the stdc++.h.gch file. Any
! options here will override the DEFAULT_CXXFLAGS and PCH_CXXFLAGS set
! up in the normal.exp file.
  // { dg-options "-O0" { target *-*-* } }
  </pre>
  
     <p>
      More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.
Index: testsuite/lib/libstdc++.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/lib/libstdc++.exp,v
retrieving revision 1.40
diff -c -5 -p -r1.40 libstdc++.exp
*** testsuite/lib/libstdc++.exp	18 May 2005 08:07:32 -0000	1.40
--- testsuite/lib/libstdc++.exp	26 May 2005 21:12:10 -0000
*************** proc libstdc++_init { testfile } {
*** 101,118 ****
      #   2) might need to be negated 
      # In particular, some tests have to be run without precompiled
      # headers, or without assertions.
      global DEFAULT_CXXFLAGS
      if ![info exists DEFAULT_CXXFLAGS] then {
! 	# Set up includes for stdc++.h.gch, the precompiled header file.
! 	if { [file exists $flags_file] } {
! 	    set cxxpchflags [exec sh $flags_file --cxxpchflags]
! 	} else {
! 	    set cxxpchflags ""
! 	}
! 	set DEFAULT_CXXFLAGS " ${cxxpchflags}"
! 
  	# Host specific goo here.
  	if { [string match "powerpc-*-darwin*" $target_triplet] } {
  	    append DEFAULT_CXXFLAGS " -multiply_defined suppress"
  	} 
      }
--- 101,111 ----
      #   2) might need to be negated 
      # In particular, some tests have to be run without precompiled
      # headers, or without assertions.
      global DEFAULT_CXXFLAGS
      if ![info exists DEFAULT_CXXFLAGS] then {
! 	set DEFAULT_CXXFLAGS ""
  	# Host specific goo here.
  	if { [string match "powerpc-*-darwin*" $target_triplet] } {
  	    append DEFAULT_CXXFLAGS " -multiply_defined suppress"
  	} 
      }
*************** proc libstdc++_init { testfile } {
*** 193,202 ****
--- 186,217 ----
  	    }
  	    set cxxflags "$cxxflags -DLOCALEDIR=\"$localedir\""
          }
      }
  
+     # If a PCH file is available, use it.  We must delay performing
+     # this check until $cxx and such have been initialized because we
+     # perform a test compilation.  (Ideally, gcc --print-file-name would
+     # list PCH files, but it does not.)
+     global PCH_CXXFLAGS
+     if ![info exists PCH_CXXFLAGS] then {
+ 	set src "config[pid].cc"
+ 	set f [open $src "w"]
+ 	puts $f "int main () {}"
+ 	close $f
+ 
+ 	set lines [v3_target_compile $src "config[pid].o" object \
+ 		   "additional_flags=-include additional_flags=bits/stdc++.h"]
+ 	if {$lines == "" } {
+ 	    set PCH_CXXFLAGS "-include bits/stdc++.h"
+ 	} else {
+ 	    set PCH_CXXFLAGS ""
+ 	}
+ 	file delete $src
+ 	v3track PCH_CXXFLAGS 2
+     }
+ 
      libstdc++_maybe_build_wrapper "${objdir}/testglue.o"
  }
  
  # Callback for cleanup routines.
  proc libstdc++_exit { } {
Index: testsuite/libstdc++-dg/normal.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/libstdc++-dg/normal.exp,v
retrieving revision 1.7
diff -c -5 -p -r1.7 normal.exp
*** testsuite/libstdc++-dg/normal.exp	24 Mar 2005 04:26:30 -0000	1.7
--- testsuite/libstdc++-dg/normal.exp	26 May 2005 21:12:10 -0000
*************** if {[info exists tests_file] && [file ex
*** 85,93 ****
  }
  set tests [lsort $tests]
  
  # Main loop.
  global DEFAULT_CXXFLAGS
! dg-runtest $tests "" $DEFAULT_CXXFLAGS
  
  # All done.
  dg-finish
--- 85,94 ----
  }
  set tests [lsort $tests]
  
  # Main loop.
  global DEFAULT_CXXFLAGS
! global PCH_CXXFLAGS
! dg-runtest $tests "" "$DEFAULT_CXXFLAGS $PCH_CXXFLAGS"
  
  # All done.
  dg-finish


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