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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [lib/] [objc.exp] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 306 jeremybenn
# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004, 2005,
2
# 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
# Currently maintained by Doug Evans (dje@cygnus.com)
20
 
21
# This file is loaded by the tool init file (eg: unix.exp).  It provides
22
# default definitions for objc_start, etc. and other supporting cast members.
23
 
24
# These globals are used by objc_start if no compiler arguments are provided.
25
# They are also used by the various testsuites to define the environment:
26
# where to find stdio.h, libc.a, etc.
27
 
28
load_lib libgloss.exp
29
load_lib prune.exp
30
load_lib gcc-defs.exp
31
load_lib timeout.exp
32
load_lib target-libpath.exp
33
 
34
#
35
# OBJC_UNDER_TEST is the compiler under test.
36
#
37
 
38
#
39
# default_objc_version -- extract and print the version number of the compiler
40
#
41
 
42
proc default_objc_version { } {
43
    global OBJC_UNDER_TEST
44
 
45
    objc_init
46
 
47
    # Ignore any arguments after the command.
48
    set compiler [lindex $OBJC_UNDER_TEST 0]
49
 
50
    if ![is_remote host] {
51
        set compiler_name [which $compiler]
52
    } else {
53
        set compiler_name $compiler
54
    }
55
 
56
    # Verify that the compiler exists.
57
    if { $compiler_name != 0 } then {
58
        set tmp [remote_exec host "$compiler -v"]
59
        set status [lindex $tmp 0]
60
        set output [lindex $tmp 1]
61
        regexp " version \[^\n\r\]*" $output version
62
        if { $status == 0 && [info exists version] } then {
63
            clone_output "$compiler_name $version\n"
64
        } else {
65
            clone_output "Couldn't determine version of $compiler_name: $output\n"
66
        }
67
    } else {
68
        # Compiler does not exist (this should have already been detected).
69
        warning "$compiler does not exist"
70
    }
71
}
72
 
73
#
74
# Call objc_version. We do it this way so we can override it if needed.
75
#
76
proc objc_version { } {
77
    default_objc_version
78
}
79
 
80
#
81
# objc_init -- called at the start of each .exp script.
82
#
83
# There currently isn't much to do, but always using it allows us to
84
# make some enhancements without having to go back and rewrite the scripts.
85
#
86
 
87
set objc_initialized 0
88
 
89
proc objc_init { args } {
90
    global rootme
91
    global tmpdir
92
    global libdir
93
    global gluefile wrap_flags
94
    global objc_initialized
95
    global OBJC_UNDER_TEST
96
    global TOOL_EXECUTABLE
97
    global objc_libgcc_s_path
98
    global gcc_warning_prefix
99
    global gcc_error_prefix
100
 
101
    # We set LC_ALL and LANG to C so that we get the same error messages as
102
    # expected.
103
    setenv LC_ALL C
104
    setenv LANG C
105
 
106
    # Many hosts now default to a non-ASCII C locale, however, so
107
    # they can set a charset encoding here if they need.
108
    if { [ishost "*-*-cygwin*"] } {
109
      setenv LC_ALL C.ASCII
110
      setenv LANG C.ASCII
111
    }
112
 
113
    if { $objc_initialized == 1 } { return; }
114
 
115
    if ![info exists OBJC_UNDER_TEST] then {
116
        if [info exists TOOL_EXECUTABLE] {
117
            set OBJC_UNDER_TEST $TOOL_EXECUTABLE
118
        } else {
119
            set OBJC_UNDER_TEST [find_gcc]
120
        }
121
    }
122
 
123
    if ![info exists tmpdir] then {
124
        set tmpdir /tmp
125
    }
126
 
127
    set gcc_warning_prefix "warning:"
128
    set gcc_error_prefix "error:"
129
 
130
    objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
131
 
132
    set objc_libgcc_s_path [gcc-set-multilib-library-path $OBJC_UNDER_TEST]
133
}
134
 
135
proc objc_target_compile { source dest type options } {
136
    global rootme
137
    global tmpdir
138
    global gluefile wrap_flags
139
    global srcdir
140
    global OBJC_UNDER_TEST
141
    global TOOL_OPTIONS
142
    global ld_library_path
143
    global objc_libgcc_s_path
144
    global shlib_ext
145
 
146
    set shlib_ext [get_shlib_extension]
147
    set ld_library_path ".:${objc_libgcc_s_path}"
148
 
149
    # We have to figure out which runtime will be used on darwin because
150
    # we need to add the include path for the gnu runtime if that is in
151
    # use.
152
    # First set the default...
153
    if { [istarget "*-*-darwin*"] } {
154
        set nextruntime 1
155
    } else {
156
        set nextruntime 0
157
    }
158
    verbose "initial next runtime state : $nextruntime" 2
159
    # Next, see if we define the option in dg-options...
160
    foreach opt $options {
161
        if [regexp ".*-fnext-runtime.*" $opt] {
162
            set nextruntime 1
163
        }
164
        if [regexp ".*-fgnu-runtime.*" $opt] {
165
            set nextruntime 0
166
        }
167
    }
168
    verbose "next runtime state after dg opts: $nextruntime"  2
169
 
170
    set tgt [target_info name]
171
    if [board_info $tgt exists multilib_flags] {
172
        set lb [board_info $tgt multilib_flags]
173
        verbose "board multilib_flags $lb" 2
174
        foreach opt $lb {
175
            if [regexp ".*-fnext-runtime.*" $opt] {
176
                set nextruntime 1
177
            }
178
            if [regexp ".*-fgnu-runtime.*" $opt] {
179
                set nextruntime 0
180
            }
181
        }
182
    }
183
    verbose "next runtime state after any multilib opts: $nextruntime" 2
184
 
185
    lappend options "libs=-lobjc"
186
    verbose "shared lib extension: $shlib_ext" 3
187
 
188
    if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
189
        lappend options "libs=${gluefile}"
190
        lappend options "ldflags=$wrap_flags"
191
    }
192
 
193
    if [target_info exists objc,stack_size] {
194
        lappend options "additional_flags=-DSTACK_SIZE=[target_info objc,stack_size]"
195
    }
196
    if [target_info exists objc,no_trampolines] {
197
        lappend options "additional_flags=-DNO_TRAMPOLINES"
198
    }
199
    if [target_info exists objc,no_label_values] {
200
        lappend options "additional_flags=-DNO_LABEL_VALUES"
201
    }
202
    # TOOL_OPTIONS must come first, so that it doesn't override testcase
203
    # specific options.
204
    if [info exists TOOL_OPTIONS] {
205
        set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
206
    }
207
 
208
    # If we have built libobjc along with the compiler, point the test harness
209
    # at it (and associated headers).
210
 
211
    set objcpath "[get_multilibs]"
212
 
213
    set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
214
    if { $libobjc_dir == "" } {
215
        # On darwin there is, potentially, a gnu runtime too.
216
        set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
217
    }
218
    # Perhaps we didn't build static libs.
219
    if { $libobjc_dir == "" } {
220
        set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
221
        # On darwin there is, potentially, a gnu runtime too.
222
        if { $libobjc_dir == "" } {
223
            set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
224
        }
225
    }
226
 
227
    if { $libobjc_dir != "" } {
228
        # If we are using the gnu runtime, add its includes.
229
        if { $nextruntime == 0 } {
230
            set objc_include_dir "${srcdir}/../../libobjc"
231
            lappend options "additional_flags=-I${objc_include_dir}"
232
            verbose "adding gnu runtime include dir: $objc_include_dir "
233
        }
234
        set libobjc_dir [file dirname ${libobjc_dir}]
235
        # Allow for %s spec substitutions..
236
        set objc_link_flags " -B${libobjc_dir} "
237
        lappend options "additional_flags=${objc_link_flags}"
238
        set objc_link_flags " -L${libobjc_dir} "
239
        lappend options "additional_flags=${objc_link_flags}"
240
        append ld_library_path ":${libobjc_dir}"
241
    }
242
    if { $type == "precompiled_header" } {
243
        # If we generating a precompiled header, we have say this is an
244
        # objective-C header.
245
        set source [concat "-x objective-c-header" $source]
246
    }
247
    lappend options "compiler=$OBJC_UNDER_TEST"
248
    lappend options "timeout=[timeout_value]"
249
 
250
    set_ld_library_path_env_vars
251
 
252
    return [target_compile $source $dest $type $options]
253
}
254
 
255
#
256
# objc_pass -- utility to record a testcase passed.
257
#
258
 
259
proc objc_pass { testcase cflags } {
260
    if { "$cflags" == "" } {
261
        pass "$testcase"
262
    } else {
263
        pass "$testcase, $cflags"
264
    }
265
}
266
 
267
#
268
# objc_fail -- utility to record a testcase failed
269
#
270
 
271
proc objc_fail { testcase cflags } {
272
    if { "$cflags" == "" } {
273
        fail "$testcase"
274
    } else {
275
        fail "$testcase, $cflags"
276
    }
277
}
278
 
279
#
280
# objc_finish -- called at the end of every .exp script that calls objc_init
281
#
282
# The purpose of this proc is to hide all quirks of the testing environment
283
# from the testsuites.  It also exists to undo anything that objc_init did
284
# (that needs undoing).
285
#
286
 
287
proc objc_finish { } {
288
    # The testing harness apparently requires this.
289
    global errorInfo
290
 
291
    if [info exists errorInfo] then {
292
        unset errorInfo
293
    }
294
 
295
    # Might as well reset these (keeps our caller from wondering whether
296
    # s/he has to or not).
297
    global prms_id bug_id
298
    set prms_id 0
299
    set bug_id 0
300
}
301
 
302
proc objc_exit { } {
303
    global gluefile
304
 
305
    if [info exists gluefile] {
306
        file_on_build delete $gluefile
307
        unset gluefile
308
    }
309
}
310
 
311
# If this is an older version of dejagnu (without runtest_file_p),
312
# provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
313
# This can be deleted after next dejagnu release.
314
 
315
if { [info procs runtest_file_p] == "" } then {
316
    proc runtest_file_p { runtests testcase } {
317
        if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
318
            if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
319
                return 1
320
            } else {
321
                return 0
322
            }
323
        }
324
        return 1
325
    }
326
}
327
 
328
# Provide a definition of this if missing (delete after next dejagnu release).
329
 
330
if { [info procs prune_warnings] == "" } then {
331
    proc prune_warnings { text } {
332
        return $text
333
    }
334
}
335
 
336
# Utility used by mike-gcc.exp and c-torture.exp.
337
# Check the compiler(/assembler/linker) output for text indicating that
338
# the testcase should be marked as "unsupported".
339
#
340
# When dealing with a large number of tests, it's difficult to weed out the
341
# ones that are too big for a particular cpu (eg: 16 bit with a small amount
342
# of memory).  There are various ways to deal with this.  Here's one.
343
# Fortunately, all of the cases where this is likely to happen will be using
344
# gld so we can tell what the error text will look like.
345
 
346
proc ${tool}_check_unsupported_p { output } {
347
    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
348
        return "memory full"
349
    }
350
    return ""
351
}
352
 
353
# Prune messages from objc that aren't useful.
354
 
355
proc prune_objc_output { text } {
356
    #send_user "Before:$text\n"
357
    regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
358
    regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
359
 
360
    # It would be nice to avoid passing anything to objc that would cause it to
361
    # issue these messages (since ignoring them seems like a hack on our part),
362
    # but that's too difficult in the general case.  For example, sometimes
363
    # you need to use -B to point objc at crt0.o, but there are some targets
364
    # that don't have crt0.o.
365
    regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
366
    regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
367
 
368
    #send_user "After:$text\n"
369
 
370
    return $text
371
}
372
 

powered by: WebSVN 2.1.0

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