]>
Commit | Line | Data |
---|---|---|
23834577 | 1 | # libstdc++ "tool init file" for DejaGNU |
2cb1c928 | 2 | |
a7543cfd | 3 | # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
0ded1615 | 4 | # Free Software Foundation, Inc. |
23834577 | 5 | # |
b3f2a032 PE |
6 | # This program is free software; you can redistribute it and/or modify |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software | |
2f9f6cef BK |
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | # 02110-1301, USA. | |
2cb1c928 | 20 | |
b3f2a032 | 21 | |
23834577 PE |
22 | # Define callbacks and load other libraries. This file is loaded relatively |
23 | # early, and before any other file we write ourselves. "load_lib" will | |
24 | # find anything in the DejaGNU installation tree, or in our lib directory. | |
25 | # "load_gcc_lib" will search the core compiler's .exp collection instead. | |
26 | # | |
27 | # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks | |
28 | # for "tool_" when finding callbacks. Utility routines we define for | |
29 | # our callbacks begin with "v3-". | |
30 | # | |
31 | # libstdc++_* callbacks we don't define, but could: | |
32 | # ..._option_help prints additional --help output | |
33 | # ..._option_proc (--foo) process our own options | |
23834577 PE |
34 | # ..._init (normal.exp) called once per test file |
35 | # ..._finish bracketing function for libstdc++_init | |
36 | # ...-dg-prune removing output text, see top of system dg.exp | |
37 | # | |
38 | # Useful hook: if ${hostname}_init exists, it will be called, almost | |
39 | # the last thing before testing begins. This can be defined in, e.g., | |
40 | # ~/.dejagnurc or $DEJAGNU. | |
41 | ||
42 | proc load_gcc_lib { filename } { | |
43 | global srcdir | |
44 | load_file $srcdir/../../gcc/testsuite/lib/$filename | |
45 | } | |
46 | ||
47 | # system routines | |
b3f2a032 PE |
48 | load_lib dg.exp |
49 | load_lib libgloss.exp | |
23834577 | 50 | # compiler routines, then ours |
58adf39c | 51 | load_gcc_lib target-supports.exp |
75d1ddc1 | 52 | load_gcc_lib target-supports-dg.exp |
b3f2a032 | 53 | load_lib prune.exp |
23834577 | 54 | load_lib dg-options.exp |
1df8e834 | 55 | load_gcc_lib target-libpath.exp |
90c609e5 | 56 | load_gcc_lib wrapper.exp |
23834577 PE |
57 | |
58 | # Useful for debugging. Pass the name of a variable and the verbosity | |
59 | # threshold (number of -v's on the command line). | |
60 | proc v3track { var n } { | |
61 | upvar $var val | |
62 | verbose "++ $var is $val" $n | |
63 | } | |
b3f2a032 | 64 | |
caf21254 | 65 | # Called by v3-init below. "Static" to this file. |
d8fe7b29 | 66 | proc v3-copy-files {srcfiles} { |
b3f2a032 | 67 | foreach f $srcfiles { |
caf21254 | 68 | if { [catch { set symlink [file readlink $f] } x] } then { |
d8fe7b29 | 69 | remote_download target $f |
caf21254 PE |
70 | } else { |
71 | if { [regexp "^/" "$symlink"] } then { | |
d8fe7b29 | 72 | remote_download target $symlink |
caf21254 PE |
73 | } else { |
74 | set dirname [file dirname $f] | |
d8fe7b29 | 75 | remote_download target $dirname/$symlink |
caf21254 PE |
76 | } |
77 | } | |
b3f2a032 PE |
78 | } |
79 | } | |
80 | ||
23834577 PE |
81 | # Called once, during runtest.exp setup. |
82 | proc libstdc++_init { testfile } { | |
83 | global env | |
93cc82d1 | 84 | global v3-sharedlib v3-libgomp |
d8fe7b29 | 85 | global srcdir blddir objdir tool_root_dir |
6116ca65 | 86 | global cc cxx cxxflags cxxpchflags cxxldflags |
b3f2a032 | 87 | global includes |
b3f2a032 | 88 | global gluefile wrap_flags |
1df8e834 | 89 | global ld_library_path |
23834577 | 90 | global target_triplet |
5f90c88f | 91 | global flags_file |
b3f2a032 | 92 | |
5305b1ae BK |
93 | # We set LC_ALL and LANG to C so that we get the same error |
94 | # messages as expected. | |
690e11b8 AP |
95 | setenv LC_ALL C |
96 | setenv LANG C | |
97 | ||
b3f2a032 | 98 | set blddir [lookfor_file [get_multilibs] libstdc++-v3] |
23834577 PE |
99 | set flags_file "${blddir}/scripts/testsuite_flags" |
100 | v3track flags_file 2 | |
101 | ||
102 | # If a test doesn't have special options, use DEFAULT_CXXFLAGS. | |
103 | # Use this variable if the behavior | |
104 | # 1) only applies to libstdc++ testing | |
105 | # 2) might need to be negated | |
106 | # In particular, some tests have to be run without precompiled | |
107 | # headers, or without assertions. | |
108 | global DEFAULT_CXXFLAGS | |
109 | if ![info exists DEFAULT_CXXFLAGS] then { | |
8b60fb43 | 110 | set DEFAULT_CXXFLAGS "" |
23834577 PE |
111 | # Host specific goo here. |
112 | if { [string match "powerpc-*-darwin*" $target_triplet] } { | |
113 | append DEFAULT_CXXFLAGS " -multiply_defined suppress" | |
114 | } | |
115 | } | |
116 | v3track DEFAULT_CXXFLAGS 2 | |
b3f2a032 PE |
117 | |
118 | # By default, we assume we want to run program images. | |
119 | global dg-do-what-default | |
120 | set dg-do-what-default run | |
121 | ||
122 | # Copy any required data files. | |
d8fe7b29 DJ |
123 | v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"] |
124 | v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"] | |
b3f2a032 | 125 | |
bdfb7c6d BK |
126 | set ld_library_path_tmp "" |
127 | ||
645112dd | 128 | # Locate libgcc.a so we don't need to account for different values of |
b3f2a032 PE |
129 | # SHLIB_EXT on different platforms |
130 | set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] | |
131 | if {$gccdir != ""} { | |
caf21254 | 132 | set gccdir [file dirname $gccdir] |
bdfb7c6d | 133 | append ld_library_path_tmp ":${gccdir}" |
b3f2a032 | 134 | } |
23834577 | 135 | v3track gccdir 3 |
b3f2a032 | 136 | |
bdfb7c6d | 137 | # Locate libgomp. This is only required for parallel mode. |
93cc82d1 | 138 | set v3-libgomp 0 |
bdfb7c6d BK |
139 | set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.so] |
140 | if {$libgompdir != ""} { | |
93cc82d1 | 141 | set v3-libgomp 1 |
bdfb7c6d BK |
142 | set libgompdir [file dirname $libgompdir] |
143 | append ld_library_path_tmp ":${libgompdir}" | |
93cc82d1 | 144 | verbose -log "libgomp support detected" |
bdfb7c6d BK |
145 | } |
146 | v3track libgompdir 3 | |
147 | ||
148 | # Locate libstdc++ shared library. (ie libstdc++.so.) | |
2f9f6cef BK |
149 | set v3-sharedlib 0 |
150 | set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so] | |
151 | if {$sharedlibdir != ""} { | |
f05c19d1 | 152 | if { [string match "*-*-linux*" $target_triplet] && [isnative] } { |
f81ab296 BK |
153 | set v3-sharedlib 1 |
154 | verbose -log "shared library support detected" | |
155 | } | |
2f9f6cef BK |
156 | } |
157 | v3track v3-sharedlib 3 | |
158 | ||
645112dd | 159 | # Compute what needs to be added to the existing LD_LIBRARY_PATH. |
0b3deaaf | 160 | if {$gccdir != ""} { |
0b3deaaf | 161 | set compiler ${gccdir}/g++ |
bdfb7c6d | 162 | set ld_library_path ${ld_library_path_tmp} |
0b3deaaf MM |
163 | append ld_library_path ":${blddir}/src/.libs" |
164 | ||
165 | if { [is_remote host] == 0 && [which $compiler] != 0 } { | |
166 | foreach i "[exec $compiler --print-multi-lib]" { | |
167 | set mldir "" | |
615baed7 | 168 | regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir |
0b3deaaf MM |
169 | set mldir [string trimright $mldir "\;@"] |
170 | if { "$mldir" == "." } { | |
171 | continue | |
172 | } | |
173 | if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { | |
174 | append ld_library_path ":${gccdir}/${mldir}" | |
175 | } | |
176 | } | |
177 | } | |
b3f2a032 | 178 | |
0b3deaaf MM |
179 | set_ld_library_path_env_vars |
180 | if [info exists env(LD_LIBRARY_PATH)] { | |
181 | verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)" | |
182 | } | |
183 | } else { | |
184 | set compiler [transform "g++"] | |
1df8e834 | 185 | } |
b3f2a032 | 186 | |
fa6763a6 DJ |
187 | # Default settings. |
188 | set cxx [transform "g++"] | |
189 | set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0" | |
6116ca65 | 190 | set cxxpchflags "" |
fa6763a6 DJ |
191 | set cxxldflags "" |
192 | set cc [transform "gcc"] | |
193 | # Locate testsuite_hooks.h and other testsuite headers. | |
194 | set includes "-I${srcdir}/util" | |
6cd5b96f | 195 | # Adapt the defaults for special circumstances. |
b3f2a032 | 196 | if [is_remote host] { |
6cd5b96f MM |
197 | # A remote host does not, in general, have access to the |
198 | # $srcdir so we copy the testsuite headers into the current | |
199 | # directory, and then add that to the search path. | |
200 | foreach src [glob "${srcdir}/util/*.h" \ | |
201 | "${srcdir}/util/*.cc" \ | |
202 | "${srcdir}/util/*/*.hpp" \ | |
203 | "${srcdir}/util/*/*.cc" \ | |
204 | "${srcdir}/util/*/*.hpp" \ | |
205 | "${srcdir}/util/*/*/*.cc" \ | |
206 | "${srcdir}/util/*/*/*.hpp" \ | |
207 | "${srcdir}/util/*/*/*/*.cc" \ | |
208 | "${srcdir}/util/*/*/*/*.hpp" \ | |
209 | "${srcdir}/util/*/*/*/*/*.cc" \ | |
210 | "${srcdir}/util/*/*/*/*/*.hpp" ] { | |
211 | # Remove everything up to "util/..." | |
212 | set dst [string range $src [string length "${srcdir}/"] end] | |
213 | # Create the directory containing the file. | |
214 | set dir [file dirname $dst] | |
215 | remote_exec host "mkdir" [list "-p" "$dir"] | |
6c1e7e26 | 216 | # Download the file. |
6cd5b96f MM |
217 | set result [remote_download host $src $dst] |
218 | if { $result == "" } { | |
6c1e7e26 | 219 | verbose -log "Unable to download ${srcdir}/${src} to host." |
6cd5b96f MM |
220 | return "untested" |
221 | } | |
222 | } | |
223 | set includes "-Iutil" | |
224 | } elseif { [file exists $flags_file] } { | |
b3f2a032 | 225 | # If we find a testsuite_flags file, we're testing in the build dir. |
6cd5b96f MM |
226 | set cxx [exec sh $flags_file --build-cxx] |
227 | set cxxflags [exec sh $flags_file --cxxflags] | |
6116ca65 | 228 | set cxxpchflags [exec sh $flags_file --cxxpchflags] |
6c1e7e26 NS |
229 | set cxxldflags [exec sh $flags_file --cxxldflags] |
230 | set cc [exec sh $flags_file --build-cc] | |
6cd5b96f | 231 | set includes [exec sh $flags_file --build-includes] |
b3f2a032 | 232 | } |
bd1a56a0 BK |
233 | append cxxflags " " |
234 | append cxxflags [getenv CXXFLAGS] | |
235 | v3track cxxflags 2 | |
b3f2a032 | 236 | |
b5b3739a MM |
237 | # Always use MO files built by this test harness. |
238 | set cxxflags "$cxxflags -DLOCALEDIR=\".\"" | |
6c1e7e26 | 239 | set ccflags "$cxxflags -DLOCALEDIR=\".\"" |
b5b3739a | 240 | |
8b60fb43 MM |
241 | # If a PCH file is available, use it. We must delay performing |
242 | # this check until $cxx and such have been initialized because we | |
243 | # perform a test compilation. (Ideally, gcc --print-file-name would | |
244 | # list PCH files, but it does not.) | |
6116ca65 | 245 | if { $cxxpchflags != "" } { |
8b60fb43 MM |
246 | set src "config[pid].cc" |
247 | set f [open $src "w"] | |
248 | puts $f "int main () {}" | |
249 | close $f | |
250 | ||
6116ca65 BK |
251 | # Fixme: "additional_flags=$cxxpchflags" fails, but would be |
252 | # useful as then the requested variant of the pre-build PCH | |
253 | # files could be tested to see if it works. | |
8b60fb43 | 254 | set lines [v3_target_compile $src "config[pid].o" object \ |
6116ca65 BK |
255 | "additional_flags=-include additional_flags=bits/stdc++.h"] |
256 | if { $lines != "" } { | |
257 | verbose -log "Requested PCH file: $cxxpchflags" | |
258 | verbose -log "is not working, and will not be used." | |
259 | set cxxpchflags "" | |
260 | } | |
8b60fb43 | 261 | file delete $src |
6116ca65 BK |
262 | } |
263 | v3track cxxpchflags 2 | |
264 | ||
265 | global PCH_CXXFLAGS | |
266 | if ![info exists PCH_CXXFLAGS] then { | |
267 | set PCH_CXXFLAGS $cxxpchflags | |
8b60fb43 MM |
268 | v3track PCH_CXXFLAGS 2 |
269 | } | |
270 | ||
d1fb5e1c | 271 | libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions" |
b3f2a032 PE |
272 | } |
273 | ||
ebd9dfc9 | 274 | # Callback for cleanup routines. |
446e8778 RE |
275 | proc libstdc++_exit { } { |
276 | global gluefile; | |
277 | ||
278 | if [info exists gluefile] { | |
279 | file_on_build delete $gluefile; | |
280 | unset gluefile; | |
281 | } | |
282 | } | |
283 | ||
b3f2a032 | 284 | # Callback from system dg-test. |
caf21254 | 285 | proc libstdc++-dg-test { prog do_what extra_tool_flags } { |
b3f2a032 | 286 | # Set up the compiler flags, based on what we're going to do. |
b3f2a032 | 287 | switch $do_what { |
caf21254 PE |
288 | "preprocess" { |
289 | set compile_type "preprocess" | |
290 | set output_file "[file rootname [file tail $prog]].i" | |
291 | } | |
292 | "compile" { | |
293 | set compile_type "assembly" | |
294 | set output_file "[file rootname [file tail $prog]].s" | |
295 | } | |
296 | "assemble" { | |
297 | set compile_type "object" | |
298 | set output_file "[file rootname [file tail $prog]].o" | |
299 | } | |
300 | "link" { | |
301 | set compile_type "executable" | |
302 | set output_file "./[file rootname [file tail $prog]].exe" | |
303 | } | |
304 | "run" { | |
305 | set compile_type "executable" | |
306 | # FIXME: "./" is to cope with "." not being in $PATH. | |
307 | # Should this be handled elsewhere? | |
308 | # YES. | |
309 | set output_file "./[file rootname [file tail $prog]].exe" | |
310 | # This is the only place where we care if an executable was | |
311 | # created or not. If it was, dg.exp will try to run it. | |
8e289297 | 312 | catch { remote_file build delete $output_file } |
caf21254 | 313 | } |
cddfb1c7 | 314 | default { |
caf21254 PE |
315 | perror "$do_what: not a valid dg-do keyword" |
316 | return "" | |
317 | } | |
b3f2a032 | 318 | } |
cddfb1c7 | 319 | |
0ded1615 BK |
320 | # Short-circut a bunch of complicated goo here for the special |
321 | # case of compiling a test file as a "C" file, not as C++. Why? So | |
322 | # -nostdc++ doesn't trip us up. So all the extra object files | |
323 | # don't trip us up. So automatically linking in libstdc++ doesn't | |
324 | # happen. So CXXFLAGS don't error. | |
3c6430a3 | 325 | set select_compile "v3_target_compile" |
b3f2a032 PE |
326 | set options "" |
327 | if { $extra_tool_flags != "" } { | |
cddfb1c7 BK |
328 | verbose -log "extra_tool_flags are:" |
329 | verbose -log $extra_tool_flags | |
330 | if { [string first "-x c" $extra_tool_flags ] != -1 } { | |
cddfb1c7 | 331 | verbose -log "compiling and executing as C, not C++" |
3c6430a3 BK |
332 | set edit_tool_flags $extra_tool_flags |
333 | regsub -all ".x c" $edit_tool_flags "" edit_tool_flags | |
334 | lappend options "additional_flags=$edit_tool_flags" | |
3c6430a3 | 335 | set select_compile "v3_target_compile_as_c" |
cddfb1c7 BK |
336 | } else { |
337 | lappend options "additional_flags=$extra_tool_flags" | |
338 | } | |
b3f2a032 PE |
339 | } |
340 | ||
23834577 PE |
341 | # There is a libstdc++_compile made for us by default (via the tool- |
342 | # and-target file), but the defaults are lacking in goodness. | |
3c6430a3 | 343 | set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]; |
b3f2a032 PE |
344 | set comp_output [ prune_g++_output $comp_output ]; |
345 | ||
346 | return [list $comp_output $output_file] | |
347 | } | |
348 | ||
0b3deaaf | 349 | # True if the library supports wchar_t. |
0b694555 | 350 | set v3-wchar_t 0 |
0b3deaaf MM |
351 | |
352 | # True if the library supports threads. | |
0b694555 | 353 | set v3-threads 0 |
0b3deaaf | 354 | |
84946e72 BK |
355 | # True if the library supports symbol versioning. |
356 | set v3-symver 0 | |
357 | ||
caf21254 | 358 | # Called from libstdc++-dg-test above. Calls back into system's |
b3f2a032 | 359 | # target_compile to actually do the work. |
caf21254 | 360 | proc v3_target_compile { source dest type options } { |
b3f2a032 PE |
361 | global gluefile |
362 | global wrap_flags | |
363 | global cxx | |
364 | global cxxflags | |
952c7b74 | 365 | global cxxldflags |
b3f2a032 | 366 | global includes |
b3f2a032 PE |
367 | |
368 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
caf21254 PE |
369 | lappend options "libs=${gluefile}" |
370 | lappend options "ldflags=${wrap_flags}" | |
b3f2a032 PE |
371 | } |
372 | ||
373 | set cxx_final $cxx | |
374 | set cxxlibglossflags [libgloss_link_flags] | |
375 | set cxx_final [concat $cxx_final $cxxlibglossflags] | |
376 | set cxx_final [concat $cxx_final $cxxflags] | |
377 | set cxx_final [concat $cxx_final $includes] | |
31a7113e BK |
378 | |
379 | # Flag setting based on type argument. | |
0b3deaaf | 380 | if { $type == "executable" } { |
31a7113e | 381 | # Link the support objects into executables. |
952c7b74 | 382 | set cxx_final [concat $cxx_final $cxxldflags] |
0ded1615 | 383 | lappend options "additional_flags=./libtestc++.a" |
31a7113e BK |
384 | } else { |
385 | if { $type == "sharedlib" } { | |
386 | # Don't link in anything. | |
387 | set type "executable" | |
388 | } | |
0b3deaaf | 389 | } |
b3f2a032 PE |
390 | |
391 | lappend options "compiler=$cxx_final" | |
a0895ebf | 392 | lappend options "timeout=600" |
b3f2a032 | 393 | |
b3f2a032 PE |
394 | return [target_compile $source $dest $type $options] |
395 | } | |
396 | ||
5305b1ae | 397 | |
3c6430a3 BK |
398 | # Called from libstdc++-dg-test above, but only for "C" compilation. |
399 | # Calls back into system's target_compile to actually do the work. | |
400 | proc v3_target_compile_as_c { source dest type options } { | |
401 | global gluefile | |
402 | global wrap_flags | |
403 | global includes | |
5f90c88f | 404 | global flags_file |
9e451553 | 405 | global blddir |
6c1e7e26 | 406 | global cc |
c2ba9709 | 407 | global cxxflags |
3c6430a3 BK |
408 | |
409 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
410 | lappend options "libs=${gluefile}" | |
411 | lappend options "ldflags=${wrap_flags}" | |
412 | } | |
413 | ||
414 | set tname [target_info name] | |
5f90c88f BK |
415 | set cc_final $cc |
416 | set cxxlibglossflags [libgloss_link_flags] | |
3c6430a3 | 417 | set cc_final [concat $cc_final $cxxlibglossflags] |
c2ba9709 | 418 | set cc_final [concat $cc_final $cxxflags] |
3c6430a3 | 419 | set cc_final [concat $cc_final $includes] |
8f1a19e2 | 420 | regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final |
3c6430a3 | 421 | |
5f90c88f BK |
422 | # This is needed for "C" tests, as this type of test may need the |
423 | # C++ includes. And if we're not testing in the build directory, | |
6cd5b96f MM |
424 | # the includes variable is not likely to include the necessary |
425 | # info. | |
5f90c88f | 426 | if { ![file exists $flags_file] } { |
357480ce MM |
427 | # ??? We need a --print-include-dirs option to GCC, so that |
428 | # we can avoid these hacks. The heuristics here will not | |
429 | # work with non-standard --with-includedir= options. | |
6cd5b96f | 430 | set version [remote_exec host ${cc} -dumpversion] |
7504beb4 MM |
431 | # Remove the trailing newline from the output. |
432 | set version [string trimright [lindex $version 1]] | |
433 | set machine [remote_exec host ${cc} -dumpmachine] | |
434 | set machine [string trimright [lindex $machine 1]] | |
6cd5b96f MM |
435 | set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1] |
436 | set comp_base_dir [lindex $comp_base_dir 1] | |
437 | set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]] | |
357480ce MM |
438 | # For a cross compiler, the header files will be located in a |
439 | # machine-specific subdirectory. | |
440 | set crossbase "${comp_base_dir}/${machine}/include/c++/${version}" | |
441 | set crosstarget "${crossbase}/${machine}" | |
442 | set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"] | |
443 | # For a native compiler, the header files will be located at | |
444 | # the top level. | |
5f90c88f BK |
445 | set includesbase "${comp_base_dir}/include/c++/${version}" |
446 | set includestarget "${includesbase}/${machine}" | |
447 | set cc_final [concat $cc_final "-I$includesbase -I$includestarget"] | |
9e451553 | 448 | |
d466a7e2 | 449 | set libdir "-L${comp_base_dir}/lib" |
9e451553 | 450 | } else { |
d466a7e2 BK |
451 | set libdir "-L${blddir}/libsupc++/.libs" |
452 | set libdir [concat $libdir "-L${blddir}/src/.libs"] | |
5f90c88f BK |
453 | } |
454 | ||
d466a7e2 | 455 | set cc_final [concat $cc_final "$libdir"] |
9e451553 | 456 | |
3c6430a3 BK |
457 | lappend options "compiler=$cc_final" |
458 | lappend options "timeout=600" | |
459 | ||
460 | return [target_compile $source $dest $type $options] | |
461 | } | |
462 | ||
0b3deaaf | 463 | # Build the support objects linked in with the libstdc++ tests. In |
0ded1615 | 464 | # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately. |
451e92db | 465 | proc v3-build_support { } { |
43e03430 | 466 | global env |
c85b032a | 467 | global srcdir |
0b694555 MM |
468 | global v3-wchar_t |
469 | global v3-threads | |
84946e72 | 470 | global v3-symver |
2f9f6cef | 471 | global v3-sharedlib |
0b3deaaf MM |
472 | |
473 | # Figure out whether or not the library supports certain features. | |
0b694555 MM |
474 | set v3-wchar_t 0 |
475 | set v3-threads 0 | |
84946e72 | 476 | set v3-symver 0 |
0ded1615 | 477 | set libtest_objs "" |
0b3deaaf MM |
478 | |
479 | set config_src "config.cc" | |
7cff41e8 | 480 | set config_out "config.ii" |
0b3deaaf MM |
481 | set f [open $config_src "w"] |
482 | puts $f "#include <bits/c++config.h>" | |
08cce8fe | 483 | puts $f "#include <bits/gthr.h>" |
0b3deaaf | 484 | close $f |
7cff41e8 JM |
485 | v3_target_compile $config_src $config_out preprocess "additional_flags=-dN" |
486 | set file [open $config_out r] | |
487 | set preprocessed [read $file] | |
488 | close $file | |
08cce8fe MM |
489 | if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } { |
490 | verbose -log "wchar_t support detected" | |
491 | set v3-wchar_t 1 | |
492 | } | |
84946e72 BK |
493 | if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } { |
494 | verbose -log "symbol versioning support detected" | |
495 | set v3-symver 1 | |
496 | } | |
08cce8fe MM |
497 | if { [string first "__GTHREADS" $preprocessed] != -1 } { |
498 | verbose -log "thread support detected" | |
499 | set v3-threads 1 | |
0b3deaaf | 500 | } |
c85b032a | 501 | |
b5b3739a MM |
502 | # Try to build the MO files that are used by some of the locale |
503 | # tests. If we can't build them, that's OK; it just means that | |
504 | # those tests will fail. | |
505 | foreach lang [list "fr" "de"] { | |
506 | catch { | |
507 | file mkdir "$lang/LC_MESSAGES" | |
508 | remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po" | |
509 | if [is_remote host] { | |
510 | remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES" | |
511 | remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo" | |
512 | } | |
513 | } | |
514 | } | |
515 | ||
0b3deaaf | 516 | # Build the support objects. |
4569a895 AT |
517 | set source_files [list testsuite_abi.cc testsuite_allocator.cc \ |
518 | testsuite_character.cc testsuite_hooks.cc \ | |
2e3f9c21 | 519 | io/verified_cmd_line_input.cc \ |
a86151e1 | 520 | io/prog_bar.cc performance/time/elapsed_timer.cc ] |
0b3deaaf | 521 | foreach f $source_files { |
4569a895 AT |
522 | set obj [file rootname $f].o |
523 | set object_file [file tail $obj] | |
510d8ecc MM |
524 | # Compile with "-w" so that warnings issued by the compiler |
525 | # do not prevent compilation. | |
3416d7cd | 526 | if { [v3_target_compile $srcdir/util/$f $object_file "object" \ |
510d8ecc | 527 | [list "incdir=$srcdir" "additional_flags=-w"]] |
0b3deaaf MM |
528 | != "" } { |
529 | error "could not compile $f" | |
530 | } | |
0ded1615 | 531 | append libtest_objs "$object_file " |
b3f2a032 | 532 | } |
2f9f6cef | 533 | |
4569a895 | 534 | # Collect into libtestc++.a |
6ed80bc4 HPN |
535 | if [info exists env(AR)] { |
536 | set ar $env(AR) | |
43e03430 HPN |
537 | } else { |
538 | set ar [transform "ar"] | |
539 | } | |
7cff41e8 JM |
540 | set arargs "-rc ./libtestc++.a ${libtest_objs}" |
541 | verbose -log "$ar $arargs" | |
542 | set result [lindex [remote_exec host "$ar" "$arargs"] 0] | |
4569a895 AT |
543 | verbose "link result is $result" |
544 | if { $result == 0 } { | |
6ed80bc4 HPN |
545 | if [info exists env(RANLIB)] { |
546 | set ranlib $env(RANLIB) | |
43e03430 HPN |
547 | } else { |
548 | set ranlib [transform "ranlib"] | |
549 | } | |
7cff41e8 JM |
550 | set ranlibargs "./libtestc++.a" |
551 | verbose -log "$ranlib $ranlibargs" | |
552 | set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0] | |
4569a895 AT |
553 | if { $result != 0 } { |
554 | error "could not link libtestc++.a" | |
4569a895 AT |
555 | } |
556 | } | |
557 | ||
558 | # Build any shared objects needed for regression testing. | |
2f9f6cef | 559 | if { ${v3-sharedlib} == 1 } { |
4569a895 | 560 | set source_files [list testsuite_shared.cc] |
2f9f6cef BK |
561 | foreach f $source_files { |
562 | set object_file [file rootname $f].so | |
563 | # Compile with "-w" so that warnings issued by the compiler | |
564 | # do not prevent compilation. | |
3416d7cd | 565 | if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \ |
2f9f6cef BK |
566 | [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]] |
567 | != "" } { | |
568 | error "could not compile $f" | |
569 | } | |
570 | } | |
571 | } | |
572 | } | |
573 | ||
0c20e4ec NS |
574 | proc check_v3_target_fileio { } { |
575 | global et_fileio_saved | |
576 | global et_fileio_target_name | |
577 | global tool | |
578 | ||
579 | if { ![info exists et_fileio_target_name] } { | |
580 | set et_fileio_target_name "" | |
581 | } | |
582 | ||
583 | # If the target has changed since we set the cached value, clear it. | |
584 | set current_target [current_target_name] | |
585 | if { $current_target != $et_fileio_target_name } { | |
586 | verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2 | |
587 | set et_fileio_target_name $current_target | |
588 | if [info exists et_fileio_saved] { | |
589 | verbose "check_v3_target_fileio: removing cached result" 2 | |
590 | unset et_fileio_saved | |
591 | } | |
592 | } | |
593 | ||
594 | if [info exists et_fileio_saved] { | |
595 | verbose "check_v3_target_fileio: using cached result" 2 | |
596 | } else { | |
597 | set et_fileio_saved 0 | |
598 | ||
599 | # Set up, compile, and execute a C++ test program that tries to use | |
600 | # the file functions | |
601 | set src fileio[pid].cc | |
602 | set exe fileio[pid].x | |
603 | ||
604 | set f [open $src "w"] | |
605 | puts $f "#include <sys/types.h>" | |
606 | puts $f "#include <sys/stat.h>" | |
607 | puts $f "#include <fcntl.h>" | |
608 | puts $f "#include <unistd.h>" | |
609 | puts $f "#include <errno.h>" | |
610 | puts $f "using namespace std;" | |
611 | puts $f "int main ()" | |
612 | puts $f "{" | |
613 | puts $f " int fd = open (\".\", O_RDONLY);" | |
23b72f17 | 614 | puts $f " int ret = 0;" |
0c20e4ec NS |
615 | puts $f " if (fd == -1)" |
616 | puts $f " {" | |
617 | puts $f " int err = errno;" | |
618 | puts $f " if (err == EIO || err == ENOSYS)" | |
23b72f17 | 619 | puts $f " ret = 1;" |
0c20e4ec NS |
620 | puts $f " }" |
621 | puts $f " else" | |
23b72f17 RS |
622 | puts $f " {" |
623 | puts $f " if (lseek (fd, 0, SEEK_CUR) == -1)" | |
624 | puts $f " ret = 1;" | |
0c20e4ec | 625 | puts $f " close (fd);" |
23b72f17 RS |
626 | puts $f " }" |
627 | puts $f " return ret;" | |
0c20e4ec NS |
628 | puts $f "}" |
629 | close $f | |
630 | ||
631 | set lines [v3_target_compile $src $exe executable ""] | |
632 | file delete $src | |
633 | ||
634 | if [string match "" $lines] { | |
635 | # No error message, compilation succeeded. | |
636 | set result [${tool}_load "./$exe" "" ""] | |
637 | set status [lindex $result 0] | |
638 | remote_file build delete $exe | |
639 | ||
640 | verbose "check_v3_target_fileio: status is <$status>" 2 | |
641 | ||
642 | if { $status == "pass" } { | |
643 | set et_fileio_saved 1 | |
644 | } | |
645 | } else { | |
646 | verbose "check_v3_target_fileio: compilation failed" 2 | |
647 | } | |
648 | } | |
649 | return $et_fileio_saved | |
650 | } | |
651 | ||
803f183a | 652 | # Eventually we want C90/C99 determining and switching from this. |
7c62b943 BK |
653 | proc check_v3_target_c_std { } { |
654 | global et_c_std_saved | |
655 | global et_c_std_target_name | |
656 | global tool | |
657 | ||
658 | if { ![info exists et_c_std_target_name] } { | |
659 | set et_c_std_target_name "" | |
660 | } | |
661 | ||
662 | # If the target has changed since we set the cached value, clear it. | |
663 | set current_target [current_target_name] | |
664 | if { $current_target != $et_c_std_target_name } { | |
665 | verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2 | |
666 | set et_c_std_target_name $current_target | |
667 | if [info exists et_c_std_saved] { | |
668 | verbose "check_v3_target_c_std: removing cached result" 2 | |
669 | unset et_c_std_saved | |
670 | } | |
671 | } | |
672 | ||
673 | if [info exists et_c_std_saved] { | |
674 | verbose "check_v3_target_c_std: using cached result" 2 | |
675 | } else { | |
676 | set et_c_std_saved 0 | |
677 | ||
678 | # Set up, compile, and execute a C++ test program that tries to use | |
679 | # C99 functionality. | |
803f183a | 680 | # For math bits, could use check_effective_target_c99_math. |
7c62b943 BK |
681 | set src fileio[pid].cc |
682 | set exe fileio[pid].x | |
683 | ||
684 | set f [open $src "w"] | |
685 | puts $f "#include <tr1/cmath>" | |
803f183a | 686 | puts $f "#include <cstdlib>" |
7c62b943 BK |
687 | puts $f "int main ()" |
688 | puts $f "{" | |
689 | puts $f " float f = 45.55;" | |
690 | puts $f " int i = std::tr1::isnan(f);" | |
803f183a BK |
691 | puts $f " " |
692 | puts $f " using std::wctomb;" | |
0d3f1ce4 | 693 | puts $f " return i;" |
7c62b943 BK |
694 | puts $f "}" |
695 | close $f | |
696 | ||
697 | set lines [v3_target_compile $src $exe executable ""] | |
698 | file delete $src | |
699 | ||
700 | if [string match "" $lines] { | |
701 | # No error message, compilation succeeded. | |
702 | set result [${tool}_load "./$exe" "" ""] | |
703 | set status [lindex $result 0] | |
704 | remote_file build delete $exe | |
705 | ||
706 | verbose "check_v3_target_c_std: status is <$status>" 2 | |
707 | ||
708 | if { $status == "pass" } { | |
709 | set et_c_std_saved 1 | |
710 | } | |
711 | } else { | |
712 | verbose "check_v3_target_c_std: compilation failed" 2 | |
713 | } | |
714 | } | |
715 | return $et_c_std_saved | |
716 | } | |
717 | ||
2f9f6cef BK |
718 | proc check_v3_target_sharedlib { } { |
719 | global v3-sharedlib | |
720 | return ${v3-sharedlib} | |
b3f2a032 | 721 | } |
f63a8495 | 722 | |
0c20e4ec NS |
723 | proc check_v3_target_time { } { |
724 | global et_time_saved | |
725 | global et_time_target_name | |
726 | global tool | |
727 | ||
728 | if { ![info exists et_time_target_name] } { | |
729 | set et_time_target_name "" | |
730 | } | |
731 | ||
732 | # If the target has changed since we set the cached value, clear it. | |
733 | set current_target [current_target_name] | |
734 | if { $current_target != $et_time_target_name } { | |
735 | verbose "check_v3_target_time: `$et_time_target_name'" 2 | |
736 | set et_time_target_name $current_target | |
737 | if [info exists et_time_saved] { | |
738 | verbose "check_v3_target_time: removing cached result" 2 | |
739 | unset et_time_saved | |
740 | } | |
741 | } | |
742 | ||
743 | if [info exists et_time_saved] { | |
744 | verbose "check_v3_target_time: using cached result" 2 | |
745 | } else { | |
746 | set et_time_saved 0 | |
747 | ||
748 | # Set up and compile a C++ test program that tries to use | |
749 | # the time function | |
750 | set src time[pid].cc | |
751 | set exe time[pid].x | |
752 | ||
753 | set f [open $src "w"] | |
754 | puts $f "#include <time.h>" | |
755 | puts $f "using namespace std;" | |
756 | puts $f "int main ()" | |
757 | puts $f "{" | |
758 | puts $f " time (0);" | |
759 | puts $f "}" | |
760 | close $f | |
761 | ||
762 | set lines [v3_target_compile $src $exe executable ""] | |
763 | file delete $src | |
764 | ||
765 | if [string match "" $lines] { | |
766 | # No error message, compilation succeeded. | |
767 | verbose "check_v3_target_time: compilation succeeded" 2 | |
768 | remote_file build delete $exe | |
769 | set et_time_saved 1 | |
770 | } else { | |
771 | verbose "check_v3_target_time: compilation failed" 2 | |
772 | } | |
773 | } | |
774 | return $et_time_saved | |
775 | } | |
776 | ||
f5783e34 CJ |
777 | proc check_v3_target_rvalref { } { |
778 | global et_rvalref_saved | |
779 | global et_rvalref_target_name | |
780 | global tool | |
781 | ||
782 | if { ![info exists et_rvalref_target_name] } { | |
783 | set et_rvalref_target_name "" | |
784 | } | |
785 | ||
786 | # If the target has changed since we set the cached value, clear it. | |
787 | set current_target [current_target_name] | |
788 | if { $current_target != $et_rvalref_target_name } { | |
789 | verbose "check_v3_target_rvalref: `$et_rvalref_target_name'" 2 | |
790 | set et_rvalref_target_name $current_target | |
791 | if [info exists et_rvalref_saved] { | |
792 | verbose "check_v3_target_rvalref: removing cached result" 2 | |
793 | unset et_rvalref_saved | |
794 | } | |
795 | } | |
796 | ||
797 | if [info exists et_rvalref_saved] { | |
798 | verbose "check_v3_target_rvalref: using cached result" 2 | |
799 | } else { | |
800 | set et_rvalref_saved 0 | |
801 | ||
802 | # Set up and compile a C++ test program that tries to use | |
803 | # the library components of rval references | |
804 | set src rvalref[pid].cc | |
805 | set exe rvalref[pid].x | |
806 | ||
807 | set f [open $src "w"] | |
808 | puts $f "#include <iterator>" | |
809 | puts $f "#include <utility>" | |
810 | puts $f "using std::move;" | |
811 | puts $f "using std::identity;" | |
812 | puts $f "using std::forward;" | |
813 | puts $f "using std::move_iterator;" | |
814 | puts $f "using std::make_move_iterator;" | |
815 | close $f | |
816 | ||
817 | set lines [v3_target_compile $src $exe executable ""] | |
818 | file delete $src | |
819 | ||
820 | if [string match "" $lines] { | |
821 | # No error message, compilation succeeded. | |
822 | verbose "check_v3_target_rvalref: compilation succeeded" 2 | |
823 | remote_file build delete $exe | |
824 | set et_rvalref_saved 1 | |
825 | } else { | |
826 | verbose "check_v3_target_rvalref: compilation failed" 2 | |
827 | } | |
828 | } | |
829 | return $et_rvalref_saved | |
830 | } | |
831 | ||
f63a8495 PC |
832 | proc check_v3_target_namedlocale { } { |
833 | global et_namedlocale_saved | |
834 | global et_namedlocale_target_name | |
835 | global tool | |
836 | ||
837 | if { ![info exists et_namedlocale_target_name] } { | |
838 | set et_namedlocale_target_name "" | |
839 | } | |
840 | ||
841 | # If the target has changed since we set the cached value, clear it. | |
842 | set current_target [current_target_name] | |
843 | if { $current_target != $et_namedlocale_target_name } { | |
844 | verbose "check_v3_target_namedlocale: `$et_namedlocale_target_name'" 2 | |
845 | set et_namedlocale_target_name $current_target | |
846 | if [info exists et_namedlocale_saved] { | |
847 | verbose "check_v3_target_namedlocale: removing cached result" 2 | |
848 | unset et_namedlocale_saved | |
849 | } | |
850 | } | |
851 | ||
852 | if [info exists et_namedlocale_saved] { | |
853 | verbose "check_v3_target_namedlocale: using cached result" 2 | |
854 | } else { | |
855 | set et_namedlocale_saved 0 | |
856 | ||
857 | # Set up, compile, and execute a C++ test program that tries to use | |
858 | # all the required named locales. | |
859 | set src nlocale[pid].cc | |
860 | set exe nlocale[pid].x | |
861 | ||
862 | set f [open $src "w"] | |
863 | puts $f "#include <locale>" | |
864 | puts $f "using namespace std;" | |
865 | puts $f "int main ()" | |
866 | puts $f "{" | |
867 | puts $f " try" | |
868 | puts $f " {" | |
869 | puts $f " locale(\"\");" | |
870 | puts $f " locale(\"de_DE\");" | |
871 | puts $f " locale(\"de_DE.ISO-8859-15@euro\");" | |
872 | puts $f " locale(\"de_DE@euro\");" | |
873 | puts $f " locale(\"en_HK\");" | |
874 | puts $f " locale(\"en_PH\");" | |
875 | puts $f " locale(\"en_US\");" | |
876 | puts $f " locale(\"en_US.ISO-8859-1\");" | |
877 | puts $f " locale(\"en_US.ISO-8859-15\");" | |
878 | puts $f " locale(\"en_US.UTF-8\");" | |
879 | puts $f " locale(\"es_ES\");" | |
880 | puts $f " locale(\"es_MX\");" | |
881 | puts $f " locale(\"fr_FR\");" | |
882 | puts $f " locale(\"fr_FR@euro\");" | |
883 | puts $f " locale(\"is_IS\");" | |
884 | puts $f " locale(\"is_IS.UTF-8\");" | |
885 | puts $f " locale(\"it_IT\");" | |
886 | puts $f " locale(\"ja_JP.eucjp\");" | |
887 | puts $f " locale(\"se_NO.UTF-8\");" | |
888 | puts $f " locale(\"ta_IN\");" | |
889 | puts $f " locale(\"zh_TW\");" | |
890 | puts $f " return 0;" | |
891 | puts $f " }" | |
892 | puts $f " catch(...)" | |
893 | puts $f " {" | |
894 | puts $f " return 1;" | |
895 | puts $f " }" | |
896 | puts $f "}" | |
897 | close $f | |
898 | ||
899 | set lines [v3_target_compile $src $exe executable ""] | |
900 | file delete $src | |
901 | ||
902 | if [string match "" $lines] { | |
903 | # No error message, compilation succeeded. | |
904 | set result [${tool}_load "./$exe" "" ""] | |
905 | set status [lindex $result 0] | |
906 | remote_file build delete $exe | |
907 | ||
908 | verbose "check_v3_target_namedlocale: status is <$status>" 2 | |
909 | ||
910 | if { $status == "pass" } { | |
911 | set et_namedlocale_saved 1 | |
912 | } | |
913 | } else { | |
914 | verbose "check_v3_target_namedlocale: compilation failed" 2 | |
915 | } | |
916 | } | |
917 | return $et_namedlocale_saved | |
918 | } | |
a1340af7 | 919 | |
451e92db BK |
920 | proc check_v3_target_debug_mode { } { |
921 | global cxxflags | |
922 | global et_debug_mode | |
451e92db BK |
923 | global tool |
924 | ||
925 | if { ![info exists et_debug_mode_target_name] } { | |
926 | set et_debug_mode_target_name "" | |
927 | } | |
928 | ||
929 | # If the target has changed since we set the cached value, clear it. | |
930 | set current_target [current_target_name] | |
931 | if { $current_target != $et_debug_mode_target_name } { | |
932 | verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2 | |
933 | set et_debug_mode_target_name $current_target | |
934 | if [info exists et_debug_mode] { | |
935 | verbose "check_v3_target_debug_mode: removing cached result" 2 | |
936 | unset et_debug_mode | |
937 | } | |
938 | } | |
939 | ||
940 | if [info exists et_debug_mode] { | |
941 | verbose "check_v3_target_debug_mode: using cached result" 2 | |
942 | } else { | |
943 | set et_debug_mode 0 | |
944 | ||
a7543cfd | 945 | # Set up and compile a C++ test program that depends |
cddfb1c7 | 946 | # on debug mode working. |
451e92db | 947 | set src debug_mode[pid].cc |
797308b2 | 948 | set exe debug_mode[pid].exe |
451e92db BK |
949 | |
950 | set f [open $src "w"] | |
951 | puts $f "#include <string>" | |
952 | puts $f "using namespace std;" | |
953 | puts $f "int main()" | |
954 | puts $f "{ return 0; }" | |
955 | close $f | |
956 | ||
957 | set cxxflags_saved $cxxflags | |
958 | set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG" | |
959 | set lines [v3_target_compile $src $exe executable ""] | |
960 | set cxxflags $cxxflags_saved | |
961 | file delete $src | |
962 | ||
963 | if [string match "" $lines] { | |
964 | # No error message, compilation succeeded. | |
965 | set et_debug_mode 1 | |
966 | } | |
967 | } | |
968 | verbose "check_v3_target_debug_mode: $et_debug_mode" 2 | |
969 | return $et_debug_mode | |
970 | } | |
c2ba9709 JS |
971 | |
972 | proc check_v3_target_parallel_mode { } { | |
973 | global cxxflags | |
93cc82d1 | 974 | global v3-libgomp |
c2ba9709 JS |
975 | global et_parallel_mode |
976 | ||
977 | global tool | |
978 | ||
979 | if { ![info exists et_parallel_mode_target_name] } { | |
980 | set et_parallel_mode_target_name "" | |
981 | } | |
982 | ||
983 | # If the target has changed since we set the cached value, clear it. | |
984 | set current_target [current_target_name] | |
985 | if { $current_target != $et_parallel_mode_target_name } { | |
986 | verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2 | |
987 | set et_parallel_mode_target_name $current_target | |
988 | if [info exists et_parallel_mode] { | |
989 | verbose "check_v3_target_parallel_mode: removing cached result" 2 | |
990 | unset et_parallel_mode | |
991 | } | |
992 | } | |
993 | ||
994 | if [info exists et_parallel_mode] { | |
995 | verbose "check_v3_target_parallel_mode: using cached result" 2 | |
996 | } else { | |
997 | set et_parallel_mode 0 | |
998 | ||
93cc82d1 PC |
999 | # If 'make check-parallel' is running the test succeeds. |
1000 | if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } { | |
c2ba9709 | 1001 | set et_parallel_mode 1 |
c2ba9709 JS |
1002 | } |
1003 | } | |
1004 | verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2 | |
1005 | return $et_parallel_mode | |
1006 | } | |
a7543cfd PC |
1007 | |
1008 | proc check_v3_target_cstdint { } { | |
1009 | global cxxflags | |
1010 | global DEFAULT_CXXFLAGS | |
1011 | global et_cstdint | |
1012 | ||
1013 | global tool | |
1014 | ||
1015 | if { ![info exists et_cstdint_target_name] } { | |
1016 | set et_cstdint_target_name "" | |
1017 | } | |
1018 | ||
1019 | # If the target has changed since we set the cached value, clear it. | |
1020 | set current_target [current_target_name] | |
1021 | if { $current_target != $et_cstdint_target_name } { | |
1022 | verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2 | |
1023 | set et_cstdint_target_name $current_target | |
1024 | if [info exists et_cstdint] { | |
1025 | verbose "check_v3_target_cstdint: removing cached result" 2 | |
1026 | unset et_cstdint | |
1027 | } | |
1028 | } | |
1029 | ||
1030 | if [info exists et_cstdint] { | |
1031 | verbose "check_v3_target_cstdint: using cached result" 2 | |
1032 | } else { | |
1033 | set et_cstdint 0 | |
1034 | ||
1035 | # Set up and compile a C++0x test program that depends | |
1036 | # on the C99 stdint facilities to be available. | |
1037 | set src cstdint[pid].cc | |
1038 | set exe cstdint[pid].exe | |
1039 | ||
1040 | set f [open $src "w"] | |
f2752f1d | 1041 | puts $f "#include <tr1/cstdint>" |
a7543cfd PC |
1042 | puts $f "int main()" |
1043 | puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1" | |
1044 | puts $f "{ return 0; }" | |
1045 | puts $f "#endif" | |
1046 | close $f | |
1047 | ||
1048 | set cxxflags_saved $cxxflags | |
f2752f1d | 1049 | set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" |
a7543cfd PC |
1050 | |
1051 | set lines [v3_target_compile $src $exe executable ""] | |
1052 | set cxxflags $cxxflags_saved | |
1053 | file delete $src | |
1054 | ||
1055 | if [string match "" $lines] { | |
1056 | # No error message, compilation succeeded. | |
1057 | set et_cstdint 1 | |
1058 | } else { | |
1059 | verbose "check_v3_target_cstdint: compilation failed" 2 | |
1060 | } | |
1061 | } | |
1062 | verbose "check_v3_target_cstdint: $et_cstdint" 2 | |
1063 | return $et_cstdint | |
1064 | } | |
30a333ce PC |
1065 | |
1066 | proc check_v3_target_atomic_builtins { } { | |
1067 | global cxxflags | |
1068 | global DEFAULT_CXXFLAGS | |
1069 | global et_cstdint | |
1070 | ||
1071 | global tool | |
1072 | ||
1073 | if { ![info exists et_atomic_builtins_target_name] } { | |
1074 | set et_atomic_builtins_target_name "" | |
1075 | } | |
1076 | ||
1077 | # If the target has changed since we set the cached value, clear it. | |
1078 | set current_target [current_target_name] | |
1079 | if { $current_target != $et_atomic_builtins_target_name } { | |
1080 | verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2 | |
1081 | set et_atomic_builtins_target_name $current_target | |
1082 | if [info exists et_atomic_builtins] { | |
1083 | verbose "check_v3_target_atomic_builtins: removing cached result" 2 | |
1084 | unset et_atomic_builtins | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | if [info exists et_atomic_builtins] { | |
1089 | verbose "check_v3_target_atomic_builtins: using cached result" 2 | |
1090 | } else { | |
1091 | set et_atomic_builtins 0 | |
1092 | ||
1093 | # Set up and compile a C++0x test program that depends | |
7b800287 | 1094 | # on the atomic builtin facilities to be available. |
30a333ce PC |
1095 | set src atomic_builtins[pid].cc |
1096 | set exe atomic_builtins[pid].exe | |
1097 | ||
1098 | set f [open $src "w"] | |
1099 | puts $f "#include <bits/c++config.h>" | |
1100 | puts $f "int main()" | |
1101 | puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4" | |
1102 | puts $f "{ return 0; }" | |
1103 | puts $f "#endif" | |
1104 | close $f | |
1105 | ||
1106 | set cxxflags_saved $cxxflags | |
1107 | set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" | |
1108 | ||
1109 | set lines [v3_target_compile $src $exe executable ""] | |
1110 | set cxxflags $cxxflags_saved | |
1111 | file delete $src | |
1112 | ||
1113 | if [string match "" $lines] { | |
1114 | # No error message, compilation succeeded. | |
1115 | set et_atomic_builtins 1 | |
1116 | } else { | |
1117 | verbose "check_v3_target_atomic_builtins: compilation failed" 2 | |
1118 | } | |
1119 | } | |
1120 | verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2 | |
1121 | return $et_atomic_builtins | |
1122 | } | |
7b800287 CF |
1123 | |
1124 | proc check_v3_target_gthreads { } { | |
1125 | global cxxflags | |
1126 | global DEFAULT_CXXFLAGS | |
1127 | global et_gthreads | |
1128 | ||
1129 | global tool | |
1130 | ||
1131 | if { ![info exists et_gthreads_target_name] } { | |
1132 | set et_gthreads_target_name "" | |
1133 | } | |
1134 | ||
1135 | # If the target has changed since we set the cached value, clear it. | |
1136 | set current_target [current_target_name] | |
1137 | if { $current_target != $et_gthreads_target_name } { | |
1138 | verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2 | |
1139 | set et_gthreads_target_name $current_target | |
1140 | if [info exists et_gthreads] { | |
1141 | verbose "check_v3_target_gthreads: removing cached result" 2 | |
1142 | unset et_gthreads | |
1143 | } | |
1144 | } | |
1145 | ||
1146 | if [info exists et_gthreads] { | |
1147 | verbose "check_v3_target_gthreads: using cached result" 2 | |
1148 | } else { | |
1149 | set et_gthreads 0 | |
1150 | ||
1151 | # Set up and compile a C++0x test program that depends | |
1152 | # on the gthreads facilities to be available. | |
1153 | set src gthreads[pid].cc | |
1154 | set exe gthreads[pid].exe | |
1155 | ||
1156 | set f [open $src "w"] | |
1157 | puts $f "#include <bits/c++config.h>" | |
1158 | puts $f "int main()" | |
1159 | puts $f "#ifdef _GLIBCXX_HAS_GTHREADS" | |
1160 | puts $f "{ return 0; }" | |
1161 | puts $f "#endif" | |
1162 | close $f | |
1163 | ||
1164 | set cxxflags_saved $cxxflags | |
1165 | set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" | |
1166 | ||
1167 | set lines [v3_target_compile $src $exe executable ""] | |
1168 | set cxxflags $cxxflags_saved | |
1169 | file delete $src | |
1170 | ||
1171 | if [string match "" $lines] { | |
1172 | # No error message, compilation succeeded. | |
1173 | set et_gthreads 1 | |
1174 | } else { | |
1175 | verbose "check_v3_target_gthreads: compilation failed" 2 | |
1176 | } | |
1177 | } | |
1178 | verbose "check_v3_target_gthreads: $et_gthreads" 2 | |
1179 | return $et_gthreads | |
1180 | } | |
46e113bf CF |
1181 | |
1182 | proc check_v3_target_nanosleep { } { | |
1183 | global cxxflags | |
1184 | global DEFAULT_CXXFLAGS | |
1185 | global et_nanosleep | |
1186 | ||
1187 | global tool | |
1188 | ||
1189 | if { ![info exists et_nanosleep_target_name] } { | |
1190 | set et_nanosleep_target_name "" | |
1191 | } | |
1192 | ||
1193 | # If the target has changed since we set the cached value, clear it. | |
1194 | set current_target [current_target_name] | |
1195 | if { $current_target != $et_nanosleep_target_name } { | |
1196 | verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2 | |
1197 | set et_nanosleep_target_name $current_target | |
1198 | if [info exists et_nanosleep] { | |
1199 | verbose "check_v3_target_nanosleep: removing cached result" 2 | |
1200 | unset et_nanosleep | |
1201 | } | |
1202 | } | |
1203 | ||
1204 | if [info exists et_nanosleep] { | |
1205 | verbose "check_v3_target_nanosleep: using cached result" 2 | |
1206 | } else { | |
1207 | set et_nanosleep 0 | |
1208 | ||
1209 | # Set up and compile a C++0x test program that depends | |
1210 | # on the nanosleep facilities to be available. | |
1211 | set src nanosleep[pid].cc | |
1212 | set exe nanosleep[pid].exe | |
1213 | ||
1214 | set f [open $src "w"] | |
1215 | puts $f "#include <bits/c++config.h>" | |
1216 | puts $f "int main()" | |
1217 | puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP" | |
1218 | puts $f "{ return 0; }" | |
1219 | puts $f "#endif" | |
1220 | close $f | |
1221 | ||
1222 | set cxxflags_saved $cxxflags | |
1223 | set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" | |
1224 | ||
1225 | set lines [v3_target_compile $src $exe executable ""] | |
1226 | set cxxflags $cxxflags_saved | |
1227 | file delete $src | |
1228 | ||
1229 | if [string match "" $lines] { | |
1230 | # No error message, compilation succeeded. | |
1231 | set et_nanosleep 1 | |
1232 | } else { | |
1233 | verbose "check_v3_target_nanosleep: compilation failed" 2 | |
1234 | } | |
1235 | } | |
1236 | verbose "check_v3_target_nanosleep: $et_nanosleep" 2 | |
1237 | return $et_nanosleep | |
1238 | } |