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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libmudflap/] [testsuite/] [lib/] [libmudflap.exp] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2
 
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 
17
# Define libmudflap callbacks for dg.exp.
18
# This file is a copy of libstdc++-v3's dejagnu driver, with minor changes.
19
 
20
# Useful hook:  if ${hostname}_init exists, it will be called, almost
21
# the last thing before testing begins.  This can be defined in, e.g.,
22
# ~/.dejagnurc or $DEJAGNU.
23
 
24
proc load_gcc_lib { filename } {
25
    global srcdir
26
    load_file $srcdir/../../gcc/testsuite/lib/$filename
27
}
28
 
29
load_lib mfdg.exp
30
load_lib libgloss.exp
31
load_gcc_lib target-libpath.exp
32
 
33
proc libmudflap-init { language } {
34
    global env
35
    global srcdir outdir blddir objdir tool_root_dir
36
    global cxx cxxflags
37
    global includes
38
    global libs
39
    global gluefile wrap_flags
40
    global ld_library_path
41
 
42
    switch $language {
43
        "c" { set cxx [find_gcc] }
44
        "c++" { set cxx [find_g++] }
45
        default { error "bad language code $language"; return }
46
    }
47
 
48
    verbose -log "libmudflap-init $cxx"
49
 
50
    set blddir [lookfor_file [get_multilibs] libmudflap]
51
    set cxxblddir [lookfor_file [get_multilibs] libstdc++-v3]
52
    set cxxflags_file "${cxxblddir}/scripts/testsuite_flags"
53
 
54
    # By default, we assume we want to run program images.
55
    global dg-do-what-default
56
    set dg-do-what-default run
57
 
58
    # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
59
    # locate libgcc.a so we don't need to account for different values of
60
    # SHLIB_EXT on different platforms
61
    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
62
    if {$gccdir != ""} {
63
        set gccdir [file dirname $gccdir]
64
    }
65
 
66
    set ld_library_path "."
67
    append ld_library_path ":${gccdir}"
68
    append ld_library_path ":${cxxblddir}/src/.libs"
69
    if {[is_remote host] == 0} {
70
        foreach i "[exec ${gccdir}/xgcc --print-multi-lib]" {
71
            set mldir ""
72
            regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
73
            set mldir [string trimright $mldir "\;@"]
74
            if { "$mldir" == "." } {
75
                continue
76
            }
77
            if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
78
                append ld_library_path ":${gccdir}/${mldir}"
79
            }
80
        }
81
    }
82
    append ld_library_path ":${blddir}/.libs"
83
 
84
    set libs "-L${blddir}/.libs"
85
    set cxxflags "-ggdb3 -DDEBUG_ASSERT"
86
    set includes "-I${srcdir} -I${srcdir}/.. -I.."
87
 
88
    if {$language == "c++"} {
89
        if {[file exists $cxxflags_file]} then {
90
            set includes "${includes} [exec sh $cxxflags_file --build-includes]"
91
            set cxxflags "${cxxflags} [exec sh $cxxflags_file --cxxflags]"
92
            # c++ libs are included by --build-cxx below
93
            set cxx "[exec sh $cxxflags_file --build-cxx]"
94
        } else {
95
            lappend libs "-L${cxxblddir}src/.libs"
96
            lappend includes "-I../../libstdc++-v3/include"
97
        }
98
    }
99
 
100
    global mfconfig_libs
101
    global add_flags
102
    append add_flags " $mfconfig_libs"
103
 
104
    set_ld_library_path_env_vars
105
    if [info exists env(LD_LIBRARY_PATH)] {
106
        verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
107
    }
108
 
109
    if { [target_info needs_status_wrapper]!=""} {
110
      file delete ${objdir}/testglue.o;
111
      set gluefile ${objdir}/testglue.o;
112
      set result [build_wrapper $gluefile];
113
      if { $result != "" } {
114
          set gluefile [lindex $result 0];
115
          set wrap_flags [lindex $result 1];
116
      } else {
117
          unset gluefile
118
      }
119
    }
120
}
121
 
122
proc libmudflap-dg-test { prog do_what extra_tool_flags } {
123
    # Set up the compiler flags, based on what we're going to do.
124
 
125
    switch $do_what {
126
        "preprocess" {
127
            set compile_type "preprocess"
128
            set output_file "[file rootname [file tail $prog]].i"
129
        }
130
        "compile" {
131
            set compile_type "assembly"
132
            set output_file "[file rootname [file tail $prog]].s"
133
        }
134
        "assemble" {
135
            set compile_type "object"
136
            set output_file "[file rootname [file tail $prog]].o"
137
        }
138
        "link" {
139
            set compile_type "executable"
140
            set output_file "./[file rootname [file tail $prog]].exe"
141
        }
142
        "run" {
143
            set compile_type "executable"
144
            # FIXME: "./" is to cope with "." not being in $PATH.
145
            # Should this be handled elsewhere?
146
            # YES.
147
            set output_file "./[file rootname [file tail $prog]].exe"
148
            # This is the only place where we care if an executable was
149
            # created or not.  If it was, dg.exp will try to run it.
150
            remote_file build delete $output_file;
151
        }
152
        default {
153
            perror "$do_what: not a valid dg-do keyword"
154
            return ""
155
        }
156
    }
157
    set options ""
158
    if { $extra_tool_flags != "" } {
159
        lappend options "additional_flags=$extra_tool_flags"
160
    }
161
 
162
    global mfconfig_libs
163
    lappend options "libs=$mfconfig_libs"
164
 
165
    set comp_output [libmudflap_target_compile "$prog" "$output_file" "$compile_type" $options];
166
    set comp_output [prune_gcc_output $comp_output ];
167
 
168
    return [list $comp_output $output_file]
169
}
170
 
171
 
172
proc libmudflap_target_compile { source dest type options } {
173
    global gluefile
174
    global wrap_flags
175
    global cxx
176
    global cxxflags
177
    global includes
178
    global libs
179
    global blddir
180
 
181
    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
182
        lappend options "libs=${gluefile}"
183
        lappend options "ldflags=${wrap_flags}"
184
    }
185
 
186
    set cxx_final $cxx
187
    set cxxlibglossflags  [libgloss_link_flags]
188
    set cxx_final [concat $cxx_final $cxxlibglossflags]
189
    set cxx_final [concat $cxx_final $cxxflags]
190
    set cxx_final [concat $cxx_final $includes]
191
    set cxx_final [concat $cxx_final $libs]
192
 
193
    lappend options "compiler=$cxx_final"
194
 
195
    # Picks up the freshly-built testsuite library corresponding to the
196
    # multilib under test.
197
    lappend options "ldflags=-L${blddir}/testsuite"
198
 
199
    return [target_compile $source $dest $type $options]
200
}
201
 
202
 
203
# A bit sloppy...  Returns a list of source files (full pathnames) to
204
# compile.  We mimic the mkcheck script in that the first time this is run,
205
# all existing files are listed in "testsuite_files" in the output
206
# directory.  Subsequent runs pull the list from that file, allowing users
207
# to trim the list down to problematic tests.
208
### This is supposed to be done via RUNTESTFLAGS, but that doesn't work.
209
proc libmudflap-list-sourcefiles { } {
210
    global srcdir
211
    global outdir
212
 
213
    set files_file "${outdir}/testsuite_files"
214
    set sfiles ""
215
    if { [file exists $files_file] } {
216
        set f [open $files_file]
217
        while { ! [eof $f] } {
218
            set t [gets $f]
219
            if { [string length "$t"] != 0 } {
220
                lappend sfiles ${srcdir}/${t}
221
            }
222
        }
223
    } else {
224
        set f [open $files_file "w"]
225
        set where_we_were [pwd]
226
        cd $srcdir
227
        foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] {
228
            lappend sfiles ${srcdir}/${s}
229
            puts $f $s
230
        }
231
        cd $where_we_were
232
    }
233
    close $f
234
 
235
    # Disable wchar_t tests if library not configured to support
236
    # wchar_t testing.
237
    set wchar_file "${outdir}/testsuite_wchar_t"
238
    if { [file exists $wchar_file] } {
239
        return $sfiles
240
    } else {
241
        # Remove wchar_t tests files from list.
242
        set res {}
243
        foreach w $sfiles {
244
            if [regexp "wchar_t" $w] {
245
                verbose -log "element out list is $w"
246
            } else {
247
                verbose -log "element in list is $w"
248
                lappend res $w
249
            }
250
        }
251
        return $res
252
    }
253
}
254
 
255
 
256
proc prune_gcc_output { text } {
257
    regsub -all {(^|\n)[^\n]*ld: warning: libgcc_s[^\n]*not found[^\n]*try using[^\n]*} $text "" text
258
    regsub -all {(^|\n)[^\n]*In function.*pthread_create[^\n]*} $text "" text
259
    regsub -all {(^|\n)[^\n]*the use of .pthread.*is deprecated[^\n]*} $text "" text
260
    regsub -all {(^|\n)[^\n]*Dwarf Error:.*FORM value: 14[^\n]*} $text "" text
261
    regsub -all {(^|\n)[^\n]*In function[^\n]*} $text "" text
262
    regsub -all {(^|\n)[^\n]*Using.*in statically linked applications requires[^\n]*} $text "" text
263
 
264
    return $text
265
}

powered by: WebSVN 2.1.0

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