1 |
306 |
jeremybenn |
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
2 |
|
|
|
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 3 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.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with GCC; see the file COPYING3. If not see
|
15 |
|
|
# .
|
16 |
|
|
|
17 |
|
|
# This file was written by Rob Savoye (rob@cygnus.com)
|
18 |
|
|
# Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
|
19 |
|
|
# With modifications by Mike Stump .
|
20 |
|
|
|
21 |
|
|
#
|
22 |
|
|
# obj-c++ support library routines
|
23 |
|
|
#
|
24 |
|
|
load_lib prune.exp
|
25 |
|
|
load_lib gcc-defs.exp
|
26 |
|
|
load_lib timeout.exp
|
27 |
|
|
load_lib target-libpath.exp
|
28 |
|
|
|
29 |
|
|
#
|
30 |
|
|
# OBJCXX_UNDER_TEST is the compiler under test.
|
31 |
|
|
#
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
set gpp_compile_options ""
|
35 |
|
|
|
36 |
|
|
#
|
37 |
|
|
# obj-c++_version -- extract and print the version number of the compiler
|
38 |
|
|
#
|
39 |
|
|
|
40 |
|
|
proc obj-c++_version { } {
|
41 |
|
|
global OBJCXX_UNDER_TEST
|
42 |
|
|
|
43 |
|
|
obj-c++_init
|
44 |
|
|
|
45 |
|
|
# Ignore any arguments after the command.
|
46 |
|
|
set compiler [lindex $OBJCXX_UNDER_TEST 0]
|
47 |
|
|
|
48 |
|
|
# Verify that the compiler exists.
|
49 |
|
|
if { [is_remote host] || [which $compiler] != 0 } then {
|
50 |
|
|
set tmp [remote_exec host "$compiler -v"]
|
51 |
|
|
set status [lindex $tmp 0];
|
52 |
|
|
set output [lindex $tmp 1];
|
53 |
|
|
regexp " version \[^\n\r\]*" $output version
|
54 |
|
|
if { $status == 0 && [info exists version] } then {
|
55 |
|
|
if [is_remote host] {
|
56 |
|
|
clone_output "$compiler $version\n"
|
57 |
|
|
} else {
|
58 |
|
|
clone_output "[which $compiler] $version\n"
|
59 |
|
|
}
|
60 |
|
|
} else {
|
61 |
|
|
clone_output "Couldn't determine version of [which $compiler]\n"
|
62 |
|
|
}
|
63 |
|
|
} else {
|
64 |
|
|
# Compiler does not exist (this should have already been detected)
|
65 |
|
|
warning "$compiler does not exist"
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
#
|
70 |
|
|
# obj-c++_include_flags -- provide new version of obj-c++_include_flags
|
71 |
|
|
# (originally from libgloss.exp) which knows about the gcc tree structure
|
72 |
|
|
#
|
73 |
|
|
proc obj-c++_include_flags { paths } {
|
74 |
|
|
global srcdir
|
75 |
|
|
global HAVE_LIBSTDCXX_V3
|
76 |
|
|
global TESTING_IN_BUILD_TREE
|
77 |
|
|
|
78 |
|
|
set flags ""
|
79 |
|
|
|
80 |
|
|
if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
|
81 |
|
|
return "${flags}"
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
set gccpath ${paths}
|
85 |
|
|
|
86 |
|
|
set odir [lookfor_file ${gccpath} libstdc++-v3]
|
87 |
|
|
if { ${odir} != "" } {
|
88 |
|
|
append flags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
return "$flags"
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
#
|
95 |
|
|
# obj-c++_link_flags -- provide new version of obj-c++_link_flags
|
96 |
|
|
# (originally from libgloss.exp) which knows about the gcc tree structure.
|
97 |
|
|
#
|
98 |
|
|
|
99 |
|
|
proc obj-c++_link_flags { paths } {
|
100 |
|
|
global rootme
|
101 |
|
|
global srcdir
|
102 |
|
|
global ld_library_path
|
103 |
|
|
global OBJCXX_UNDER_TEST
|
104 |
|
|
global shlib_ext
|
105 |
|
|
|
106 |
|
|
set gccpath ${paths}
|
107 |
|
|
set libio_dir ""
|
108 |
|
|
set flags ""
|
109 |
|
|
set ld_library_path "."
|
110 |
|
|
set shlib_ext [get_shlib_extension]
|
111 |
|
|
verbose "shared lib extension: $shlib_ext"
|
112 |
|
|
|
113 |
|
|
if { $gccpath != "" } {
|
114 |
|
|
if [file exists "${gccpath}/lib/libstdc++.a"] {
|
115 |
|
|
append ld_library_path ":${gccpath}/lib"
|
116 |
|
|
}
|
117 |
|
|
if [file exists "${gccpath}/libg++/libg++.a"] {
|
118 |
|
|
append flags " -L${gccpath}/libg++ "
|
119 |
|
|
append ld_library_path ":${gccpath}/libg++"
|
120 |
|
|
}
|
121 |
|
|
if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
|
122 |
|
|
append flags " -L${gccpath}/libstdc++ "
|
123 |
|
|
append ld_library_path ":${gccpath}/libstdc++"
|
124 |
|
|
}
|
125 |
|
|
if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
|
126 |
|
|
# Allow for %s spec substitutions
|
127 |
|
|
append flags " -B${gccpath}/libstdc++-v3/src/.libs "
|
128 |
|
|
append flags " -L${gccpath}/libstdc++-v3/src/.libs "
|
129 |
|
|
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
|
130 |
|
|
}
|
131 |
|
|
# Look for libstdc++.${shlib_ext}.
|
132 |
|
|
if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
|
133 |
|
|
# Allow for %s spec substitutions
|
134 |
|
|
append flags " -B${gccpath}/libstdc++-v3/src/.libs "
|
135 |
|
|
append flags " -L${gccpath}/libstdc++-v3/src/.libs "
|
136 |
|
|
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
|
137 |
|
|
}
|
138 |
|
|
if [file exists "${gccpath}/libiberty/libiberty.a"] {
|
139 |
|
|
append flags " -L${gccpath}/libiberty "
|
140 |
|
|
}
|
141 |
|
|
if [file exists "${gccpath}/librx/librx.a"] {
|
142 |
|
|
append flags " -L${gccpath}/librx "
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
set objcpath "[get_multilibs]"
|
146 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
|
147 |
|
|
if { $libobjc_dir == ""} {
|
148 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
|
149 |
|
|
}
|
150 |
|
|
# Now check if we have a shared only build.
|
151 |
|
|
if { $libobjc_dir == ""} {
|
152 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
|
153 |
|
|
if { $libobjc_dir == ""} {
|
154 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
verbose "libobjc_dir: $libobjc_dir"
|
159 |
|
|
|
160 |
|
|
if { $libobjc_dir != "" } {
|
161 |
|
|
set libobjc_dir [file dirname ${libobjc_dir}]
|
162 |
|
|
# Allow for %s spec substitutions
|
163 |
|
|
append flags " -B${libobjc_dir} "
|
164 |
|
|
append flags " -L${libobjc_dir} "
|
165 |
|
|
append ld_library_path ":${libobjc_dir}"
|
166 |
|
|
}
|
167 |
|
|
append ld_library_path \
|
168 |
|
|
[gcc-set-multilib-library-path $OBJCXX_UNDER_TEST]
|
169 |
|
|
} else {
|
170 |
|
|
global tool_root_dir;
|
171 |
|
|
|
172 |
|
|
set libgpp [lookfor_file ${tool_root_dir} libg++];
|
173 |
|
|
if { $libgpp != "" } {
|
174 |
|
|
append flags "-L${libgpp} ";
|
175 |
|
|
append ld_library_path ":${libgpp}"
|
176 |
|
|
}
|
177 |
|
|
set libstdcpp [lookfor_file ${tool_root_dir} libstdc++];
|
178 |
|
|
if { $libstdcpp != "" } {
|
179 |
|
|
append flags "-L${libstdcpp} ";
|
180 |
|
|
append ld_library_path ":${libstdcpp}"
|
181 |
|
|
}
|
182 |
|
|
set libiberty [lookfor_file ${tool_root_dir} libiberty];
|
183 |
|
|
if { $libiberty != "" } {
|
184 |
|
|
append flags "-L${libiberty} ";
|
185 |
|
|
}
|
186 |
|
|
set librx [lookfor_file ${tool_root_dir} librx];
|
187 |
|
|
if { $librx != "" } {
|
188 |
|
|
append flags "-L${librx} ";
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
set_ld_library_path_env_vars
|
193 |
|
|
|
194 |
|
|
return "$flags"
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
#
|
198 |
|
|
# obj-c++_init -- called at the start of each subdir of tests
|
199 |
|
|
#
|
200 |
|
|
|
201 |
|
|
proc obj-c++_init { args } {
|
202 |
|
|
global subdir
|
203 |
|
|
global gpp_initialized
|
204 |
|
|
global base_dir
|
205 |
|
|
global tmpdir
|
206 |
|
|
global libdir
|
207 |
|
|
global gluefile wrap_flags;
|
208 |
|
|
global objdir srcdir
|
209 |
|
|
global ALWAYS_OBJCXXFLAGS
|
210 |
|
|
global TOOL_EXECUTABLE TOOL_OPTIONS
|
211 |
|
|
global OBJCXX_UNDER_TEST
|
212 |
|
|
global TESTING_IN_BUILD_TREE
|
213 |
|
|
global target_triplet
|
214 |
|
|
|
215 |
|
|
if ![info exists OBJCXX_UNDER_TEST] then {
|
216 |
|
|
if [info exists TOOL_EXECUTABLE] {
|
217 |
|
|
set OBJCXX_UNDER_TEST $TOOL_EXECUTABLE;
|
218 |
|
|
} else {
|
219 |
|
|
if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
|
220 |
|
|
set OBJCXX_UNDER_TEST [transform c++]
|
221 |
|
|
} else {
|
222 |
|
|
set OBJCXX_UNDER_TEST [findfile $base_dir/../../g++ "$base_dir/../../g++ -B$base_dir/../../" [findfile $base_dir/g++ "$base_dir/g++ -B$base_dir/" [transform c++]]]
|
223 |
|
|
}
|
224 |
|
|
}
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
# Bleah, nasty. Bad taste.
|
228 |
|
|
if [ishost "*-dos-*" ] {
|
229 |
|
|
regsub "c\\+\\+" "$OBJCXX_UNDER_TEST" "gcc" OBJCXX_UNDER_TEST
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
if ![is_remote host] {
|
233 |
|
|
if { [which $OBJCXX_UNDER_TEST] == 0 } then {
|
234 |
|
|
perror "OBJCXX_UNDER_TEST ($OBJCXX_UNDER_TEST) does not exist"
|
235 |
|
|
exit 1
|
236 |
|
|
}
|
237 |
|
|
}
|
238 |
|
|
if ![info exists tmpdir] {
|
239 |
|
|
set tmpdir "/tmp"
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
if [info exists gluefile] {
|
243 |
|
|
unset gluefile
|
244 |
|
|
}
|
245 |
|
|
|
246 |
|
|
obj-c++_maybe_build_wrapper "${tmpdir}/obj-c++-testglue.o" "-fexceptions"
|
247 |
|
|
|
248 |
|
|
set ALWAYS_OBJCXXFLAGS ""
|
249 |
|
|
|
250 |
|
|
if ![is_remote host] {
|
251 |
|
|
if [info exists TOOL_OPTIONS] {
|
252 |
|
|
lappend ALWAYS_OBJCXXFLAGS "additional_flags=[obj-c++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]";
|
253 |
|
|
lappend ALWAYS_OBJCXXFLAGS "ldflags=[obj-c++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
|
254 |
|
|
} else {
|
255 |
|
|
lappend ALWAYS_OBJCXXFLAGS "additional_flags=[obj-c++_include_flags [get_multilibs] ]";
|
256 |
|
|
lappend ALWAYS_OBJCXXFLAGS "ldflags=[obj-c++_link_flags [get_multilibs] ]";
|
257 |
|
|
}
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
if [info exists TOOL_OPTIONS] {
|
261 |
|
|
lappend ALWAYS_OBJCXXFLAGS "additional_flags=$TOOL_OPTIONS";
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
# Make sure that lines are not wrapped. That can confuse the
|
265 |
|
|
# error-message parsing machinery.
|
266 |
|
|
lappend ALWAYS_OBJCXXFLAGS "additional_flags=-fmessage-length=0"
|
267 |
|
|
|
268 |
|
|
if { [string match "*-*-darwin*" $target_triplet] } {
|
269 |
|
|
lappend ALWAYS_OBJCXXFLAGS "ldflags=-multiply_defined suppress"
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
verbose -log "ALWAYS_OBJCXXFLAGS set to $ALWAYS_OBJCXXFLAGS"
|
273 |
|
|
|
274 |
|
|
verbose "obj-c++ is initialized" 3
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
#
|
278 |
|
|
# obj-c++_target_compile -- compile a source file
|
279 |
|
|
#
|
280 |
|
|
|
281 |
|
|
proc obj-c++_target_compile { source dest type options } {
|
282 |
|
|
global tmpdir
|
283 |
|
|
global srcdir
|
284 |
|
|
global gpp_compile_options
|
285 |
|
|
global gluefile wrap_flags
|
286 |
|
|
global ALWAYS_OBJCXXFLAGS
|
287 |
|
|
global OBJCXX_UNDER_TEST
|
288 |
|
|
global shlib_ext
|
289 |
|
|
|
290 |
|
|
set shlib_ext [get_shlib_extension]
|
291 |
|
|
verbose "input-options: $options" 4
|
292 |
|
|
|
293 |
|
|
# We have to figure out which runtime will be used on darwin because
|
294 |
|
|
# we need to add the include path for the gnu runtime if that is in
|
295 |
|
|
# use.
|
296 |
|
|
# First, set the default...
|
297 |
|
|
if { [istarget "*-*-darwin*"] } {
|
298 |
|
|
set nextruntime 1
|
299 |
|
|
} else {
|
300 |
|
|
set nextruntime 0
|
301 |
|
|
}
|
302 |
|
|
verbose "initial next runtime state : $nextruntime" 2
|
303 |
|
|
# Next, see if we define the option in dg-options...
|
304 |
|
|
foreach opt $options {
|
305 |
|
|
if [regexp ".*-fnext-runtime.*" $opt] {
|
306 |
|
|
set nextruntime 1
|
307 |
|
|
}
|
308 |
|
|
if [regexp ".*-fgnu-runtime.*" $opt] {
|
309 |
|
|
set nextruntime 0
|
310 |
|
|
}
|
311 |
|
|
}
|
312 |
|
|
verbose "next runtime state after dg opts: $nextruntime" 2
|
313 |
|
|
|
314 |
|
|
set tgt [target_info name]
|
315 |
|
|
if [board_info $tgt exists multilib_flags] {
|
316 |
|
|
set lb [board_info $tgt multilib_flags]
|
317 |
|
|
verbose "board multilib_flags $lb" 2
|
318 |
|
|
foreach opt $lb {
|
319 |
|
|
if [regexp ".*-fnext-runtime.*" $opt] {
|
320 |
|
|
set nextruntime 1
|
321 |
|
|
}
|
322 |
|
|
if [regexp ".*-fgnu-runtime.*" $opt] {
|
323 |
|
|
set nextruntime 0
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
}
|
327 |
|
|
verbose "next runtime state after any multilib opts: $nextruntime" 2
|
328 |
|
|
|
329 |
|
|
lappend options "libs=-lobjc"
|
330 |
|
|
|
331 |
|
|
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
|
332 |
|
|
lappend options "libs=${gluefile}"
|
333 |
|
|
lappend options "ldflags=${wrap_flags}"
|
334 |
|
|
}
|
335 |
|
|
|
336 |
|
|
# If we have built libobjc along with the compiler, point the test harness
|
337 |
|
|
# at it (and associated headers).
|
338 |
|
|
|
339 |
|
|
set objcpath "[get_multilibs]"
|
340 |
|
|
|
341 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
|
342 |
|
|
if { $libobjc_dir == ""} {
|
343 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
|
344 |
|
|
}
|
345 |
|
|
if { $libobjc_dir == ""} {
|
346 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
|
347 |
|
|
if { $libobjc_dir == ""} {
|
348 |
|
|
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
if { $libobjc_dir != "" } {
|
353 |
|
|
# If we are using the gnu runtime, add its includes.
|
354 |
|
|
if { $nextruntime == 0 } {
|
355 |
|
|
set objc_include_dir "${srcdir}/../../libobjc"
|
356 |
|
|
lappend options "additional_flags=-I${objc_include_dir}"
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
lappend options "additional_flags=[libio_include_flags]"
|
361 |
|
|
lappend options "compiler=$OBJCXX_UNDER_TEST";
|
362 |
|
|
lappend options "timeout=[timeout_value]"
|
363 |
|
|
|
364 |
|
|
set options [concat $gpp_compile_options $options]
|
365 |
|
|
|
366 |
|
|
set options [concat "$ALWAYS_OBJCXXFLAGS" $options];
|
367 |
|
|
|
368 |
|
|
if { [regexp "(^| )-frepo( |$)" $options] && \
|
369 |
|
|
[regexp "\.o(|bj)$" $dest] } then {
|
370 |
|
|
regsub "\.o(|bj)$" $dest ".rpo" rponame
|
371 |
|
|
exec rm -f $rponame
|
372 |
|
|
}
|
373 |
|
|
|
374 |
|
|
set options [dg-additional-files-options $options $source]
|
375 |
|
|
|
376 |
|
|
set result [target_compile $source $dest $type $options]
|
377 |
|
|
|
378 |
|
|
return $result
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
#
|
382 |
|
|
# ${tool}_option_help
|
383 |
|
|
#
|
384 |
|
|
|
385 |
|
|
proc ${tool}_option_help { } {
|
386 |
|
|
send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
|
387 |
|
|
}
|
388 |
|
|
|
389 |
|
|
#
|
390 |
|
|
# ${tool}_option_proc
|
391 |
|
|
#
|
392 |
|
|
|
393 |
|
|
proc ${tool}_option_proc { option } {
|
394 |
|
|
if [regexp "^--additional_options," $option] {
|
395 |
|
|
global gpp_compile_options
|
396 |
|
|
regsub "--additional_options," $option "" option
|
397 |
|
|
foreach x [split $option ","] {
|
398 |
|
|
lappend gpp_compile_options "additional_flags=$x"
|
399 |
|
|
}
|
400 |
|
|
return 1;
|
401 |
|
|
} else {
|
402 |
|
|
return 0
|
403 |
|
|
}
|
404 |
|
|
}
|