1 # Copyright
(C
) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002
2 # Free Software Foundation
, Inc.
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.
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.
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.
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
>.
23 # g
++ support library routines
29 # GXX_UNDER_TEST is the compiler under test.
33 set gpp_compile_options
""
37 # g
++_version
-- extract and print the version number of the compiler
40 proc g
++_version
{ } {
45 # ignore
any arguments after the command
46 set compiler
[lindex $GXX_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.*$" $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 # g
++_include_flags
-- provide new version of g
++_include_flags
71 #
(originally from libgloss.exp
) which knows about the gcc tree structure
73 proc g
++_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
] } {
84 set dir [lookfor_file $
{srcdir
} libg
++]
86 append flags
"-I${dir} -I${dir}/src "
91 if { $
{HAVE_LIBSTDCXX_V3
} } {
92 set odir_v3
[lookfor_file $
{gccpath
} libstdc
++-v3
]
93 if { $
{odir_v3
} != "" } {
94 append flags
[exec sh $
{odir_v3
}/testsuite_flags
--build
-includes
]
97 set odir_v2
[lookfor_file $
{gccpath
} libstdc
++]
98 set sdir_v2
[lookfor_file $
{srcdir
} libstdc
++]
99 append flags
"-I${sdir_v2} -I${sdir_v2}/stl "
106 # g
++_link_flags
-- provide new version of g
++_link_flags
107 #
(originally from libgloss.exp
) which knows about the gcc tree structure
110 proc g
++_link_flags
{ paths
} {
113 global ld_library_path
114 global GXX_UNDER_TEST
119 set ld_library_path
"."
121 if { $gccpath
!= "" } {
122 if [file
exists "${gccpath}/lib/libstdc++.a"] {
123 append ld_library_path
":${gccpath}/lib"
125 if [file
exists "${gccpath}/libg++/libg++.a"] {
126 append flags
"-L${gccpath}/libg++ "
127 append ld_library_path
":${gccpath}/libg++"
129 if [file
exists "${gccpath}/libstdc++/libstdc++.a"] {
130 append flags
"-L${gccpath}/libstdc++ "
131 append ld_library_path
":${gccpath}/libstdc++"
133 if [file
exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
134 append flags
" -L${gccpath}/libstdc++-v3/src/.libs "
135 append ld_library_path
":${gccpath}/libstdc++-v3/src/.libs"
137 if [file
exists "${gccpath}/libiberty/libiberty.a"] {
138 append flags
"-L${gccpath}/libiberty "
140 if [file
exists "${gccpath}/librx/librx.a"] {
141 append flags
"-L${gccpath}/librx "
143 append ld_library_path
":${rootme}"
144 set compiler
[lindex $GXX_UNDER_TEST
0]
145 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
146 foreach i
"[exec $compiler --print-multi-lib]" {
148 regexp
-- "\[a-z0-9=/\.-\]*;" $i mldir
149 set mldir
[string trimright $mldir
"\;@"]
150 if { "$mldir" == "." } {
153 if { [llength
[glob
-nocomplain $
{rootme
}/$
{mldir
}/libgcc_s
*.so.
*]] == 1 } {
154 append ld_library_path
":${rootme}/${mldir}"
159 global tool_root_dir
;
161 set libgpp
[lookfor_file $
{tool_root_dir
} libg
++];
162 if { $libgpp
!= "" } {
163 append flags
"-L${libgpp} ";
164 append ld_library_path
":${libgpp}"
166 set libstdcpp
[lookfor_file $
{tool_root_dir
} libstdc
++];
167 if { $libstdcpp
!= "" } {
168 append flags
"-L${libstdcpp} ";
169 append ld_library_path
":${libstdcpp}"
171 set libiberty
[lookfor_file $
{tool_root_dir
} libiberty
];
172 if { $libiberty
!= "" } {
173 append flags
"-L${libiberty} ";
175 set librx
[lookfor_file $
{tool_root_dir
} librx
];
176 if { $librx
!= "" } {
177 append flags
"-L${librx} ";
181 #
On IRIX
6, we have to
set variables akin to LD_LIBRARY_PATH
, but
182 # called LD_LIBRARYN32_PATH
(for the N32 ABI
) and LD_LIBRARY64_PATH
183 #
(for the
64-bit ABI
). The right way to
do this would be to modify
184 # unix.exp
-- but that
's not an option since it's part of DejaGNU
185 # proper
, so we
do it here. We really only need to
do
186 # this
on IRIX
, but it shouldn
't hurt to do it anywhere else.
187 setenv LD_LIBRARY_PATH $ld_library_path
188 setenv SHLIB_PATH $ld_library_path
189 setenv LD_LIBRARYN32_PATH $ld_library_path
190 setenv LD_LIBRARY64_PATH $ld_library_path
196 # g++_init -- called at the start of each subdir of tests
199 proc g++_init { args } {
201 global gpp_initialized
205 global gluefile wrap_flags;
207 global ALWAYS_CXXFLAGS
208 global TOOL_EXECUTABLE TOOL_OPTIONS
209 global GXX_UNDER_TEST
210 global TESTING_IN_BUILD_TREE
212 if ![info exists GXX_UNDER_TEST] then {
213 if [info exists TOOL_EXECUTABLE] {
214 set GXX_UNDER_TEST $TOOL_EXECUTABLE;
216 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
217 set GXX_UNDER_TEST [transform c++]
219 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++]]]
224 # Bleah, nasty. Bad taste.
225 if [ishost "*-dos-*" ] {
226 regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
229 if ![is_remote host] {
230 if { [which $GXX_UNDER_TEST] == 0 } then {
231 perror "GXX_UNDER_TEST ($GXX_UNDER_TEST) does not exist"
235 if ![info exists tmpdir] {
239 if [info exists gluefile] {
243 if { [target_info needs_status_wrapper] != "" } {
244 set gluefile ${tmpdir}/g++-testglue.o;
245 set result [build_wrapper $gluefile];
246 if { $result != "" } {
247 set gluefile [lindex $result 0];
248 set wrap_flags [lindex $result 1];
254 set ALWAYS_CXXFLAGS ""
256 if ![is_remote host] {
257 if [info exists TOOL_OPTIONS] {
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}] ]";
261 lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs] ]";
262 lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs] ]";
266 if [info exists TOOL_OPTIONS] {
267 lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS";
270 # Make sure that lines are not wrapped. That can confuse the
271 # error-message parsing machinery.
272 lappend ALWAYS_CXXFLAGS "additional_flags=-fmessage-length=0"
274 verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
276 verbose "g++ is initialized" 3
280 # g++_target_compile -- compile a source file
283 proc g++_target_compile { source dest type options } {
285 global gpp_compile_options
286 global gluefile wrap_flags
287 global ALWAYS_CXXFLAGS;
288 global GXX_UNDER_TEST;
290 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
291 lappend options "libs=${gluefile}"
292 lappend options "ldflags=${wrap_flags}"
295 lappend options "additional_flags=[libio_include_flags]"
296 lappend options "compiler=$GXX_UNDER_TEST";
298 set options [concat $gpp_compile_options $options]
300 set options [concat "$ALWAYS_CXXFLAGS" $options];
302 if { [regexp "(^| )-frepo( |$)" $options] && \
303 [regexp "\.o(|bj)$" $dest] } then {
304 regsub "\.o(|bj)$" $dest ".rpo" rponame
308 return [target_compile $source $dest $type $options]
312 # ${tool}_option_help
315 proc ${tool}_option_help { } {
316 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
320 # ${tool}_option_proc
323 proc ${tool}_option_proc { option } {
324 if [regexp "^--additional_options," $option] {
325 global gpp_compile_options
326 regsub "--additional_options," $option "" option
327 foreach x [split $option ","] {
328 lappend gpp_compile_options "additional_flags=$x"