* lib/objc.exp: Add -lposix4 on Solaris 2.8.
[official-gcc.git] / gcc / testsuite / lib / objc.exp
bloba2a3756f57ff8063a62e5eb9f31508b837de9ebc
1 # Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001 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.
7 #
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
38 objc_init;
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];
45 } else {
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"
57 } else {
58 clone_output "Couldn't determine version of $compiler_name: $output\n"
60 } else {
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 { } {
70 default_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 } {
83 global tmpdir
84 global libdir
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;
95 } else {
96 set OBJC_UNDER_TEST [find_gcc]
100 if ![info exists tmpdir] then {
101 set tmpdir /tmp
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];
109 } else {
110 unset gluefile
115 proc objc_target_compile { source dest type options } {
116 global tmpdir;
117 global gluefile wrap_flags;
118 global OBJC_UNDER_TEST
119 global TOOL_OPTIONS
120 global ld_library_path
122 set ld_library_path "."
123 lappend options "libs=-lobjc"
125 # On Solaris 2.8, we need to include libposix4 inorder to get
126 # sched_get_priority_max and such.
127 if [ishost "sparc-sun-solaris2.8"] {
128 lappend options "libs=-lposix4"
131 if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
132 lappend options "libs=${gluefile}"
133 lappend options "ldflags=$wrap_flags"
136 if [target_info exists objc,stack_size] {
137 lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
139 if [target_info exists objc,no_trampolines] {
140 lappend options "additional_flags=-DNO_TRAMPOLINES"
142 if [target_info exists objc,no_label_values] {
143 lappend options "additional_flags=-DNO_LABEL_VALUES"
145 if [info exists TOOL_OPTIONS] {
146 lappend options "additional_flags=$TOOL_OPTIONS"
148 if [target_info exists objc,no_varargs] {
149 lappend options "additional_flags=-DNO_VARARGS"
151 set objcpath "[get_multilibs]"
152 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
153 if { $libobjc_dir != "" } {
154 set libobjc_dir [file dirname ${libobjc_dir}]
155 set objc_link_flags "-L${libobjc_dir}"
156 lappend options "additional_flags=${objc_link_flags}"
157 append ld_library_path ":${libobjc_dir}"
159 lappend options "compiler=$OBJC_UNDER_TEST"
160 return [target_compile $source $dest $type $options]
164 # objc_pass -- utility to record a testcase passed
167 proc objc_pass { testcase cflags } {
168 if { "$cflags" == "" } {
169 pass "$testcase"
170 } else {
171 pass "$testcase, $cflags"
176 # objc_fail -- utility to record a testcase failed
179 proc objc_fail { testcase cflags } {
180 if { "$cflags" == "" } {
181 fail "$testcase"
182 } else {
183 fail "$testcase, $cflags"
188 # objc_finish -- called at the end of every .exp script that calls objc_init
190 # The purpose of this proc is to hide all quirks of the testing environment
191 # from the testsuites. It also exists to undo anything that objc_init did
192 # (that needs undoing).
195 proc objc_finish { } {
196 # The testing harness apparently requires this.
197 global errorInfo;
199 if [info exists errorInfo] then {
200 unset errorInfo
203 # Might as well reset these (keeps our caller from wondering whether
204 # s/he has to or not).
205 global prms_id bug_id
206 set prms_id 0
207 set bug_id 0
210 proc objc_exit { } {
211 global gluefile;
213 if [info exists gluefile] {
214 file_on_build delete $gluefile;
215 unset gluefile;
219 # If this is an older version of dejagnu (without runtest_file_p),
220 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
221 # This can be deleted after next dejagnu release.
223 if { [info procs runtest_file_p] == "" } then {
224 proc runtest_file_p { runtests testcase } {
225 if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
226 if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
227 return 1
228 } else {
229 return 0
232 return 1
236 # Provide a definition of this if missing (delete after next dejagnu release).
238 if { [info procs prune_warnings] == "" } then {
239 proc prune_warnings { text } {
240 return $text
244 # Utility used by mike-gcc.exp and c-torture.exp.
245 # Check the compiler(/assembler/linker) output for text indicating that
246 # the testcase should be marked as "unsupported".
248 # When dealing with a large number of tests, it's difficult to weed out the
249 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
250 # of memory). There are various ways to deal with this. Here's one.
251 # Fortunately, all of the cases where this is likely to happen will be using
252 # gld so we can tell what the error text will look like.
254 proc ${tool}_check_unsupported_p { output } {
255 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
256 return "memory full"
258 return ""
261 # Prune messages from objc that aren't useful.
263 proc prune_objc_output { text } {
264 #send_user "Before:$text\n"
265 regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
266 regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
268 # It would be nice to avoid passing anything to objc that would cause it to
269 # issue these messages (since ignoring them seems like a hack on our part),
270 # but that's too difficult in the general case. For example, sometimes
271 # you need to use -B to point objc at crt0.o, but there are some targets
272 # that don't have crt0.o.
273 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
274 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
276 #send_user "After:$text\n"
278 return $text