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