OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [lib/] [g++.exp] - Blame information for rev 310

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 306 jeremybenn
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
2
# 2004, 2005, 2007, 2008 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 3 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 GCC; see the file COPYING3.  If not see
16
# .
17
 
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 .
21
 
22
#
23
# g++ support library routines
24
#
25
load_lib prune.exp
26
load_lib gcc-defs.exp
27
load_lib timeout.exp
28
load_lib target-libpath.exp
29
 
30
#
31
# GXX_UNDER_TEST is the compiler under test.
32
#
33
 
34
 
35
set gpp_compile_options ""
36
 
37
#
38
# g++_version -- extract and print the version number of the compiler
39
#
40
 
41
proc g++_version { } {
42
    global GXX_UNDER_TEST
43
 
44
    g++_init
45
 
46
    # ignore any arguments after the command
47
    set compiler [lindex $GXX_UNDER_TEST 0]
48
 
49
    # verify that the compiler exists
50
    if { [is_remote host] || [which $compiler] != 0 } then {
51
        set tmp [remote_exec host "$compiler -v"]
52
        set status [lindex $tmp 0]
53
        set output [lindex $tmp 1]
54
        regexp " version \[^\n\r\]*" $output version
55
        if { $status == 0 && [info exists version] } then {
56
            if [is_remote host] {
57
                clone_output "$compiler $version\n"
58
            } else {
59
                clone_output "[which $compiler] $version\n"
60
            }
61
        } else {
62
            clone_output "Couldn't determine version of [which $compiler]\n"
63
        }
64
    } else {
65
        # compiler does not exist (this should have already been detected)
66
        warning "$compiler does not exist"
67
    }
68
}
69
 
70
#
71
# g++_include_flags -- provide new version of g++_include_flags
72
# (originally from libgloss.exp) which knows about the gcc tree structure
73
#
74
proc g++_include_flags { paths } {
75
    global srcdir
76
    global HAVE_LIBSTDCXX_V3
77
    global TESTING_IN_BUILD_TREE
78
 
79
    set flags ""
80
 
81
    if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
82
      return "${flags}"
83
    }
84
 
85
    set gccpath ${paths}
86
 
87
    set odir [lookfor_file ${gccpath} libstdc++-v3]
88
    if { ${odir} != "" } {
89
      append flags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
90
    }
91
 
92
    return "$flags"
93
}
94
 
95
#
96
# g++_link_flags -- provide new version of g++_link_flags
97
# (originally from libgloss.exp) which knows about the gcc tree structure
98
#
99
 
100
proc g++_link_flags { paths } {
101
    global srcdir
102
    global ld_library_path
103
    global GXX_UNDER_TEST
104
    global shlib_ext
105
 
106
    set gccpath ${paths}
107
    set libio_dir ""
108
    set flags ""
109
    set ld_library_path "."
110
 
111
    set shlib_ext [get_shlib_extension]
112
    verbose "shared lib extension: $shlib_ext"
113
 
114
    if { $gccpath != "" } {
115
      if [file exists "${gccpath}/lib/libstdc++.a"] {
116
          append ld_library_path ":${gccpath}/lib"
117
      }
118
      if [file exists "${gccpath}/libg++/libg++.a"] {
119
          append flags "-L${gccpath}/libg++ "
120
          append ld_library_path ":${gccpath}/libg++"
121
      }
122
      if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
123
          append flags "-L${gccpath}/libstdc++ "
124
          append ld_library_path ":${gccpath}/libstdc++"
125
      }
126
      if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
127
          append flags " -L${gccpath}/libstdc++-v3/src/.libs "
128
          # Some targets use libstdc++.a%s in their specs, so they need a
129
          # -B option for uninstalled testing.
130
          append flags " -B${gccpath}/libstdc++-v3/src/.libs "
131
          append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
132
      }
133
      # Look for libstdc++.${shlib_ext}.
134
      if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
135
          append flags " -L${gccpath}/libstdc++-v3/src/.libs "
136
          append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
137
      }
138
 
139
      if [file exists "${gccpath}/libiberty/libiberty.a"] {
140
          append flags "-L${gccpath}/libiberty "
141
      }
142
      if [file exists "${gccpath}/librx/librx.a"] {
143
          append flags "-L${gccpath}/librx "
144
      }
145
      append ld_library_path [gcc-set-multilib-library-path $GXX_UNDER_TEST]
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
    }
168
 
169
    set_ld_library_path_env_vars
170
 
171
    return "$flags"
172
}
173
 
174
#
175
# g++_init -- called at the start of each subdir of tests
176
#
177
 
178
proc g++_init { args } {
179
    global subdir
180
    global gpp_initialized
181
    global base_dir
182
    global tmpdir
183
    global libdir
184
    global gluefile wrap_flags
185
    global objdir srcdir
186
    global ALWAYS_CXXFLAGS
187
    global CXXFLAGS
188
    global TOOL_EXECUTABLE TOOL_OPTIONS
189
    global GXX_UNDER_TEST
190
    global TESTING_IN_BUILD_TREE
191
    global target_triplet
192
    global gcc_warning_prefix
193
    global gcc_error_prefix
194
 
195
    # We set LC_ALL and LANG to C so that we get the same error messages as expected.
196
    setenv LC_ALL C
197
    setenv LANG C
198
 
199
    # Many hosts now default to a non-ASCII C locale, however, so
200
    # they can set a charset encoding here if they need.
201
    if { [ishost "*-*-cygwin*"] } {
202
      setenv LC_ALL C.ASCII
203
      setenv LANG C.ASCII
204
    }
205
 
206
    if ![info exists GXX_UNDER_TEST] then {
207
        if [info exists TOOL_EXECUTABLE] {
208
            set GXX_UNDER_TEST $TOOL_EXECUTABLE
209
        } else {
210
            if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
211
                set GXX_UNDER_TEST [transform c++]
212
            } else {
213
                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++]]]
214
            }
215
        }
216
    }
217
 
218
    # Bleah, nasty. Bad taste.
219
    if [ishost "*-dos-*" ] {
220
        regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
221
    }
222
 
223
    if ![is_remote host] {
224
        if { [which $GXX_UNDER_TEST] == 0 } then {
225
            perror "GXX_UNDER_TEST ($GXX_UNDER_TEST) does not exist"
226
            exit 1
227
        }
228
    }
229
    if ![info exists tmpdir] {
230
        set tmpdir "/tmp"
231
    }
232
 
233
    if [info exists gluefile] {
234
        unset gluefile
235
    }
236
 
237
    g++_maybe_build_wrapper "${tmpdir}/g++-testglue.o" "-fexceptions"
238
 
239
    if {![info exists CXXFLAGS]} {
240
        set CXXFLAGS ""
241
    }
242
 
243
    set ALWAYS_CXXFLAGS ""
244
 
245
    if ![is_remote host] {
246
        if [info exists TOOL_OPTIONS] {
247
            lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
248
            lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
249
        } else {
250
            lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs] ]"
251
            lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs] ]"
252
        }
253
    }
254
 
255
    if [info exists TOOL_OPTIONS] {
256
        lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS"
257
    }
258
 
259
    # Make sure that lines are not wrapped.  That can confuse the
260
    # error-message parsing machinery.
261
    lappend ALWAYS_CXXFLAGS "additional_flags=-fmessage-length=0"
262
 
263
    set gcc_warning_prefix "warning:"
264
    set gcc_error_prefix "error:"
265
 
266
    if { [string match "*-*-darwin*" $target_triplet] } {
267
        lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
268
       }
269
 
270
    verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
271
 
272
    verbose "g++ is initialized" 3
273
}
274
 
275
#
276
# g++_target_compile -- compile a source file
277
#
278
 
279
proc g++_target_compile { source dest type options } {
280
    global tmpdir
281
    global gpp_compile_options
282
    global gluefile wrap_flags
283
    global ALWAYS_CXXFLAGS
284
    global GXX_UNDER_TEST
285
 
286
    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
287
        lappend options "libs=${gluefile}"
288
        lappend options "ldflags=${wrap_flags}"
289
    }
290
 
291
    lappend options "additional_flags=[libio_include_flags]"
292
    lappend options "compiler=$GXX_UNDER_TEST"
293
    lappend options "timeout=[timeout_value]"
294
 
295
    set options [concat $gpp_compile_options $options]
296
 
297
    set options [concat "$ALWAYS_CXXFLAGS" $options]
298
 
299
    if { [regexp "(^| )-frepo( |$)" $options] && \
300
         [regexp "\.o(|bj)$" $dest] } then {
301
        regsub "\.o(|bj)$" $dest ".rpo" rponame
302
        exec rm -f $rponame
303
    }
304
 
305
    set options [dg-additional-files-options $options $source]
306
 
307
    set result [target_compile $source $dest $type $options]
308
 
309
    return $result
310
}
311
 
312
#
313
# ${tool}_option_help
314
#
315
 
316
proc ${tool}_option_help { } {
317
    send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
318
}
319
 
320
#
321
# ${tool}_option_proc
322
#
323
 
324
proc ${tool}_option_proc { option } {
325
    if [regexp "^--additional_options," $option] {
326
        global gpp_compile_options
327
        regsub "--additional_options," $option "" option
328
        foreach x [split $option ","] {
329
            lappend gpp_compile_options "additional_flags=$x"
330
        }
331
        return 1
332
    } else {
333
        return 0
334
    }
335
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.