1 # Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This file was written by Rob Savoye (rob@cygnus.com)
19 # Currently maintained by Doug Evans (dje@cygnus.com)
21 # This file is loaded by the tool init file (eg: unix.exp). It provides
22 # default definitions for objc_start, etc. and other supporting cast members.
24 # These globals are used by objc_start if no compiler arguments are provided.
25 # They are also used by the various testsuites to define the environment:
26 # where to find stdio.h, libc.a, etc.
29 # OBJC_UNDER_TEST is the compiler under test.
33 # default_objc_version -- extract and print the version number of the compiler
36 proc default_objc_version { } {
37 global OBJC_UNDER_TEST
41 # ignore any arguments after the command
42 set compiler [lindex $OBJC_UNDER_TEST 0]
44 if ![is_remote host] {
45 set compiler_name [which $compiler];
47 set compiler_name $compiler;
50 # verify that the compiler exists
51 if { $compiler_name != 0 } then {
52 set tmp [remote_exec host "$compiler -v"]
53 set status [lindex $tmp 0];
54 set output [lindex $tmp 1];
55 regexp "version.*$" $output version
56 if { $status == 0 && [info exists version] } then {
57 clone_output "$compiler_name $version\n"
59 clone_output "Couldn't determine version of $compiler_name: $output\n"
62 # compiler does not exist (this should have already been detected)
63 warning "$compiler does not exist"
68 # Call objc_version. We do it this way so we can override it if needed.
70 proc objc_version { } {
75 # objc_init -- called at the start of each .exp script.
77 # There currently isn't much to do, but always using it allows us to
78 # make some enhancements without having to go back and rewrite the scripts.
81 set objc_initialized 0
83 proc objc_init { args } {
86 global gluefile wrap_flags
87 global objc_initialized
88 global OBJC_UNDER_TEST
89 global TOOL_EXECUTABLE
91 if { $objc_initialized == 1 } { return; }
93 if ![info exists OBJC_UNDER_TEST] then {
94 if [info exists TOOL_EXECUTABLE] {
95 set OBJC_UNDER_TEST $TOOL_EXECUTABLE;
97 set OBJC_UNDER_TEST [find_gcc]
101 if ![info exists tmpdir] then {
104 if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } {
105 set gluefile ${tmpdir}/testglue.o;
106 set result [build_wrapper $gluefile];
107 if { $result != "" } {
108 set gluefile [lindex $result 0];
109 set wrap_flags [lindex $result 1];
116 proc objc_target_compile { source dest type options } {
119 global gluefile wrap_flags;
120 global OBJC_UNDER_TEST
122 global ld_library_path
124 set ld_library_path ".:${rootme}"
125 lappend options "libs=-lobjc"
127 if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
128 lappend options "libs=${gluefile}"
129 lappend options "ldflags=$wrap_flags"
132 if [target_info exists objc,stack_size] {
133 lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
135 if [target_info exists objc,no_trampolines] {
136 lappend options "additional_flags=-DNO_TRAMPOLINES"
138 if [target_info exists objc,no_label_values] {
139 lappend options "additional_flags=-DNO_LABEL_VALUES"
141 if [info exists TOOL_OPTIONS] {
142 lappend options "additional_flags=$TOOL_OPTIONS"
144 if [target_info exists objc,no_varargs] {
145 lappend options "additional_flags=-DNO_VARARGS"
147 set objcpath "[get_multilibs]"
148 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
149 if { $libobjc_dir != "" } {
150 set libobjc_dir [file dirname ${libobjc_dir}]
151 set objc_link_flags "-L${libobjc_dir}"
152 lappend options "additional_flags=${objc_link_flags}"
153 append ld_library_path ":${libobjc_dir}"
155 lappend options "compiler=$OBJC_UNDER_TEST"
156 return [target_compile $source $dest $type $options]
160 # objc_pass -- utility to record a testcase passed
163 proc objc_pass { testcase cflags } {
164 if { "$cflags" == "" } {
167 pass "$testcase, $cflags"
172 # objc_fail -- utility to record a testcase failed
175 proc objc_fail { testcase cflags } {
176 if { "$cflags" == "" } {
179 fail "$testcase, $cflags"
184 # objc_finish -- called at the end of every .exp script that calls objc_init
186 # The purpose of this proc is to hide all quirks of the testing environment
187 # from the testsuites. It also exists to undo anything that objc_init did
188 # (that needs undoing).
191 proc objc_finish { } {
192 # The testing harness apparently requires this.
195 if [info exists errorInfo] then {
199 # Might as well reset these (keeps our caller from wondering whether
200 # s/he has to or not).
201 global prms_id bug_id
209 if [info exists gluefile] {
210 file_on_build delete $gluefile;
215 # If this is an older version of dejagnu (without runtest_file_p),
216 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
217 # This can be deleted after next dejagnu release.
219 if { [info procs runtest_file_p] == "" } then {
220 proc runtest_file_p { runtests testcase } {
221 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
222 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
232 # Provide a definition of this if missing (delete after next dejagnu release).
234 if { [info procs prune_warnings] == "" } then {
235 proc prune_warnings { text } {
240 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
241 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
242 # (for the 64-bit ABI). The right way to do this would be to modify
243 # unix.exp -- but that's not an option since it's part of DejaGNU
244 # proper, so we do it here, by trickery. We really only need to do
245 # this on IRIX, but it shouldn't hurt to do it anywhere else.
247 proc ${tool}_set_ld_library_path { name element op } {
248 setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
249 setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
252 trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
254 # Utility used by mike-gcc.exp and c-torture.exp.
255 # Check the compiler(/assembler/linker) output for text indicating that
256 # the testcase should be marked as "unsupported".
258 # When dealing with a large number of tests, it's difficult to weed out the
259 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
260 # of memory). There are various ways to deal with this. Here's one.
261 # Fortunately, all of the cases where this is likely to happen will be using
262 # gld so we can tell what the error text will look like.
264 proc ${tool}_check_unsupported_p { output } {
265 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
271 # Prune messages from objc that aren't useful.
273 proc prune_objc_output { text } {
274 #send_user "Before:$text\n"
275 regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
276 regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
278 # It would be nice to avoid passing anything to objc that would cause it to
279 # issue these messages (since ignoring them seems like a hack on our part),
280 # but that's too difficult in the general case. For example, sometimes
281 # you need to use -B to point objc at crt0.o, but there are some targets
282 # that don't have crt0.o.
283 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
284 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
286 #send_user "After:$text\n"