1 |
12 |
jlechner |
# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004, 2005
|
2 |
|
|
# Free Software Foundation, Inc.
|
3 |
|
|
|
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.
|
8 |
|
|
#
|
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.
|
13 |
|
|
#
|
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
17 |
|
|
|
18 |
|
|
# This file was written by Rob Savoye (rob@cygnus.com)
|
19 |
|
|
# Currently maintained by Doug Evans (dje@cygnus.com)
|
20 |
|
|
|
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.
|
23 |
|
|
|
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.
|
27 |
|
|
|
28 |
|
|
load_lib libgloss.exp
|
29 |
|
|
load_lib prune.exp
|
30 |
|
|
load_lib gcc-defs.exp
|
31 |
|
|
load_lib target-libpath.exp
|
32 |
|
|
|
33 |
|
|
#
|
34 |
|
|
# OBJC_UNDER_TEST is the compiler under test.
|
35 |
|
|
#
|
36 |
|
|
|
37 |
|
|
#
|
38 |
|
|
# default_objc_version -- extract and print the version number of the compiler
|
39 |
|
|
#
|
40 |
|
|
|
41 |
|
|
proc default_objc_version { } {
|
42 |
|
|
global OBJC_UNDER_TEST
|
43 |
|
|
|
44 |
|
|
objc_init
|
45 |
|
|
|
46 |
|
|
# ignore any arguments after the command
|
47 |
|
|
set compiler [lindex $OBJC_UNDER_TEST 0]
|
48 |
|
|
|
49 |
|
|
if ![is_remote host] {
|
50 |
|
|
set compiler_name [which $compiler]
|
51 |
|
|
} else {
|
52 |
|
|
set compiler_name $compiler
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
# verify that the compiler exists
|
56 |
|
|
if { $compiler_name != 0 } then {
|
57 |
|
|
set tmp [remote_exec host "$compiler -v"]
|
58 |
|
|
set status [lindex $tmp 0]
|
59 |
|
|
set output [lindex $tmp 1]
|
60 |
|
|
regexp " version \[^\n\r\]*" $output version
|
61 |
|
|
if { $status == 0 && [info exists version] } then {
|
62 |
|
|
clone_output "$compiler_name $version\n"
|
63 |
|
|
} else {
|
64 |
|
|
clone_output "Couldn't determine version of $compiler_name: $output\n"
|
65 |
|
|
}
|
66 |
|
|
} else {
|
67 |
|
|
# compiler does not exist (this should have already been detected)
|
68 |
|
|
warning "$compiler does not exist"
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
#
|
73 |
|
|
# Call objc_version. We do it this way so we can override it if needed.
|
74 |
|
|
#
|
75 |
|
|
proc objc_version { } {
|
76 |
|
|
default_objc_version
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
#
|
80 |
|
|
# objc_init -- called at the start of each .exp script.
|
81 |
|
|
#
|
82 |
|
|
# There currently isn't much to do, but always using it allows us to
|
83 |
|
|
# make some enhancements without having to go back and rewrite the scripts.
|
84 |
|
|
#
|
85 |
|
|
|
86 |
|
|
set objc_initialized 0
|
87 |
|
|
|
88 |
|
|
proc objc_init { args } {
|
89 |
|
|
global rootme
|
90 |
|
|
global tmpdir
|
91 |
|
|
global libdir
|
92 |
|
|
global gluefile wrap_flags
|
93 |
|
|
global objc_initialized
|
94 |
|
|
global OBJC_UNDER_TEST
|
95 |
|
|
global TOOL_EXECUTABLE
|
96 |
|
|
global objc_libgcc_s_path
|
97 |
|
|
|
98 |
|
|
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
|
99 |
|
|
setenv LC_ALL C
|
100 |
|
|
setenv LANG C
|
101 |
|
|
|
102 |
|
|
if { $objc_initialized == 1 } { return; }
|
103 |
|
|
|
104 |
|
|
if ![info exists OBJC_UNDER_TEST] then {
|
105 |
|
|
if [info exists TOOL_EXECUTABLE] {
|
106 |
|
|
set OBJC_UNDER_TEST $TOOL_EXECUTABLE
|
107 |
|
|
} else {
|
108 |
|
|
set OBJC_UNDER_TEST [find_gcc]
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
if ![info exists tmpdir] then {
|
113 |
|
|
set tmpdir /tmp
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
|
117 |
|
|
|
118 |
|
|
append objc_libgcc_s_path [gcc-set-multilib-library-path $OBJC_UNDER_TEST]
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
proc objc_target_compile { source dest type options } {
|
122 |
|
|
global rootme
|
123 |
|
|
global tmpdir
|
124 |
|
|
global gluefile wrap_flags
|
125 |
|
|
global srcdir
|
126 |
|
|
global OBJC_UNDER_TEST
|
127 |
|
|
global TOOL_OPTIONS
|
128 |
|
|
global ld_library_path
|
129 |
|
|
global objc_libgcc_s_path
|
130 |
|
|
global shlib_ext
|
131 |
|
|
|
132 |
|
|
set ld_library_path ".:${objc_libgcc_s_path}"
|
133 |
|
|
lappend options "libs=-lobjc"
|
134 |
|
|
set shlib_ext [get_shlib_extension]
|
135 |
|
|
verbose "shared lib extension: $shlib_ext"
|
136 |
|
|
|
137 |
|
|
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
|
138 |
|
|
lappend options "libs=${gluefile}"
|
139 |
|
|
lappend options "ldflags=$wrap_flags"
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
if [target_info exists objc,stack_size] {
|
143 |
|
|
lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
|
144 |
|
|
}
|
145 |
|
|
if [target_info exists objc,no_trampolines] {
|
146 |
|
|
lappend options "additional_flags=-DNO_TRAMPOLINES"
|
147 |
|
|
}
|
148 |
|
|
if [target_info exists objc,no_label_values] {
|
149 |
|
|
lappend options "additional_flags=-DNO_LABEL_VALUES"
|
150 |
|
|
}
|
151 |
|
|
# TOOL_OPTIONS must come first, so that it doesn't override testcase
|
152 |
|
|
# specific options.
|
153 |
|
|
if [info exists TOOL_OPTIONS] {
|
154 |
|
|
set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
# If we have built libobjc along with the compiler (which usually
|
158 |
|
|
# _is not_ the case on Mac OS X systems), point the test harness
|
159 |
|
|
# at it (and associated headers).
|
160 |
|
|
|
161 |
|
|
set objcpath "[get_multilibs]"
|
162 |
|
|
|
163 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
|
164 |
|
|
if { $libobjc_dir == ""} {
|
165 |
|
|
verbose "see if we have -fgnu-runtime in options"
|
166 |
|
|
if [regexp ".*-fgnu-runtime.*" "${options}"] {
|
167 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
|
168 |
|
|
}
|
169 |
|
|
}
|
170 |
|
|
# Now check if we have a shared only build.
|
171 |
|
|
if { $libobjc_dir == ""} {
|
172 |
|
|
set libobjc_dir \
|
173 |
|
|
[lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
|
174 |
|
|
}
|
175 |
|
|
if { $libobjc_dir == ""} {
|
176 |
|
|
verbose "see if we have -fgnu-runtime in options"
|
177 |
|
|
if [regexp ".*-fgnu-runtime.*" "${options}"] {
|
178 |
|
|
set libobjc_dir \
|
179 |
|
|
[lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
if { $libobjc_dir != "" } {
|
183 |
|
|
set objc_include_dir "${srcdir}/../../libobjc"
|
184 |
|
|
lappend options "additional_flags=-I${objc_include_dir}"
|
185 |
|
|
set libobjc_dir [file dirname ${libobjc_dir}]
|
186 |
|
|
set objc_link_flags "-L${libobjc_dir}"
|
187 |
|
|
lappend options "additional_flags=${objc_link_flags}"
|
188 |
|
|
append ld_library_path ":${libobjc_dir}"
|
189 |
|
|
}
|
190 |
|
|
lappend options "compiler=$OBJC_UNDER_TEST"
|
191 |
|
|
|
192 |
|
|
set_ld_library_path_env_vars
|
193 |
|
|
|
194 |
|
|
return [target_compile $source $dest $type $options]
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
#
|
198 |
|
|
# objc_pass -- utility to record a testcase passed
|
199 |
|
|
#
|
200 |
|
|
|
201 |
|
|
proc objc_pass { testcase cflags } {
|
202 |
|
|
if { "$cflags" == "" } {
|
203 |
|
|
pass "$testcase"
|
204 |
|
|
} else {
|
205 |
|
|
pass "$testcase, $cflags"
|
206 |
|
|
}
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
#
|
210 |
|
|
# objc_fail -- utility to record a testcase failed
|
211 |
|
|
#
|
212 |
|
|
|
213 |
|
|
proc objc_fail { testcase cflags } {
|
214 |
|
|
if { "$cflags" == "" } {
|
215 |
|
|
fail "$testcase"
|
216 |
|
|
} else {
|
217 |
|
|
fail "$testcase, $cflags"
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
#
|
222 |
|
|
# objc_finish -- called at the end of every .exp script that calls objc_init
|
223 |
|
|
#
|
224 |
|
|
# The purpose of this proc is to hide all quirks of the testing environment
|
225 |
|
|
# from the testsuites. It also exists to undo anything that objc_init did
|
226 |
|
|
# (that needs undoing).
|
227 |
|
|
#
|
228 |
|
|
|
229 |
|
|
proc objc_finish { } {
|
230 |
|
|
# The testing harness apparently requires this.
|
231 |
|
|
global errorInfo
|
232 |
|
|
|
233 |
|
|
if [info exists errorInfo] then {
|
234 |
|
|
unset errorInfo
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
# Might as well reset these (keeps our caller from wondering whether
|
238 |
|
|
# s/he has to or not).
|
239 |
|
|
global prms_id bug_id
|
240 |
|
|
set prms_id 0
|
241 |
|
|
set bug_id 0
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
proc objc_exit { } {
|
245 |
|
|
global gluefile
|
246 |
|
|
|
247 |
|
|
if [info exists gluefile] {
|
248 |
|
|
file_on_build delete $gluefile
|
249 |
|
|
unset gluefile
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
# If this is an older version of dejagnu (without runtest_file_p),
|
254 |
|
|
# provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
|
255 |
|
|
# This can be deleted after next dejagnu release.
|
256 |
|
|
|
257 |
|
|
if { [info procs runtest_file_p] == "" } then {
|
258 |
|
|
proc runtest_file_p { runtests testcase } {
|
259 |
|
|
if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
|
260 |
|
|
if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
|
261 |
|
|
return 1
|
262 |
|
|
} else {
|
263 |
|
|
return 0
|
264 |
|
|
}
|
265 |
|
|
}
|
266 |
|
|
return 1
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
# Provide a definition of this if missing (delete after next dejagnu release).
|
271 |
|
|
|
272 |
|
|
if { [info procs prune_warnings] == "" } then {
|
273 |
|
|
proc prune_warnings { text } {
|
274 |
|
|
return $text
|
275 |
|
|
}
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
# Utility used by mike-gcc.exp and c-torture.exp.
|
279 |
|
|
# Check the compiler(/assembler/linker) output for text indicating that
|
280 |
|
|
# the testcase should be marked as "unsupported".
|
281 |
|
|
#
|
282 |
|
|
# When dealing with a large number of tests, it's difficult to weed out the
|
283 |
|
|
# ones that are too big for a particular cpu (eg: 16 bit with a small amount
|
284 |
|
|
# of memory). There are various ways to deal with this. Here's one.
|
285 |
|
|
# Fortunately, all of the cases where this is likely to happen will be using
|
286 |
|
|
# gld so we can tell what the error text will look like.
|
287 |
|
|
|
288 |
|
|
proc ${tool}_check_unsupported_p { output } {
|
289 |
|
|
if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
|
290 |
|
|
return "memory full"
|
291 |
|
|
}
|
292 |
|
|
return ""
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
# Prune messages from objc that aren't useful.
|
296 |
|
|
|
297 |
|
|
proc prune_objc_output { text } {
|
298 |
|
|
#send_user "Before:$text\n"
|
299 |
|
|
regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
|
300 |
|
|
regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
|
301 |
|
|
|
302 |
|
|
# It would be nice to avoid passing anything to objc that would cause it to
|
303 |
|
|
# issue these messages (since ignoring them seems like a hack on our part),
|
304 |
|
|
# but that's too difficult in the general case. For example, sometimes
|
305 |
|
|
# you need to use -B to point objc at crt0.o, but there are some targets
|
306 |
|
|
# that don't have crt0.o.
|
307 |
|
|
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
|
308 |
|
|
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
|
309 |
|
|
|
310 |
|
|
#send_user "After:$text\n"
|
311 |
|
|
|
312 |
|
|
return $text
|
313 |
|
|
}
|
314 |
|
|
|