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

Subversion Repositories openrisc_me

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

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

Line No. Rev Author Line
1 149 jeremybenn
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
2
# 2004, 2005, 2007 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 target-libpath.exp
28
 
29
#
30
# GXX_UNDER_TEST is the compiler under test.
31
#
32
 
33
 
34
set gpp_compile_options ""
35
 
36
#
37
# g++_version -- extract and print the version number of the compiler
38
#
39
 
40
proc g++_version { } {
41
    global GXX_UNDER_TEST
42
 
43
    g++_init
44
 
45
    # ignore any arguments after the command
46
    set compiler [lindex $GXX_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
# g++_include_flags -- provide new version of g++_include_flags
71
# (originally from libgloss.exp) which knows about the gcc tree structure
72
#
73
proc g++_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
# g++_link_flags -- provide new version of g++_link_flags
96
# (originally from libgloss.exp) which knows about the gcc tree structure
97
#
98
 
99
proc g++_link_flags { paths } {
100
    global srcdir
101
    global ld_library_path
102
    global GXX_UNDER_TEST
103
    global shlib_ext
104
 
105
    set gccpath ${paths}
106
    set libio_dir ""
107
    set flags ""
108
    set ld_library_path "."
109
 
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
          append flags " -L${gccpath}/libstdc++-v3/src/.libs "
127
          append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
128
      }
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"
133
      }
134
 
135
      if [file exists "${gccpath}/libiberty/libiberty.a"] {
136
          append flags "-L${gccpath}/libiberty "
137
      }
138
      if [file exists "${gccpath}/librx/librx.a"] {
139
          append flags "-L${gccpath}/librx "
140
      }
141
      append ld_library_path [gcc-set-multilib-library-path $GXX_UNDER_TEST]
142
    } else {
143
      global tool_root_dir
144
 
145
      set libgpp [lookfor_file ${tool_root_dir} libg++]
146
      if { $libgpp != "" } {
147
          append flags "-L${libgpp} "
148
          append ld_library_path ":${libgpp}"
149
      }
150
      set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
151
      if { $libstdcpp != "" } {
152
          append flags "-L${libstdcpp} "
153
          append ld_library_path ":${libstdcpp}"
154
      }
155
      set libiberty [lookfor_file ${tool_root_dir} libiberty]
156
      if { $libiberty != "" } {
157
          append flags "-L${libiberty} "
158
      }
159
      set librx [lookfor_file ${tool_root_dir} librx]
160
      if { $librx != "" } {
161
          append flags "-L${librx} "
162
      }
163
    }
164
 
165
    set_ld_library_path_env_vars
166
 
167
    return "$flags"
168
}
169
 
170
#
171
# g++_init -- called at the start of each subdir of tests
172
#
173
 
174
proc g++_init { args } {
175
    global subdir
176
    global gpp_initialized
177
    global base_dir
178
    global tmpdir
179
    global libdir
180
    global gluefile wrap_flags
181
    global objdir srcdir
182
    global ALWAYS_CXXFLAGS
183
    global CXXFLAGS
184
    global TOOL_EXECUTABLE TOOL_OPTIONS
185
    global GXX_UNDER_TEST
186
    global TESTING_IN_BUILD_TREE
187
    global target_triplet
188
 
189
    # We set LC_ALL and LANG to C so that we get the same error messages as expected.
190
    setenv LC_ALL C
191
    setenv LANG C
192
 
193
    if ![info exists GXX_UNDER_TEST] then {
194
        if [info exists TOOL_EXECUTABLE] {
195
            set GXX_UNDER_TEST $TOOL_EXECUTABLE
196
        } else {
197
            if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
198
                set GXX_UNDER_TEST [transform c++]
199
            } else {
200
                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++]]]
201
            }
202
        }
203
    }
204
 
205
    # Bleah, nasty. Bad taste.
206
    if [ishost "*-dos-*" ] {
207
        regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
208
    }
209
 
210
    if ![is_remote host] {
211
        if { [which $GXX_UNDER_TEST] == 0 } then {
212
            perror "GXX_UNDER_TEST ($GXX_UNDER_TEST) does not exist"
213
            exit 1
214
        }
215
    }
216
    if ![info exists tmpdir] {
217
        set tmpdir "/tmp"
218
    }
219
 
220
    if [info exists gluefile] {
221
        unset gluefile
222
    }
223
 
224
    g++_maybe_build_wrapper "${tmpdir}/g++-testglue.o" "-fexceptions"
225
 
226
    if {![info exists CXXFLAGS]} {
227
        set CXXFLAGS ""
228
    }
229
 
230
    set ALWAYS_CXXFLAGS ""
231
 
232
    if ![is_remote host] {
233
        if [info exists TOOL_OPTIONS] {
234
            lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
235
            lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
236
        } else {
237
            lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags [get_multilibs] ]"
238
            lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags [get_multilibs] ]"
239
        }
240
    }
241
 
242
    if [info exists TOOL_OPTIONS] {
243
        lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS"
244
    }
245
 
246
    # Make sure that lines are not wrapped.  That can confuse the
247
    # error-message parsing machinery.
248
    lappend ALWAYS_CXXFLAGS "additional_flags=-fmessage-length=0"
249
 
250
    if { [string match "*-*-darwin*" $target_triplet] } {
251
        lappend ALWAYS_CXXFLAGS "ldflags=-multiply_defined suppress"
252
       }
253
 
254
    verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
255
 
256
    verbose "g++ is initialized" 3
257
}
258
 
259
#
260
# g++_target_compile -- compile a source file
261
#
262
 
263
proc g++_target_compile { source dest type options } {
264
    global tmpdir
265
    global gpp_compile_options
266
    global gluefile wrap_flags
267
    global ALWAYS_CXXFLAGS
268
    global GXX_UNDER_TEST
269
 
270
    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
271
        lappend options "libs=${gluefile}"
272
        lappend options "ldflags=${wrap_flags}"
273
    }
274
 
275
    lappend options "additional_flags=[libio_include_flags]"
276
    lappend options "compiler=$GXX_UNDER_TEST"
277
 
278
    set options [concat $gpp_compile_options $options]
279
 
280
    set options [concat "$ALWAYS_CXXFLAGS" $options]
281
 
282
    if { [regexp "(^| )-frepo( |$)" $options] && \
283
         [regexp "\.o(|bj)$" $dest] } then {
284
        regsub "\.o(|bj)$" $dest ".rpo" rponame
285
        exec rm -f $rponame
286
    }
287
 
288
    set options [dg-additional-files-options $options $source]
289
 
290
    set result [target_compile $source $dest $type $options]
291
 
292
    return $result
293
}
294
 
295
#
296
# ${tool}_option_help
297
#
298
 
299
proc ${tool}_option_help { } {
300
    send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
301
}
302
 
303
#
304
# ${tool}_option_proc
305
#
306
 
307
proc ${tool}_option_proc { option } {
308
    if [regexp "^--additional_options," $option] {
309
        global gpp_compile_options
310
        regsub "--additional_options," $option "" option
311
        foreach x [split $option ","] {
312
            lappend gpp_compile_options "additional_flags=$x"
313
        }
314
        return 1
315
    } else {
316
        return 0
317
    }
318
}

powered by: WebSVN 2.1.0

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