1 # Copyright (C) 1992, 1993, 1994, 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 # This file was written by Rob Savoye (rob@cygnus.com)
18 # Currently maintained by Doug Evans (dje@cygnus.com)
20 # This file is loaded by the tool init file (eg: unix.exp). It provides
21 # default definitions for objc_start, etc. and other supporting cast members.
23 # These globals are used by objc_start if no compiler arguments are provided.
24 # They are also used by the various testsuites to define the environment:
25 # where to find stdio.h, libc.a, etc.
28 # OBJC_UNDER_TEST is the compiler under test.
32 # default_objc_version -- extract and print the version number of the compiler
35 proc default_objc_version { } {
36 global OBJC_UNDER_TEST
40 # ignore any arguments after the command
41 set compiler [lindex $OBJC_UNDER_TEST 0]
43 if ![is_remote host] {
44 set compiler_name [which $compiler];
46 set compiler_name $compiler;
49 # verify that the compiler exists
50 if { $compiler_name != 0 } then {
51 set tmp [remote_exec host "$compiler -v"]
52 set status [lindex $tmp 0];
53 set output [lindex $tmp 1];
54 regexp "version.*$" $output version
55 if { $status == 0 && [info exists version] } then {
56 clone_output "$compiler_name $version\n"
58 clone_output "Couldn't determine version of $compiler_name: $output\n"
61 # compiler does not exist (this should have already been detected)
62 warning "$compiler does not exist"
67 # Call objc_version. We do it this way so we can override it if needed.
69 proc objc_version { } {
74 # objc_init -- called at the start of each .exp script.
76 # There currently isn't much to do, but always using it allows us to
77 # make some enhancements without having to go back and rewrite the scripts.
80 set objc_initialized 0
82 proc objc_init { args } {
85 global gluefile wrap_flags
86 global objc_initialized
87 global OBJC_UNDER_TEST
88 global TOOL_EXECUTABLE
90 if { $objc_initialized == 1 } { return; }
92 if ![info exists OBJC_UNDER_TEST] then {
93 if [info exists TOOL_EXECUTABLE] {
94 set OBJC_UNDER_TEST $TOOL_EXECUTABLE;
96 set OBJC_UNDER_TEST [find_gcc]
100 if ![info exists tmpdir] then {
103 if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } {
104 set gluefile ${tmpdir}/testglue.o;
105 set result [build_wrapper $gluefile];
106 if { $result != "" } {
107 set gluefile [lindex $result 0];
108 set wrap_flags [lindex $result 1];
115 proc objc_target_compile { source dest type options } {
117 global gluefile wrap_flags;
118 global OBJC_UNDER_TEST
121 lappend options "libs=-lobjc"
122 if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
123 lappend options "libs=${gluefile}"
124 lappend options "ldflags=$wrap_flags"
127 if [target_info exists objc,stack_size] {
128 lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
130 if [target_info exists objc,no_trampolines] {
131 lappend options "additional_flags=-DNO_TRAMPOLINES"
133 if [target_info exists objc,no_label_values] {
134 lappend options "additional_flags=-DNO_LABEL_VALUES"
136 if [info exists TOOL_OPTIONS] {
137 lappend options "additional_flags=$TOOL_OPTIONS"
139 if [target_info exists objc,no_varargs] {
140 lappend options "additional_flags=-DNO_VARARGS"
142 lappend options "compiler=$OBJC_UNDER_TEST"
143 return [target_compile $source $dest $type $options]
147 # objc_pass -- utility to record a testcase passed
150 proc objc_pass { testcase cflags } {
151 if { "$cflags" == "" } {
154 pass "$testcase, $cflags"
159 # objc_fail -- utility to record a testcase failed
162 proc objc_fail { testcase cflags } {
163 if { "$cflags" == "" } {
166 fail "$testcase, $cflags"
171 # objc_finish -- called at the end of every .exp script that calls objc_init
173 # The purpose of this proc is to hide all quirks of the testing environment
174 # from the testsuites. It also exists to undo anything that objc_init did
175 # (that needs undoing).
178 proc objc_finish { } {
179 # The testing harness apparently requires this.
182 if [info exists errorInfo] then {
186 # Might as well reset these (keeps our caller from wondering whether
187 # s/he has to or not).
188 global prms_id bug_id
196 if [info exists gluefile] {
197 file_on_build delete $gluefile;
202 # If this is an older version of dejagnu (without runtest_file_p),
203 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
204 # This can be deleted after next dejagnu release.
206 if { [info procs runtest_file_p] == "" } then {
207 proc runtest_file_p { runtests testcase } {
208 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
209 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
219 # Provide a definition of this if missing (delete after next dejagnu release).
221 if { [info procs prune_warnings] == "" } then {
222 proc prune_warnings { text } {
227 # Utility used by mike-gcc.exp and c-torture.exp.
228 # Check the compiler(/assembler/linker) output for text indicating that
229 # the testcase should be marked as "unsupported".
231 # When dealing with a large number of tests, it's difficult to weed out the
232 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
233 # of memory). There are various ways to deal with this. Here's one.
234 # Fortunately, all of the cases where this is likely to happen will be using
235 # gld so we can tell what the error text will look like.
237 proc ${tool}_check_unsupported_p { output } {
238 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
244 # Prune messages from objc that aren't useful.
246 proc prune_objc_output { text } {
247 #send_user "Before:$text\n"
248 regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
249 regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
251 # It would be nice to avoid passing anything to objc that would cause it to
252 # issue these messages (since ignoring them seems like a hack on our part),
253 # but that's too difficult in the general case. For example, sometimes
254 # you need to use -B to point objc at crt0.o, but there are some targets
255 # that don't have crt0.o.
256 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
257 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
259 #send_user "After:$text\n"