]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/lib/g++.exp
re PR other/18138 (libgcc_s.so.1 not found by 64-bit testsuite)
[thirdparty/gcc.git] / gcc / testsuite / lib / g++.exp
CommitLineData
8800e533 1# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004
2937267b 2# Free Software Foundation, Inc.
921e5a0e
JL
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
921e5a0e
JL
18# This file was written by Rob Savoye (rob@cygnus.com)
19# Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
20# With modifications by Mike Stump <mrs@cygnus.com>.
21
22#
23# g++ support library routines
24#
a4d81081 25load_lib prune.exp
62ba5f39 26load_lib gcc-defs.exp
921e5a0e
JL
27
28#
29# GXX_UNDER_TEST is the compiler under test.
30#
31
32
33set gpp_compile_options ""
62ba5f39 34
921e5a0e
JL
35#
36# g++_version -- extract and print the version number of the compiler
37#
62ba5f39 38
921e5a0e
JL
39proc g++_version { } {
40 global GXX_UNDER_TEST
41
62ba5f39
SC
42 g++_init
43
921e5a0e
JL
44 # ignore any arguments after the command
45 set compiler [lindex $GXX_UNDER_TEST 0]
46
47 # verify that the compiler exists
48 if { [is_remote host] || [which $compiler] != 0 } then {
49 set tmp [remote_exec host "$compiler -v"]
50 set status [lindex $tmp 0];
51 set output [lindex $tmp 1];
fb0737c2 52 regexp " version \[^\n\r\]*" $output version
921e5a0e
JL
53 if { $status == 0 && [info exists version] } then {
54 if [is_remote host] {
55 clone_output "$compiler $version\n"
56 } else {
57 clone_output "[which $compiler] $version\n"
58 }
59 } else {
60 clone_output "Couldn't determine version of [which $compiler]\n"
61 }
62 } else {
63 # compiler does not exist (this should have already been detected)
64 warning "$compiler does not exist"
65 }
66}
67
1c7781fb 68#
62ba5f39
SC
69# g++_include_flags -- provide new version of g++_include_flags
70# (originally from libgloss.exp) which knows about the gcc tree structure
1c7781fb 71#
6bdfaf09 72proc g++_include_flags { paths } {
1c7781fb 73 global srcdir
be5aeb60 74 global HAVE_LIBSTDCXX_V3
4091fa5f 75 global TESTING_IN_BUILD_TREE
be5aeb60
MM
76
77 set flags ""
1c7781fb 78
4091fa5f 79 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
be5aeb60 80 return "${flags}"
1c7781fb
L
81 }
82
6bdfaf09 83 set gccpath ${paths}
be5aeb60 84
7dfa28ba
BK
85 set odir [lookfor_file ${gccpath} libstdc++-v3]
86 if { ${odir} != "" } {
87 append flags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
1c7781fb
L
88 }
89
1c7781fb
L
90 return "$flags"
91}
92
62ba5f39
SC
93#
94# g++_link_flags -- provide new version of g++_link_flags
95# (originally from libgloss.exp) which knows about the gcc tree structure
96#
97
6bdfaf09 98proc g++_link_flags { paths } {
049f6ec9 99 global rootme
1c7781fb
L
100 global srcdir
101 global ld_library_path
2937267b 102 global GXX_UNDER_TEST
1c7781fb 103
6bdfaf09 104 set gccpath ${paths}
1c7781fb
L
105 set libio_dir ""
106 set flags ""
107 set ld_library_path "."
108
109 if { $gccpath != "" } {
110 if [file exists "${gccpath}/lib/libstdc++.a"] {
111 append ld_library_path ":${gccpath}/lib"
112 }
113 if [file exists "${gccpath}/libg++/libg++.a"] {
114 append flags "-L${gccpath}/libg++ "
115 append ld_library_path ":${gccpath}/libg++"
116 }
117 if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
118 append flags "-L${gccpath}/libstdc++ "
119 append ld_library_path ":${gccpath}/libstdc++"
120 }
121 if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
122 append flags " -L${gccpath}/libstdc++-v3/src/.libs "
123 append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
124 }
125 if [file exists "${gccpath}/libiberty/libiberty.a"] {
126 append flags "-L${gccpath}/libiberty "
127 }
128 if [file exists "${gccpath}/librx/librx.a"] {
129 append flags "-L${gccpath}/librx "
130 }
049f6ec9 131 append ld_library_path ":${rootme}"
2937267b
JJ
132 set compiler [lindex $GXX_UNDER_TEST 0]
133 if { [is_remote host] == 0 && [which $compiler] != 0 } {
134 foreach i "[exec $compiler --print-multi-lib]" {
135 set mldir ""
136 regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
137 set mldir [string trimright $mldir "\;@"]
138 if { "$mldir" == "." } {
139 continue
140 }
1e02510f 141 if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
2937267b
JJ
142 append ld_library_path ":${rootme}/${mldir}"
143 }
144 }
145 }
1c7781fb
L
146 } else {
147 global tool_root_dir;
148
149 set libgpp [lookfor_file ${tool_root_dir} libg++];
150 if { $libgpp != "" } {
151 append flags "-L${libgpp} ";
152 append ld_library_path ":${libgpp}"
153 }
154 set libstdcpp [lookfor_file ${tool_root_dir} libstdc++];
155 if { $libstdcpp != "" } {
156 append flags "-L${libstdcpp} ";
157 append ld_library_path ":${libstdcpp}"
158 }
159 set libiberty [lookfor_file ${tool_root_dir} libiberty];
160 if { $libiberty != "" } {
161 append flags "-L${libiberty} ";
162 }
163 set librx [lookfor_file ${tool_root_dir} librx];
164 if { $librx != "" } {
165 append flags "-L${librx} ";
166 }
167 }
12c3717e
DB
168
169 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
170 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
171 # (for the 64-bit ABI). The right way to do this would be to modify
172 # unix.exp -- but that's not an option since it's part of DejaGNU
3a1cac0f
AT
173 # proper, so we do it here.
174 # The same applies to Darwin (DYLD_LIBRARY_PATH), Solaris 32 bit
175 # (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64), and HP-UX
176 # (SHLIB_PATH).
d11994a8
SB
177 # Doing this does cause trouble when testing cross-compilers.
178 if {![is_remote target]} {
dab8eb57 179 global env;
3a15f566
RS
180 if [info exists env(LD_LIBRARY_PATH)] {
181 # If we've already added these directories once, keep the
182 # existing path.
183 if {$ld_library_path == $env(LD_LIBRARY_PATH)
184 || [string first $ld_library_path: \
185 $env(LD_LIBRARY_PATH)] == 0} {
186 set ld_library_path $env(LD_LIBRARY_PATH)
187 } elseif { $env(LD_LIBRARY_PATH) != "" } {
188 append ld_library_path ":$env(LD_LIBRARY_PATH)"
189 }
dab8eb57 190 }
d11994a8
SB
191 setenv LD_LIBRARY_PATH $ld_library_path
192 setenv SHLIB_PATH $ld_library_path
193 setenv LD_LIBRARYN32_PATH $ld_library_path
194 setenv LD_LIBRARY64_PATH $ld_library_path
3a1cac0f
AT
195 setenv LD_LIBRARY_PATH_32 $ld_library_path
196 setenv LD_LIBRARY_PATH_64 $ld_library_path
d11994a8
SB
197 setenv DYLD_LIBRARY_PATH $ld_library_path
198 }
12c3717e 199
1c7781fb
L
200 return "$flags"
201}
202
921e5a0e
JL
203#
204# g++_init -- called at the start of each subdir of tests
205#
206
207proc g++_init { args } {
208 global subdir
209 global gpp_initialized
210 global base_dir
211 global tmpdir
212 global libdir
213 global gluefile wrap_flags;
214 global objdir srcdir
215 global ALWAYS_CXXFLAGS
216 global TOOL_EXECUTABLE TOOL_OPTIONS
217 global GXX_UNDER_TEST
4091fa5f 218 global TESTING_IN_BUILD_TREE
5153e857 219 global target_triplet
921e5a0e
JL
220
221 if ![info exists GXX_UNDER_TEST] then {
222 if [info exists TOOL_EXECUTABLE] {
223 set GXX_UNDER_TEST $TOOL_EXECUTABLE;
224 } else {
4091fa5f 225 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
921e5a0e
JL
226 set GXX_UNDER_TEST [transform c++]
227 } else {
7a53e94b 228 set GXX_UNDER_TEST [findfile $base_dir/../g++ "$base_dir/../g++ -B$base_dir/../" [findfile $base_dir/g++ "$base_dir/g++ -B$base_dir/" [transform c++]]]
921e5a0e
JL
229 }
230 }
231 }
232
233 # Bleah, nasty. Bad taste.
234 if [ishost "*-dos-*" ] {
235 regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
236 }
237
238 if ![is_remote host] {
239 if { [which $GXX_UNDER_TEST] == 0 } then {
7a53e94b 240 perror "GXX_UNDER_TEST ($GXX_UNDER_TEST) does not exist"
921e5a0e
JL
241 exit 1
242 }
243 }
244 if ![info exists tmpdir] {
245 set tmpdir "/tmp"
246 }
247
248 if [info exists gluefile] {
249 unset gluefile
250 }
251
8800e533 252 g++_maybe_build_wrapper "${tmpdir}/g++-testglue.o"
921e5a0e
JL
253
254 set ALWAYS_CXXFLAGS ""
255
256 if ![is_remote host] {
1ec07597 257 if [info exists TOOL_OPTIONS] {
6bdfaf09
JO
258 lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]";
259 lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
1ec07597 260 } else {
6bdfaf09
JO
261 lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs] ]";
262 lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs] ]";
1ec07597 263 }
921e5a0e
JL
264 }
265
266 if [info exists TOOL_OPTIONS] {
267 lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS";
268 }
269
44399cac
MM
270 # Make sure that lines are not wrapped. That can confuse the
271 # error-message parsing machinery.
602b1b13 272 lappend ALWAYS_CXXFLAGS "additional_flags=-fmessage-length=0"
44399cac 273
5153e857
AT
274 if { [string match "powerpc-*-darwin*" $target_triplet] } {
275 lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
276 }
277
921e5a0e
JL
278 verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
279
280 verbose "g++ is initialized" 3
281}
282
62ba5f39
SC
283#
284# g++_target_compile -- compile a source file
285#
921e5a0e
JL
286
287proc g++_target_compile { source dest type options } {
288 global tmpdir;
289 global gpp_compile_options
290 global gluefile wrap_flags
291 global ALWAYS_CXXFLAGS;
292 global GXX_UNDER_TEST;
293
294 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
295 lappend options "libs=${gluefile}"
296 lappend options "ldflags=${wrap_flags}"
297 }
298
299 lappend options "additional_flags=[libio_include_flags]"
300 lappend options "compiler=$GXX_UNDER_TEST";
301
602b1b13 302 set options [concat $gpp_compile_options $options]
921e5a0e 303
602b1b13 304 set options [concat "$ALWAYS_CXXFLAGS" $options];
921e5a0e 305
16fe4796
AO
306 if { [regexp "(^| )-frepo( |$)" $options] && \
307 [regexp "\.o(|bj)$" $dest] } then {
308 regsub "\.o(|bj)$" $dest ".rpo" rponame
309 exec rm -f $rponame
310 }
311
b4e0fcc3 312 set options [dg-additional-files-options $options $source]
6481daa9
MM
313
314 set result [target_compile $source $dest $type $options]
315
6481daa9 316 return $result
921e5a0e
JL
317}
318
921e5a0e 319#
62ba5f39
SC
320# ${tool}_option_help
321#
921e5a0e
JL
322
323proc ${tool}_option_help { } {
62ba5f39 324 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
921e5a0e
JL
325}
326
62ba5f39
SC
327#
328# ${tool}_option_proc
329#
330
921e5a0e 331proc ${tool}_option_proc { option } {
7a53e94b 332 if [regexp "^--additional_options," $option] {
921e5a0e
JL
333 global gpp_compile_options
334 regsub "--additional_options," $option "" option
335 foreach x [split $option ","] {
336 lappend gpp_compile_options "additional_flags=$x"
337 }
338 return 1;
339 } else {
340 return 0
341 }
342}