1 # Copyright
(C
) 2004, 2005, 2007, 2008 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
3 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 GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
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
<mrs@cygnus.com
>.
22 #
obj-c
++ support library routines
27 load_lib target
-libpath.exp
30 # OBJCXX_UNDER_TEST is the compiler under test.
34 set gpp_compile_options
""
37 #
obj-c
++_version
-- extract and print the version number of the compiler
40 proc
obj-c
++_version
{ } {
41 global OBJCXX_UNDER_TEST
45 # ignore
any arguments after the command
46 set compiler
[lindex $OBJCXX_UNDER_TEST
0]
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 {
56 clone_output
"$compiler $version\n"
58 clone_output
"[which $compiler] $version\n"
61 clone_output
"Couldn't determine version of [which $compiler]\n"
64 # compiler does not exist
(this should have already been detected
)
65 warning
"$compiler does not exist"
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
73 proc
obj-c
++_include_flags
{ paths
} {
75 global HAVE_LIBSTDCXX_V3
76 global TESTING_IN_BUILD_TREE
80 if { [is_remote host
] ||
! [info exists TESTING_IN_BUILD_TREE
] } {
86 set odir
[lookfor_file $
{gccpath
} libstdc
++-v3
]
87 if { $
{odir
} != "" } {
88 append flags
[exec sh $
{odir
}/scripts
/testsuite_flags
--build
-includes
]
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
99 proc
obj-c
++_link_flags
{ paths
} {
102 global ld_library_path
103 global OBJCXX_UNDER_TEST
109 set ld_library_path
"."
110 set shlib_ext
[get_shlib_extension
]
111 verbose
"shared lib extension: $shlib_ext"
113 if { $gccpath
!= "" } {
114 if [file
exists "${gccpath}/lib/libstdc++.a"] {
115 append ld_library_path
":${gccpath}/lib"
117 if [file
exists "${gccpath}/libg++/libg++.a"] {
118 append flags
"-L${gccpath}/libg++ "
119 append ld_library_path
":${gccpath}/libg++"
121 if [file
exists "${gccpath}/libstdc++/libstdc++.a"] {
122 append flags
"-L${gccpath}/libstdc++ "
123 append ld_library_path
":${gccpath}/libstdc++"
125 if [file
exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
126 append flags
" -L${gccpath}/libstdc++-v3/src/.libs "
127 append ld_library_path
":${gccpath}/libstdc++-v3/src/.libs"
129 # Look
for libstdc
++.$
{shlib_ext
}.
130 if [file
exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
131 append flags
" -L${gccpath}/libstdc++-v3/src/.libs "
132 append ld_library_path
":${gccpath}/libstdc++-v3/src/.libs"
134 if [file
exists "${gccpath}/libiberty/libiberty.a"] {
135 append flags
"-L${gccpath}/libiberty "
137 if [file
exists "${gccpath}/librx/librx.a"] {
138 append flags
"-L${gccpath}/librx "
141 set objcpath
"[get_multilibs]"
142 set libobjc_dir
[lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc.a
]
143 if { $libobjc_dir
== ""} {
144 set libobjc_dir
[lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc
-gnu.a
]
146 # Now check
if we have a shared only build.
147 if { $libobjc_dir
== ""} {
149 [lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc.$
{shlib_ext
}]
151 if { $libobjc_dir
== ""} {
153 [lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc
-gnu.$
{shlib_ext
}]
156 verbose
"libobjc_dir: $libobjc_dir"
158 if { $libobjc_dir
!= "" } {
159 set libobjc_dir
[file dirname $
{libobjc_dir
}]
160 append flags
"-L${libobjc_dir}"
161 append ld_library_path
":${libobjc_dir}"
163 append ld_library_path \
164 [gcc
-set-multilib
-library
-path $OBJCXX_UNDER_TEST
]
167 global tool_root_dir
;
169 set libgpp
[lookfor_file $
{tool_root_dir
} libg
++];
170 if { $libgpp
!= "" } {
171 append flags
"-L${libgpp} ";
172 append ld_library_path
":${libgpp}"
174 set libstdcpp
[lookfor_file $
{tool_root_dir
} libstdc
++];
175 if { $libstdcpp
!= "" } {
176 append flags
"-L${libstdcpp} ";
177 append ld_library_path
":${libstdcpp}"
179 set libiberty
[lookfor_file $
{tool_root_dir
} libiberty
];
180 if { $libiberty
!= "" } {
181 append flags
"-L${libiberty} ";
183 set librx
[lookfor_file $
{tool_root_dir
} librx
];
184 if { $librx
!= "" } {
185 append flags
"-L${librx} ";
189 set_ld_library_path_env_vars
195 #
obj-c
++_init
-- called at the start of each subdir of tests
198 proc
obj-c
++_init
{ args } {
200 global gpp_initialized
204 global gluefile wrap_flags
;
206 global ALWAYS_OBJCXXFLAGS
207 global TOOL_EXECUTABLE TOOL_OPTIONS
208 global OBJCXX_UNDER_TEST
209 global TESTING_IN_BUILD_TREE
210 global target_triplet
212 if ![info exists OBJCXX_UNDER_TEST
] then {
213 if [info exists TOOL_EXECUTABLE
] {
214 set OBJCXX_UNDER_TEST $TOOL_EXECUTABLE
;
216 if { [is_remote host
] ||
! [info exists TESTING_IN_BUILD_TREE
] } {
217 set OBJCXX_UNDER_TEST
[transform c
++]
219 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++]]]
224 # Bleah
, nasty. Bad taste.
225 if [ishost
"*-dos-*" ] {
226 regsub
"c\\+\\+" "$OBJCXX_UNDER_TEST" "gcc" OBJCXX_UNDER_TEST
229 if ![is_remote host
] {
230 if { [which $OBJCXX_UNDER_TEST
] == 0 } then {
231 perror
"OBJCXX_UNDER_TEST ($OBJCXX_UNDER_TEST) does not exist"
235 if ![info exists tmpdir
] {
239 if [info exists gluefile
] {
243 obj-c
++_maybe_build_wrapper
"${tmpdir}/obj-c++-testglue.o" "-fexceptions"
245 set ALWAYS_OBJCXXFLAGS
""
247 if ![is_remote host
] {
248 if [info exists TOOL_OPTIONS
] {
249 lappend ALWAYS_OBJCXXFLAGS
"additional_flags=[obj-c++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]";
250 lappend ALWAYS_OBJCXXFLAGS
"ldflags=[obj-c++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
252 lappend ALWAYS_OBJCXXFLAGS
"additional_flags=[obj-c++_include_flags [get_multilibs] ]";
253 lappend ALWAYS_OBJCXXFLAGS
"ldflags=[obj-c++_link_flags [get_multilibs] ]";
257 if [info exists TOOL_OPTIONS
] {
258 lappend ALWAYS_OBJCXXFLAGS
"additional_flags=$TOOL_OPTIONS";
261 # Make sure that lines are not wrapped. That can confuse the
262 # error
-message parsing machinery.
263 lappend ALWAYS_OBJCXXFLAGS
"additional_flags=-fmessage-length=0"
265 if { [string match
"*-*-darwin*" $target_triplet] } {
266 lappend ALWAYS_OBJCXXFLAGS
"ldflags=-multiply_defined suppress"
269 verbose
-log "ALWAYS_OBJCXXFLAGS set to $ALWAYS_OBJCXXFLAGS"
271 verbose
"obj-c++ is initialized" 3
275 #
obj-c
++_target_compile
-- compile a source file
278 proc
obj-c
++_target_compile
{ source dest type options
} {
281 global gpp_compile_options
282 global gluefile wrap_flags
283 global ALWAYS_OBJCXXFLAGS
284 global OBJCXX_UNDER_TEST
287 lappend options
"libs=-lobjc"
288 set shlib_ext
[get_shlib_extension
]
289 verbose
"shared lib extension: $shlib_ext"
291 if { [target_info needs_status_wrapper
] != "" && [info exists gluefile] } {
292 lappend options
"libs=${gluefile}"
293 lappend options
"ldflags=${wrap_flags}"
296 #
If we have built libobjc along with the compiler
(which usually
297 # _is not_ the case
on Mac OS X systems
), point the test harness
298 # at it
(and associated headers
).
300 set objcpath
"[get_multilibs]"
302 set libobjc_dir
[lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc.a
]
303 if { $libobjc_dir
== ""} {
304 verbose
"see if we have -fgnu-runtime in options"
305 if [regexp
".*-fgnu-runtime.*" "${options}" ] {
306 set libobjc_dir
[lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc
-gnu.a
]
309 if { $libobjc_dir
== ""} {
311 [lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc.$
{shlib_ext
}]
313 if { $libobjc_dir
== ""} {
314 verbose
"see if we have -fgnu-runtime in options"
315 if [regexp
".*-fgnu-runtime.*" "${options}"] {
317 [lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc
-gnu.$
{shlib_ext
}]
321 if { $libobjc_dir
!= "" } {
322 set objc_include_dir
"${srcdir}/../../libobjc"
323 lappend options
"additional_flags=-I${objc_include_dir}"
326 lappend options
"additional_flags=[libio_include_flags]"
327 lappend options
"compiler=$OBJCXX_UNDER_TEST";
328 lappend options
"timeout=[timeout_value]"
330 set options
[concat $gpp_compile_options $options
]
332 set options
[concat
"$ALWAYS_OBJCXXFLAGS" $options];
334 if { [regexp
"(^| )-frepo( |$)" $options] && \
335 [regexp
"\.o(|bj)$" $dest] } then {
336 regsub
"\.o(|bj)$" $dest ".rpo" rponame
340 set options
[dg
-additional
-files
-options $options $source
]
342 set result
[target_compile $source $dest $type $options
]
348 # $
{tool
}_option_help
351 proc $
{tool
}_option_help
{ } {
352 send_user
" --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
356 # $
{tool
}_option_proc
359 proc $
{tool
}_option_proc
{ option
} {
360 if [regexp
"^--additional_options," $option] {
361 global gpp_compile_options
362 regsub
"--additional_options," $option "" option
363 foreach x
[split $option
","] {
364 lappend gpp_compile_options
"additional_flags=$x"