1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-g++@prep.ai.mit.edu
20 # This file was written by Rob Savoye (rob@cygnus.com)
21 # Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
22 # With modifications by Mike Stump <mrs@cygnus.com>.
25 # g++ support library routines
29 # GXX_UNDER_TEST is the compiler under test.
33 set gpp_compile_options ""
36 # g++_version -- extract and print the version number of the compiler
38 proc g++_version { } {
41 # ignore any arguments after the command
42 set compiler [lindex $GXX_UNDER_TEST 0]
44 # verify that the compiler exists
45 if { [is_remote host] || [which $compiler] != 0 } then {
46 set tmp [remote_exec host "$compiler -v"]
47 set status [lindex $tmp 0];
48 set output [lindex $tmp 1];
49 regexp "version.*$" $output version
50 if { $status == 0 && [info exists version] } then {
52 clone_output "$compiler $version\n"
54 clone_output "[which $compiler] $version\n"
57 clone_output "Couldn't determine version of [which $compiler]\n"
60 # compiler does not exist (this should have already been detected)
61 warning "$compiler does not exist"
66 # g++_init -- called at the start of each subdir of tests
69 proc g++_init { args } {
71 global gpp_initialized
75 global gluefile wrap_flags;
77 global ALWAYS_CXXFLAGS
78 global TOOL_EXECUTABLE TOOL_OPTIONS
81 if ![info exists GXX_UNDER_TEST] then {
82 if [info exists TOOL_EXECUTABLE] {
83 set GXX_UNDER_TEST $TOOL_EXECUTABLE;
86 set GXX_UNDER_TEST [transform c++]
88 set GXX_UNDER_TEST [findfile $base_dir/../xgcc "$base_dir/../xgcc -B$base_dir/../" [transform c++]]
93 # Bleah, nasty. Bad taste.
94 if [ishost "*-dos-*" ] {
95 regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
98 if ![is_remote host] {
99 if { [which $GXX_UNDER_TEST] == 0 } then {
100 perror "GXX_UNDER_TEST does not exist"
104 if ![info exists tmpdir] {
108 if [info exists gluefile] {
112 if { [target_info needs_status_wrapper] != "" } {
113 set gluefile ${tmpdir}/testglue.o;
114 set result [build_wrapper $gluefile];
115 if { $result != "" } {
116 set gluefile [lindex $result 0];
117 set wrap_flags [lindex $result 1];
123 set ALWAYS_CXXFLAGS ""
125 if ![is_remote host] {
126 lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags]";
127 lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags]";
128 lappend ALWAYS_CXXFLAGS "incdir=$base_dir/../include"
131 if [info exists TOOL_OPTIONS] {
132 lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS";
135 verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
137 verbose "g++ is initialized" 3
141 proc g++_target_compile { source dest type options } {
143 global gpp_compile_options
144 global gluefile wrap_flags
145 global ALWAYS_CXXFLAGS;
146 global GXX_UNDER_TEST;
148 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
149 lappend options "libs=${gluefile}"
150 lappend options "ldflags=${wrap_flags}"
153 lappend options "additional_flags=[libio_include_flags]"
154 lappend options "compiler=$GXX_UNDER_TEST";
156 set options [concat $options $gpp_compile_options]
158 set options [concat $options "$ALWAYS_CXXFLAGS"];
160 return [target_compile $source $dest $type $options]
163 proc g++_exit { args } {
166 if [info exists gluefile] {
167 file_on_build delete $gluefile;
172 # If this is an older version of dejagnu (without runtest_file_p),
173 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
174 # This can be deleted after the next dejagnu release.
176 if { [info procs runtest_file_p] == "" } then {
177 proc runtest_file_p { runtests testcase } {
178 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
179 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
189 # Provide a definition of this if missing (delete after next dejagnu release).
191 if { [info procs prune_warnings] == "" } then {
192 proc prune_warnings { text } {
197 # Utility used by mike-g++.exp and old-dejagnu.exp.
198 # Check the compiler(/assembler/linker) output for text indicating that
199 # the testcase should be marked as "unsupported".
201 # When dealing with a large number of tests, it's difficult to weed out the
202 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
203 # of memory). There are various ways to deal with this. Here's one.
204 # Fortunately, all of the cases where this is likely to happen will be using
205 # gld so we can tell what the error text will look like.
207 proc ${tool}_check_unsupported_p { output } {
208 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
214 proc ${tool}_option_help { } {
215 send_user "--additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated."
218 proc ${tool}_option_proc { option } {
219 if[regexp "^--additional_options," $option] {
220 global gpp_compile_options
221 regsub "--additional_options," $option "" option
222 foreach x [split $option ","] {
223 lappend gpp_compile_options "additional_flags=$x"