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