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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libmudflap/] [testsuite/] [lib/] [libmudflap.exp] - Blame information for rev 867

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

Line No. Rev Author Line
1 738 jeremybenn
# Copyright (C) 2001, 2002, 2003, 2004, 2009, 2010, 2011
2
# 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 this program; see the file COPYING3.  If not see
16
# .
17
 
18
# Define libmudflap callbacks for dg.exp.
19
# This file is a copy of libstdc++-v3's dejagnu driver, with minor changes.
20
 
21
# Useful hook:  if ${hostname}_init exists, it will be called, almost
22
# the last thing before testing begins.  This can be defined in, e.g.,
23
# ~/.dejagnurc or $DEJAGNU.
24
 
25
proc load_gcc_lib { filename } {
26
    global srcdir
27
    load_file $srcdir/../../gcc/testsuite/lib/$filename
28
}
29
 
30
load_lib mfdg.exp
31
load_lib libgloss.exp
32
load_gcc_lib target-libpath.exp
33
load_gcc_lib target-supports.exp
34
load_gcc_lib timeout.exp
35
load_gcc_lib timeout-dg.exp
36
 
37
proc libmudflap-init { language } {
38
    global env
39
    global srcdir outdir blddir objdir tool_root_dir
40
    global cxx cxxflags
41
    global includes
42
    global libs
43
    global gluefile wrap_flags
44
    global ld_library_path
45
 
46
    switch $language {
47
        "c" { set cxx [find_gcc] }
48
        "c++" { set cxx [find_g++] }
49
        default { error "bad language code $language"; return }
50
    }
51
 
52
    verbose -log "libmudflap-init $cxx"
53
 
54
    set blddir [lookfor_file [get_multilibs] libmudflap]
55
    set cxxblddir [lookfor_file [get_multilibs] libstdc++-v3]
56
    set cxxflags_file "${cxxblddir}/scripts/testsuite_flags"
57
 
58
    # By default, we assume we want to run program images.
59
    global dg-do-what-default
60
    set dg-do-what-default run
61
 
62
    # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
63
    # locate libgcc.a so we don't need to account for different values of
64
    # SHLIB_EXT on different platforms
65
    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
66
    if {$gccdir != ""} {
67
        set gccdir [file dirname $gccdir]
68
    }
69
 
70
    set ld_library_path "."
71
    append ld_library_path ":${gccdir}"
72
    append ld_library_path ":${cxxblddir}/src/.libs"
73
    if {[is_remote host] == 0} {
74
        foreach i "[exec ${gccdir}/xgcc --print-multi-lib]" {
75
            set mldir ""
76
            regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
77
            set mldir [string trimright $mldir "\;@"]
78
            if { "$mldir" == "." } {
79
                continue
80
            }
81
            if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
82
                append ld_library_path ":${gccdir}/${mldir}"
83
            }
84
        }
85
    }
86
    append ld_library_path ":${blddir}/.libs"
87
 
88
    set libs "-L${blddir}/.libs"
89
    set cxxflags "-ggdb3 -DDEBUG_ASSERT"
90
    set includes "-I${srcdir} -I${srcdir}/.. -I.."
91
 
92
    if {$language == "c++"} {
93
        if {[file exists $cxxflags_file]} then {
94
            set includes "${includes} [exec sh $cxxflags_file --build-includes]"
95
            set cxxflags "${cxxflags} [exec sh $cxxflags_file --cxxflags]"
96
            # c++ libs are included by --build-cxx below
97
            set cxx "[exec sh $cxxflags_file --build-cxx]"
98
        } else {
99
            lappend libs "-L${cxxblddir}src/.libs"
100
            lappend includes "-I../../libstdc++-v3/include"
101
        }
102
    }
103
 
104
    global mfconfig_libs
105
    global add_flags
106
    append add_flags " $mfconfig_libs"
107
 
108
    set_ld_library_path_env_vars
109
    if [info exists env(LD_LIBRARY_PATH)] {
110
        verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
111
    }
112
 
113
    if { [target_info needs_status_wrapper]!=""} {
114
      file delete ${objdir}/testglue.o;
115
      set gluefile ${objdir}/testglue.o;
116
      set result [build_wrapper $gluefile];
117
      if { $result != "" } {
118
          set gluefile [lindex $result 0];
119
          set wrap_flags [lindex $result 1];
120
      } else {
121
          unset gluefile
122
      }
123
    }
124
 
125
    # If there is no static library then don't run tests with -static.
126
    global tool
127
    global mfconfig_libs
128
    set opts "additional_flags=-static"
129
    lappend opts "additional_flags=-fmudflap"
130
    lappend opts "additional_flags=-lmudflap"
131
    lappend opts "libs=$mfconfig_libs"
132
    set src stlm[pid].c
133
    set exe stlm[pid].x
134
 
135
    set f [open $src "w"]
136
    puts $f "int main () { }"
137
    close $f
138
    set lines [${tool}_target_compile $src $exe executable "$opts"]
139
    file delete $src
140
    remote_file build delete $exe
141
 
142
    if { ![string match "" $lines] } {
143
        # Compilation failed; assume static library is not available.
144
        global MUDFLAP_FLAGS
145
        set i [lsearch $MUDFLAP_FLAGS "*static*"]
146
        set MUDFLAP_FLAGS [lreplace $MUDFLAP_FLAGS $i $i]
147
    }
148
}
149
 
150
proc libmudflap-dg-test { prog do_what extra_tool_flags } {
151
    # Set up the compiler flags, based on what we're going to do.
152
 
153
    switch $do_what {
154
        "preprocess" {
155
            set compile_type "preprocess"
156
            set output_file "[file rootname [file tail $prog]].i"
157
        }
158
        "compile" {
159
            set compile_type "assembly"
160
            set output_file "[file rootname [file tail $prog]].s"
161
        }
162
        "assemble" {
163
            set compile_type "object"
164
            set output_file "[file rootname [file tail $prog]].o"
165
        }
166
        "link" {
167
            set compile_type "executable"
168
            set output_file "./[file rootname [file tail $prog]].exe"
169
        }
170
        "run" {
171
            set compile_type "executable"
172
            # FIXME: "./" is to cope with "." not being in $PATH.
173
            # Should this be handled elsewhere?
174
            # YES.
175
            set output_file "./[file rootname [file tail $prog]].exe"
176
            # This is the only place where we care if an executable was
177
            # created or not.  If it was, dg.exp will try to run it.
178
            remote_file build delete $output_file;
179
        }
180
        default {
181
            perror "$do_what: not a valid dg-do keyword"
182
            return ""
183
        }
184
    }
185
    set options ""
186
    if { $extra_tool_flags != "" } {
187
        lappend options "additional_flags=$extra_tool_flags"
188
    }
189
 
190
    global mfconfig_libs
191
    lappend options "libs=$mfconfig_libs"
192
 
193
    set comp_output [libmudflap_target_compile "$prog" "$output_file" "$compile_type" $options];
194
 
195
    return [list $comp_output $output_file]
196
}
197
 
198
 
199
proc libmudflap_target_compile { source dest type options } {
200
    global gluefile
201
    global wrap_flags
202
    global cxx
203
    global cxxflags
204
    global includes
205
    global libs
206
    global blddir
207
 
208
    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
209
        lappend options "libs=${gluefile}"
210
        lappend options "ldflags=${wrap_flags}"
211
    }
212
 
213
    set cxx_final $cxx
214
    set cxxlibglossflags  [libgloss_link_flags]
215
    set cxx_final [concat $cxx_final $cxxlibglossflags]
216
    set cxx_final [concat $cxx_final $cxxflags]
217
    set cxx_final [concat $cxx_final $includes]
218
    set cxx_final [concat $cxx_final $libs]
219
 
220
    lappend options "compiler=$cxx_final"
221
    lappend options "timeout=[timeout_value]"
222
 
223
    # Picks up the freshly-built testsuite library corresponding to the
224
    # multilib under test.
225
    lappend options "ldflags=-L${blddir}/testsuite"
226
 
227
    return [target_compile $source $dest $type $options]
228
}
229
 
230
 
231
# A bit sloppy...  Returns a list of source files (full pathnames) to
232
# compile.  We mimic the mkcheck script in that the first time this is run,
233
# all existing files are listed in "testsuite_files" in the output
234
# directory.  Subsequent runs pull the list from that file, allowing users
235
# to trim the list down to problematic tests.
236
### This is supposed to be done via RUNTESTFLAGS, but that doesn't work.
237
proc libmudflap-list-sourcefiles { } {
238
    global srcdir
239
    global outdir
240
 
241
    set files_file "${outdir}/testsuite_files"
242
    set sfiles ""
243
    if { [file exists $files_file] } {
244
        set f [open $files_file]
245
        while { ! [eof $f] } {
246
            set t [gets $f]
247
            if { [string length "$t"] != 0 } {
248
                lappend sfiles ${srcdir}/${t}
249
            }
250
        }
251
    } else {
252
        set f [open $files_file "w"]
253
        set where_we_were [pwd]
254
        cd $srcdir
255
        foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] {
256
            lappend sfiles ${srcdir}/${s}
257
            puts $f $s
258
        }
259
        cd $where_we_were
260
    }
261
    close $f
262
 
263
    # Disable wchar_t tests if library not configured to support
264
    # wchar_t testing.
265
    set wchar_file "${outdir}/testsuite_wchar_t"
266
    if { [file exists $wchar_file] } {
267
        return $sfiles
268
    } else {
269
        # Remove wchar_t tests files from list.
270
        set res {}
271
        foreach w $sfiles {
272
            if [regexp "wchar_t" $w] {
273
                verbose -log "element out list is $w"
274
            } else {
275
                verbose -log "element in list is $w"
276
                lappend res $w
277
            }
278
        }
279
        return $res
280
    }
281
}
282
 
283
 
284
proc libmudflap-dg-prune { system text } {
285
    global additional_prunes
286
 
287
    set text [prune_gcc_output $text]
288
 
289
    foreach p $additional_prunes {
290
        if { [string length $p] > 0 } {
291
            # Following regexp matches a complete line containing $p.
292
            regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
293
        }
294
    }
295
 
296
    return $text
297
}
298
 
299
 
300
proc prune_gcc_output { text } {
301
    regsub -all {(^|\n)[^\n]*ld: warning: libgcc_s[^\n]*not found[^\n]*try using[^\n]*} $text "" text
302
    regsub -all {(^|\n)[^\n]*In function.*pthread_create[^\n]*} $text "" text
303
    regsub -all {(^|\n)[^\n]*the use of .pthread.*is deprecated[^\n]*} $text "" text
304
    regsub -all {(^|\n)[^\n]*Dwarf Error:.*FORM value: 14[^\n]*} $text "" text
305
    regsub -all {(^|\n)[^\n]*In function[^\n]*} $text "" text
306
    regsub -all {(^|\n)[^\n]*Using.*in statically linked applications requires[^\n]*} $text "" text
307
 
308
    return $text
309
}

powered by: WebSVN 2.1.0

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