Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
blob0dff98caa66081a75b9ea0cecdfd34a9d41f0b4e
1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
20 # Define callbacks and load other libraries. This file is loaded relatively
21 # early, and before any other file we write ourselves. "load_lib" will
22 # find anything in the DejaGNU installation tree, or in our lib directory.
23 # "load_gcc_lib" will search the core compiler's .exp collection instead.
25 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
26 # for "tool_" when finding callbacks. Utility routines we define for
27 # our callbacks begin with "v3-".
29 # libstdc++_* callbacks we don't define, but could:
30 # ..._option_help prints additional --help output
31 # ..._option_proc (--foo) process our own options
32 # ..._init (normal.exp) called once per test file
33 # ..._finish bracketing function for libstdc++_init
34 # ...-dg-prune removing output text, see top of system dg.exp
36 # Useful hook: if ${hostname}_init exists, it will be called, almost
37 # the last thing before testing begins. This can be defined in, e.g.,
38 # ~/.dejagnurc or $DEJAGNU.
40 proc load_gcc_lib { filename } {
41 global srcdir
42 load_file $srcdir/../../gcc/testsuite/lib/$filename
45 # system routines
46 load_lib dg.exp
47 load_lib libgloss.exp
48 # compiler routines, then ours
49 load_gcc_lib target-supports.exp
50 load_gcc_lib target-supports-dg.exp
51 load_lib prune.exp
52 load_lib dg-options.exp
53 load_gcc_lib scanasm.exp
54 load_gcc_lib target-libpath.exp
55 load_gcc_lib timeout.exp
56 load_gcc_lib timeout-dg.exp
57 load_gcc_lib wrapper.exp
59 # Useful for debugging. Pass the name of a variable and the verbosity
60 # threshold (number of -v's on the command line).
61 proc v3track { var n } {
62 upvar $var val
63 verbose "++ $var is $val" $n
66 # Called by v3-init below. "Static" to this file.
67 proc v3-copy-files {srcfiles} {
68 foreach f $srcfiles {
69 if { [catch { set symlink [file readlink $f] } x] } then {
70 remote_download target $f
71 } else {
72 if { [regexp "^/" "$symlink"] } then {
73 remote_download target $symlink
74 } else {
75 set dirname [file dirname $f]
76 remote_download target $dirname/$symlink
82 # Called once, during runtest.exp setup.
83 proc libstdc++_init { testfile } {
84 global env
85 global v3-sharedlib v3-libgomp
86 global srcdir blddir objdir tool_root_dir
87 global cc cxx cxxflags cxxpchflags cxxldflags cxxvtvflags
88 global includes
89 global gluefile wrap_flags
90 global ld_library_path
91 global target_triplet
92 global flags_file
93 global tool_timeout
94 global DEFAULT_CXXFLAGS
95 global STATIC_LIBCXXFLAGS
97 # We set LC_ALL and LANG to C so that we get the same error
98 # messages as expected.
99 setenv LC_ALL C
100 setenv LANG C
102 # Many hosts now default to a non-ASCII C locale, however, so
103 # they can set a charset encoding here if they need.
104 if { [ishost "*-*-cygwin*"] } {
105 setenv LC_ALL C.ASCII
106 setenv LANG C.ASCII
109 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
110 set flags_file "${blddir}/scripts/testsuite_flags"
111 set shlib_ext [get_shlib_extension]
112 v3track flags_file 2
114 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
115 # Use this variable if the behavior
116 # 1) only applies to libstdc++ testing
117 # 2) might need to be negated
118 # In particular, some tests have to be run without precompiled
119 # headers, or without assertions.
121 if ![info exists DEFAULT_CXXFLAGS] then {
122 set DEFAULT_CXXFLAGS ""
123 # Host specific goo here.
124 if { [string match "powerpc-*-darwin*" $target_triplet] } {
125 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
128 v3track DEFAULT_CXXFLAGS 2
130 # By default, we assume we want to run program images.
131 global dg-do-what-default
132 set dg-do-what-default run
134 # Copy any required data files.
135 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
136 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
138 set ld_library_path_tmp ""
140 # Locate libgcc.a so we don't need to account for different values of
141 # SHLIB_EXT on different platforms
142 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
143 if {$gccdir != ""} {
144 set gccdir [file dirname $gccdir]
145 append ld_library_path_tmp ":${gccdir}"
147 v3track gccdir 3
149 # Locate libgomp. This is only required for parallel mode.
150 set v3-libgomp 0
151 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
152 if {$libgompdir != ""} {
153 set v3-libgomp 1
154 set libgompdir [file dirname $libgompdir]
155 append ld_library_path_tmp ":${libgompdir}"
156 verbose -log "libgomp support detected"
158 v3track libgompdir 3
160 # Locate libvtv. This is only required for --enable-vtable-verify.
161 set v3-libvtv 0
162 set libvtvdir [lookfor_file $blddir/../libvtv .libs/libvtv.$shlib_ext]
163 if {$libvtvdir != ""} {
164 set v3-libvtv 1
165 set libvtvdir [file dirname $libvtvdir]
166 append ld_library_path_tmp ":${libvtvdir}"
167 verbose -log "libvtv support detected"
169 v3track libvtvdir 3
171 # Locate libstdc++ shared library. (ie libstdc++.so.)
172 set v3-sharedlib 0
173 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
174 if {$sharedlibdir != ""} {
175 if { ([string match "*-*-linux*" $target_triplet]
176 || [string match "*-*-gnu*" $target_triplet])
177 && [isnative] } then {
178 set v3-sharedlib 1
179 verbose -log "shared library support detected"
182 v3track v3-sharedlib 3
184 set STATIC_LIBCXXFLAGS ""
185 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
186 if {$staticlibdir != ""} {
187 set staticlibdir [file dirname $staticlibdir]
188 # Some targets use libstdc++.a%s in their specs, so they need a
189 # -B option for uninstalled testing.
190 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
193 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
194 if {$gccdir != ""} {
195 set compiler ${gccdir}/xg++
196 set ld_library_path ${ld_library_path_tmp}
197 append ld_library_path ":${blddir}/src/.libs"
199 if { [is_remote host] == 0 && [which $compiler] != 0 } {
200 foreach i "[exec $compiler --print-multi-lib]" {
201 set mldir ""
202 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
203 set mldir [string trimright $mldir "\;@"]
204 if { "$mldir" == "." } {
205 continue
207 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
208 append ld_library_path ":${gccdir}/${mldir}"
213 set_ld_library_path_env_vars
214 if [info exists env(LD_LIBRARY_PATH)] {
215 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
217 } else {
218 set compiler [transform "g++"]
221 # Set the default timeout for v3 tests.
222 set tool_timeout 600
224 # Default settings.
225 set cxx [transform "g++"]
226 set cxxflags "-D_GLIBCXX_ASSERT -fmessage-length=0"
227 set cxxpchflags ""
228 set cxxvtvflags ""
229 set cxxldflags ""
230 set cc [transform "gcc"]
231 # Locate testsuite_hooks.h and other testsuite headers.
232 set includes "-I${srcdir}/util"
233 # Adapt the defaults for special circumstances.
234 if [is_remote host] {
235 # A remote host does not, in general, have access to the
236 # $srcdir so we copy the testsuite headers into the current
237 # directory, and then add that to the search path.
238 foreach src [glob "${srcdir}/util/*.h" \
239 "${srcdir}/util/*.cc" \
240 "${srcdir}/util/*.tcc" \
241 "${srcdir}/util/*.hpp" \
242 "${srcdir}/util/*/*.h" \
243 "${srcdir}/util/*/*.cc" \
244 "${srcdir}/util/*/*.tcc" \
245 "${srcdir}/util/*/*.hpp" \
246 "${srcdir}/util/*/*/*.h" \
247 "${srcdir}/util/*/*/*.cc" \
248 "${srcdir}/util/*/*/*.tcc" \
249 "${srcdir}/util/*/*/*.hpp" \
250 "${srcdir}/util/*/*/*/*.h" \
251 "${srcdir}/util/*/*/*/*.cc" \
252 "${srcdir}/util/*/*/*/*.tcc" \
253 "${srcdir}/util/*/*/*/*.hpp" \
254 "${srcdir}/util/*/*/*/*/*.h" \
255 "${srcdir}/util/*/*/*/*/*.cc" \
256 "${srcdir}/util/*/*/*/*/*.tcc" \
257 "${srcdir}/util/*/*/*/*/*.hpp" ] {
258 # Remove everything up to "util/..."
259 set dst [string range $src [string length "${srcdir}/"] end]
260 # Create the directory containing the file.
261 set dir [file dirname $dst]
262 remote_exec host "mkdir" [list "-p" "$dir"]
263 # Download the file.
264 set result [remote_download host $src $dst]
265 if { $result == "" } {
266 verbose -log "Unable to download ${srcdir}/${src} to host."
267 return "untested"
270 set includes "-Iutil"
271 } elseif { [file exists $flags_file] } {
272 # If we find a testsuite_flags file, we're testing in the build dir.
273 set cxx [exec sh $flags_file --build-cxx]
274 set cxxflags [exec sh $flags_file --cxxflags]
275 set cxxpchflags [exec sh $flags_file --cxxpchflags]
276 set cxxvtvflags [exec sh $flags_file --cxxvtvflags]
277 set cxxldflags [exec sh $flags_file --cxxldflags]
278 set cc [exec sh $flags_file --build-cc]
279 set includes [exec sh $flags_file --build-includes]
281 append cxxflags " "
282 append cxxflags [getenv CXXFLAGS]
283 v3track cxxflags 2
285 # Always use MO files built by this test harness.
286 set cxxflags "-fdiagnostics-color=never $cxxflags -DLOCALEDIR=\".\""
287 set ccflags "$cxxflags -DLOCALEDIR=\".\""
289 # If a PCH file is available, use it. We must delay performing
290 # this check until $cxx and such have been initialized because we
291 # perform a test compilation. (Ideally, gcc --print-file-name would
292 # list PCH files, but it does not.)
293 if { $cxxpchflags != "" } {
294 set src "config[pid].cc"
295 set f [open $src "w"]
296 puts $f "int main () {}"
297 close $f
299 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
300 # useful as then the requested variant of the pre-build PCH
301 # files could be tested to see if it works.
302 set lines [v3_target_compile $src "config[pid].o" object \
303 "additional_flags=-include additional_flags=bits/stdc++.h"]
304 if { $lines != "" } {
305 verbose -log "Requested PCH file: $cxxpchflags"
306 verbose -log "is not working, and will not be used."
307 set cxxpchflags ""
309 file delete $src
311 v3track cxxpchflags 2
313 global PCH_CXXFLAGS
314 if ![info exists PCH_CXXFLAGS] then {
315 set PCH_CXXFLAGS $cxxpchflags
316 v3track PCH_CXXFLAGS 2
319 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
322 # Callback for cleanup routines.
323 proc libstdc++_exit { } {
324 global gluefile;
326 if [info exists gluefile] {
327 file_on_build delete $gluefile;
328 unset gluefile;
332 # Callback from system dg-test.
333 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
334 # Set up the compiler flags, based on what we're going to do.
335 switch $do_what {
336 "preprocess" {
337 set compile_type "preprocess"
338 set output_file "[file rootname [file tail $prog]].i"
340 "compile" {
341 set compile_type "assembly"
342 set output_file "[file rootname [file tail $prog]].s"
344 "assemble" {
345 set compile_type "object"
346 set output_file "[file rootname [file tail $prog]].o"
348 "link" {
349 set compile_type "executable"
350 set output_file "./[file rootname [file tail $prog]].exe"
352 "run" {
353 set compile_type "executable"
354 # FIXME: "./" is to cope with "." not being in $PATH.
355 # Should this be handled elsewhere?
356 # YES.
357 set output_file "./[file rootname [file tail $prog]].exe"
358 # This is the only place where we care if an executable was
359 # created or not. If it was, dg.exp will try to run it.
360 catch { remote_file build delete $output_file }
362 default {
363 perror "$do_what: not a valid dg-do keyword"
364 return ""
368 # Short-circut a bunch of complicated goo here for the special
369 # case of compiling a test file as a "C" file, not as C++. Why? So
370 # -nostdc++ doesn't trip us up. So all the extra object files
371 # don't trip us up. So automatically linking in libstdc++ doesn't
372 # happen. So CXXFLAGS don't error.
373 set select_compile "v3_target_compile"
374 set options ""
375 if { $extra_tool_flags != "" } {
376 verbose -log "extra_tool_flags are:"
377 verbose -log $extra_tool_flags
378 if { [string first "-x c" $extra_tool_flags ] != -1 } {
379 verbose -log "compiling and executing as C, not C++"
380 set edit_tool_flags $extra_tool_flags
381 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
382 lappend options "additional_flags=$edit_tool_flags"
383 set select_compile "v3_target_compile_as_c"
384 } else {
385 lappend options "additional_flags=$extra_tool_flags"
389 # There is a libstdc++_compile made for us by default (via the tool-
390 # and-target file), but the defaults are lacking in goodness.
391 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
393 return [list $comp_output $output_file]
396 # Override the DejaGnu dg-test in order to clear flags after a test, as
397 # is done for compiler tests in gcc-dg.exp.
399 if { [info procs saved-dg-test] == [list] } {
400 rename dg-test saved-dg-test
402 proc dg-test { args } {
403 global additional_prunes
404 global errorInfo
405 global testname_with_flags
407 if { [ catch { eval saved-dg-test $args } errmsg ] } {
408 set saved_info $errorInfo
409 set additional_prunes ""
410 if [info exists testname_with_flags] {
411 unset testname_with_flags
413 unset_timeout_vars
414 error $errmsg $saved_info
416 set additional_prunes ""
417 unset_timeout_vars
418 if [info exists testname_with_flags] {
419 unset testname_with_flags
424 # True if the library supports wchar_t.
425 set v3-wchar_t 0
427 # True if the library supports threads.
428 set v3-threads 0
430 # True if the library supports symbol versioning.
431 set v3-symver 0
433 # Called from libstdc++-dg-test above. Calls back into system's
434 # target_compile to actually do the work.
435 proc v3_target_compile { source dest type options } {
436 global gluefile
437 global wrap_flags
438 global cxx
439 global cxxflags
440 global cxxvtvflags
441 global cxxldflags
442 global includes
443 global STATIC_LIBCXXFLAGS
445 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
446 lappend options "libs=${gluefile}"
447 lappend options "ldflags=${wrap_flags}"
450 set cxx_final $cxx
451 set cxxlibglossflags [libgloss_link_flags]
452 set cxx_final [concat $cxx_final $cxxlibglossflags]
453 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
454 set cxx_final [concat $cxx_final $cxxflags]
455 set cxx_final [concat $cxx_final $cxxvtvflags]
456 set cxx_final [concat $cxx_final $includes]
458 # Flag setting based on type argument.
459 if { $type == "executable" } {
460 # Link the support objects into executables.
461 lappend options "additional_flags=./libtestc++.a $cxxldflags"
462 } else {
463 if { $type == "sharedlib" } {
464 # Don't link in anything.
465 set type "executable"
469 lappend options "compiler=$cxx_final"
470 lappend options "timeout=[timeout_value]"
472 return [target_compile $source $dest $type $options]
476 # Called from libstdc++-dg-test above, but only for "C" compilation.
477 # Calls back into system's target_compile to actually do the work.
478 proc v3_target_compile_as_c { source dest type options } {
479 global gluefile
480 global wrap_flags
481 global includes
482 global flags_file
483 global blddir
484 global cc
485 global cxxflags
486 global STATIC_LIBCXXFLAGS
488 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
489 lappend options "libs=${gluefile}"
490 lappend options "ldflags=${wrap_flags}"
493 set tname [target_info name]
494 set cc_final $cc
495 set cxxlibglossflags [libgloss_link_flags]
496 set cc_final [concat $cc_final $cxxlibglossflags]
497 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
498 set cc_final [concat $cc_final $cxxflags]
499 set cc_final [concat $cc_final $includes]
500 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
502 # This is needed for "C" tests, as this type of test may need the
503 # C++ includes. And if we're not testing in the build directory,
504 # the includes variable is not likely to include the necessary
505 # info.
506 if { ![file exists $flags_file] } {
507 # ??? We need a --print-include-dirs option to GCC, so that
508 # we can avoid these hacks. The heuristics here will not
509 # work with non-standard --with-includedir= options.
510 set version [remote_exec host ${cc} -dumpversion]
511 # Remove the trailing newline from the output.
512 set version [string trimright [lindex $version 1]]
513 set machine [remote_exec host ${cc} -dumpmachine]
514 set machine [string trimright [lindex $machine 1]]
515 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
516 set comp_base_dir [lindex $comp_base_dir 1]
517 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
518 # For a cross compiler, the header files will be located in a
519 # machine-specific subdirectory.
520 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
521 set crosstarget "${crossbase}/${machine}"
522 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
523 # For a native compiler, the header files will be located at
524 # the top level.
525 set includesbase "${comp_base_dir}/include/c++/${version}"
526 set includestarget "${includesbase}/${machine}"
527 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
529 set libdir "-L${comp_base_dir}/lib"
530 } else {
531 set libdir "-L${blddir}/libsupc++/.libs"
532 set libdir [concat $libdir "-L${blddir}/src/.libs"]
535 set cc_final [concat $cc_final "$libdir"]
537 lappend options "compiler=$cc_final"
538 lappend options "timeout=[timeout_value]"
540 return [target_compile $source $dest $type $options]
543 # Build the support objects linked in with the libstdc++ tests. In
544 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
545 proc v3-build_support { } {
546 global env
547 global srcdir
548 global v3-wchar_t
549 global v3-threads
550 global v3-symver
551 global v3-sharedlib
553 # Figure out whether or not the library supports certain features.
554 set v3-wchar_t 0
555 set v3-threads 0
556 set v3-symver 0
557 set libtest_objs ""
559 set config_src "config.cc"
560 set config_out "config.ii"
561 set f [open $config_src "w"]
562 puts $f "#include <bits/c++config.h>"
563 puts $f "#include <bits/gthr.h>"
564 close $f
565 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
566 set file [open $config_out r]
567 set preprocessed [read $file]
568 close $file
569 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
570 verbose -log "wchar_t support detected"
571 set v3-wchar_t 1
573 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
574 verbose -log "symbol versioning support detected"
575 set v3-symver 1
577 if { [string first "__GTHREADS" $preprocessed] != -1 } {
578 verbose -log "thread support detected"
579 set v3-threads 1
582 # Try to build the MO files that are used by some of the locale
583 # tests. If we can't build them, that's OK; it just means that
584 # those tests will fail.
585 foreach lang [list "fr" "de"] {
586 catch {
587 file mkdir "$lang/LC_MESSAGES"
588 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
589 if [is_remote host] {
590 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
591 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
596 # Build the support objects.
597 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
598 testsuite_character.cc testsuite_hooks.cc \
599 io/verified_cmd_line_input.cc \
600 io/prog_bar.cc performance/time/elapsed_timer.cc ]
601 foreach f $source_files {
602 set obj [file rootname $f].o
603 set object_file [file tail $obj]
604 # Compile with "-w" so that warnings issued by the compiler
605 # do not prevent compilation.
606 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
607 [list "incdir=$srcdir" "additional_flags=-w"]]
608 != "" } {
609 error "could not compile $f"
611 append libtest_objs "$object_file "
614 # Collect into libtestc++.a
615 if [info exists env(AR)] {
616 set ar $env(AR)
617 } else {
618 set ar [transform "ar"]
620 set arargs "-rc ./libtestc++.a ${libtest_objs}"
621 verbose -log "$ar $arargs"
622 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
623 verbose "link result is $result"
624 if { $result == 0 } {
625 if [info exists env(RANLIB)] {
626 set ranlib $env(RANLIB)
627 } else {
628 set ranlib [transform "ranlib"]
630 set ranlibargs "./libtestc++.a"
631 verbose -log "$ranlib $ranlibargs"
632 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
633 if { $result != 0 } {
634 error "could not link libtestc++.a"
638 # Build any shared objects needed for regression testing.
639 if { ${v3-sharedlib} == 1 } {
640 set source_files [list testsuite_shared.cc]
641 foreach f $source_files {
642 set object_file [file rootname $f].so
643 # Compile with "-w" so that warnings issued by the compiler
644 # do not prevent compilation.
645 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
646 [list "incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC"]]
647 != "" } {
648 error "could not compile $f"
654 proc check_v3_target_fileio { } {
655 global et_fileio_saved
656 global et_fileio_target_name
657 global tool
658 global srcdir
660 if { ![info exists et_fileio_target_name] } {
661 set et_fileio_target_name ""
664 # If the target has changed since we set the cached value, clear it.
665 set current_target [current_target_name]
666 if { $current_target != $et_fileio_target_name } {
667 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
668 set et_fileio_target_name $current_target
669 if [info exists et_fileio_saved] {
670 verbose "check_v3_target_fileio: removing cached result" 2
671 unset et_fileio_saved
675 if [info exists et_fileio_saved] {
676 verbose "check_v3_target_fileio: using cached result" 2
677 } else {
678 set et_fileio_saved 0
680 # Set up, compile, and execute a C++ test program that tries to use
681 # the file functions
682 set src fileio[pid].cc
683 set exe fileio[pid].x
684 set testfile "cin_unget-1.txt"
685 v3-copy-files "$srcdir/data/$testfile"
687 set f [open $src "w"]
688 puts $f "#include <sys/types.h>"
689 puts $f "#include <sys/stat.h>"
690 puts $f "#include <fcntl.h>"
691 puts $f "#include <unistd.h>"
692 puts $f "#include <errno.h>"
693 puts $f "#include <string.h>"
694 puts $f "using namespace std;"
695 puts $f "int main ()"
696 puts $f "{"
697 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
698 puts $f " int ret = 0;"
699 puts $f " char buf\[10\];"
700 puts $f " if (fd == -1)"
701 puts $f " ret = 1;"
702 puts $f " else"
703 puts $f " {"
704 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
705 puts $f " ret = 1;"
706 puts $f " errno = 0;"
707 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
708 puts $f " || read (fd, buf, 4) != 4"
709 puts $f " || memcmp (buf, \"1234\", 4) != 0"
710 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
711 puts $f " || read (fd, buf, 2) != 2"
712 puts $f " || memcmp (buf, \"34\", 2) != 0)"
713 puts $f " ret = 1;"
714 puts $f " close (fd);"
715 puts $f " }"
716 puts $f " return ret;"
717 puts $f "}"
718 close $f
720 set lines [v3_target_compile $src $exe executable ""]
721 file delete $src
723 if [string match "" $lines] {
724 # No error message, compilation succeeded.
725 set result [${tool}_load "./$exe" "" ""]
726 set status [lindex $result 0]
727 remote_file build delete $exe
729 verbose "check_v3_target_fileio: status is <$status>" 2
731 if { $status == "pass" } {
732 set et_fileio_saved 1
734 } else {
735 verbose "check_v3_target_fileio: compilation failed" 2
738 return $et_fileio_saved
741 # Eventually we want C90/C99 determining and switching from this.
742 proc check_v3_target_c_std { } {
743 global et_c_std_saved
744 global et_c_std_target_name
745 global tool
747 if { ![info exists et_c_std_target_name] } {
748 set et_c_std_target_name ""
751 # If the target has changed since we set the cached value, clear it.
752 set current_target [current_target_name]
753 if { $current_target != $et_c_std_target_name } {
754 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
755 set et_c_std_target_name $current_target
756 if [info exists et_c_std_saved] {
757 verbose "check_v3_target_c_std: removing cached result" 2
758 unset et_c_std_saved
762 if [info exists et_c_std_saved] {
763 verbose "check_v3_target_c_std: using cached result" 2
764 } else {
765 set et_c_std_saved 0
767 # Set up, compile, and execute a C++ test program that tries to use
768 # C99 functionality.
769 # For math bits, could use check_effective_target_c99_math.
770 set src fileio[pid].cc
771 set exe fileio[pid].x
773 set f [open $src "w"]
774 puts $f "#include <tr1/cmath>"
775 puts $f "#include <cstdlib>"
776 puts $f "int main ()"
777 puts $f "{"
778 puts $f " float f = 45.55;"
779 puts $f " int i = std::tr1::isnan(f);"
780 puts $f " "
781 puts $f " using std::wctomb;"
782 puts $f " return i;"
783 puts $f "}"
784 close $f
786 set lines [v3_target_compile $src $exe executable ""]
787 file delete $src
789 if [string match "" $lines] {
790 # No error message, compilation succeeded.
791 set result [${tool}_load "./$exe" "" ""]
792 set status [lindex $result 0]
793 remote_file build delete $exe
795 verbose "check_v3_target_c_std: status is <$status>" 2
797 if { $status == "pass" } {
798 set et_c_std_saved 1
800 } else {
801 verbose "check_v3_target_c_std: compilation failed" 2
804 return $et_c_std_saved
807 proc check_v3_target_sharedlib { } {
808 global v3-sharedlib
809 return ${v3-sharedlib}
812 proc check_v3_target_time { } {
813 global et_time_saved
814 global et_time_target_name
815 global tool
817 if { ![info exists et_time_target_name] } {
818 set et_time_target_name ""
821 # If the target has changed since we set the cached value, clear it.
822 set current_target [current_target_name]
823 if { $current_target != $et_time_target_name } {
824 verbose "check_v3_target_time: `$et_time_target_name'" 2
825 set et_time_target_name $current_target
826 if [info exists et_time_saved] {
827 verbose "check_v3_target_time: removing cached result" 2
828 unset et_time_saved
832 if [info exists et_time_saved] {
833 verbose "check_v3_target_time: using cached result" 2
834 } else {
835 set et_time_saved 0
837 # Set up and compile a C++ test program that tries to use
838 # the time function
839 set src time[pid].cc
841 set f [open $src "w"]
842 puts $f "#include <time.h>"
843 puts $f "using namespace std;"
844 puts $f "int main ()"
845 puts $f "{"
846 puts $f " time (0);"
847 puts $f "}"
848 close $f
850 set lines [v3_target_compile $src /dev/null executable ""]
851 file delete $src
853 if [string match "" $lines] {
854 # No error message, compilation succeeded.
855 verbose "check_v3_target_time: compilation succeeded" 2
856 set et_time_saved 1
857 } else {
858 verbose "check_v3_target_time: compilation failed" 2
861 return $et_time_saved
864 proc check_v3_target_namedlocale { args } {
865 global et_namedlocale
866 global tool
868 set et_namedlocale 0
870 # Set up, compile, and execute a C++ test program that tries to use
871 # the required named locale.
872 set exe nlocale[pid].x
874 if ![file exists ./$exe] {
875 set src nlocale[pid].cc
877 set f [open $src "w"]
878 puts $f "#include <locale>"
879 puts $f "#include <cstdio>"
880 puts $f "using namespace std;"
881 puts $f "int main (int argc, char** argv)"
882 puts $f "{"
883 puts $f " try"
884 puts $f " {"
885 puts $f " locale(*(argv + 1));"
886 puts $f " return 0;"
887 puts $f " }"
888 puts $f " catch(...)"
889 puts $f " {"
890 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
891 puts $f " return 1;"
892 puts $f " }"
893 puts $f "}"
894 close $f
896 set lines [v3_target_compile $src $exe executable ""]
897 file delete $src
899 if ![string match "" $lines] {
900 verbose "check_v3_target_namedlocale: compilation failed" 2
901 return $et_namedlocale
903 # else No error message, compilation succeeded.
906 set result [${tool}_load "./$exe" "$args" ""]
907 set status [lindex $result 0]
909 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
911 if { $status == "pass" } {
912 set et_namedlocale 1
914 return $et_namedlocale
917 proc check_v3_target_debug_mode { } {
918 global et_debug_mode
919 global tool
921 if { ![info exists et_debug_mode_target_name] } {
922 set et_debug_mode_target_name ""
925 # If the target has changed since we set the cached value, clear it.
926 set current_target [current_target_name]
927 if { $current_target != $et_debug_mode_target_name } {
928 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
929 set et_debug_mode_target_name $current_target
930 if [info exists et_debug_mode] {
931 verbose "check_v3_target_debug_mode: removing cached result" 2
932 unset et_debug_mode
936 if [info exists et_debug_mode] {
937 verbose "check_v3_target_debug_mode: using cached result" 2
938 } else {
939 set et_debug_mode 0
941 # Set up and preprocess a C++ test program that depends
942 # on debug mode activated.
943 set src debug_mode[pid].cc
945 set f [open $src "w"]
946 puts $f "#ifndef _GLIBCXX_DEBUG"
947 puts $f "# error No debug mode"
948 puts $f "#endif"
949 close $f
951 set lines [v3_target_compile $src /dev/null preprocess ""]
952 file delete $src
954 if [string match "" $lines] {
955 # No error message, preprocessing succeeded.
956 set et_debug_mode 1
959 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
960 return $et_debug_mode
963 proc check_v3_target_profile_mode { } {
964 global et_profile_mode
965 global tool
967 if { ![info exists et_profile_mode_target_name] } {
968 set et_profile_mode_target_name ""
971 # If the target has changed since we set the cached value, clear it.
972 set current_target [current_target_name]
973 if { $current_target != $et_profile_mode_target_name } {
974 verbose "check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
975 set et_profile_mode_target_name $current_target
976 if [info exists et_profile_mode] {
977 verbose "check_v3_target_profile_mode: removing cached result" 2
978 unset et_profile_mode
982 if [info exists et_profile_mode] {
983 verbose "check_v3_target_profile_mode: using cached result" 2
984 } else {
985 set et_profile_mode 0
987 # Set up and preprocess a C++ test program that depends
988 # on profile mode activated.
989 set src profile_mode[pid].cc
991 set f [open $src "w"]
992 puts $f "#ifndef _GLIBCXX_PROFILE"
993 puts $f "# error No profile mode"
994 puts $f "#endif"
995 close $f
997 set lines [v3_target_compile $src /dev/null preprocess ""]
998 file delete $src
1000 if [string match "" $lines] {
1001 # No error message, preprocessing succeeded.
1002 set et_profile_mode 1
1005 verbose "check_v3_target_profile_mode: $et_profile_mode" 2
1006 return $et_profile_mode
1009 proc check_v3_target_normal_mode { } {
1010 global et_normal_mode
1011 global tool
1013 if { ![info exists et_normal_mode_target_name] } {
1014 set et_normal_mode_target_name ""
1017 # If the target has changed since we set the cached value, clear it.
1018 set current_target [current_target_name]
1019 if { $current_target != $et_normal_mode_target_name } {
1020 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1021 set et_normal_mode_target_name $current_target
1022 if [info exists et_normal_mode] {
1023 verbose "check_v3_target_normal_mode: removing cached result" 2
1024 unset et_normal_mode
1028 if [info exists et_normal_mode] {
1029 verbose "check_v3_target_normal_mode: using cached result" 2
1030 } else {
1031 set et_normal_mode 0
1033 # Set up and compile a C++ test program that depends
1034 # on normal mode activated.
1035 set src normal_mode[pid].cc
1037 set f [open $src "w"]
1038 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1039 puts $f "# error No normal mode"
1040 puts $f "#endif"
1041 close $f
1043 set lines [v3_target_compile $src /dev/null preprocess ""]
1044 file delete $src
1046 if [string match "" $lines] {
1047 # No error message, compilation succeeded.
1048 set et_normal_mode 1
1051 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
1052 return $et_normal_mode
1055 proc check_v3_target_parallel_mode { } {
1056 global cxxflags
1057 global v3-libgomp
1058 global et_parallel_mode
1060 global tool
1062 if { ![info exists et_parallel_mode_target_name] } {
1063 set et_parallel_mode_target_name ""
1066 # If the target has changed since we set the cached value, clear it.
1067 set current_target [current_target_name]
1068 if { $current_target != $et_parallel_mode_target_name } {
1069 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1070 set et_parallel_mode_target_name $current_target
1071 if [info exists et_parallel_mode] {
1072 verbose "check_v3_target_parallel_mode: removing cached result" 2
1073 unset et_parallel_mode
1077 if [info exists et_parallel_mode] {
1078 verbose "check_v3_target_parallel_mode: using cached result" 2
1079 } else {
1080 set et_parallel_mode 0
1082 # If 'make check-parallel' is running the test succeeds.
1083 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1084 set et_parallel_mode 1
1087 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1088 return $et_parallel_mode
1091 proc check_v3_target_cstdint { } {
1092 global cxxflags
1093 global DEFAULT_CXXFLAGS
1094 global et_cstdint
1096 global tool
1098 if { ![info exists et_cstdint_target_name] } {
1099 set et_cstdint_target_name ""
1102 # If the target has changed since we set the cached value, clear it.
1103 set current_target [current_target_name]
1104 if { $current_target != $et_cstdint_target_name } {
1105 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1106 set et_cstdint_target_name $current_target
1107 if [info exists et_cstdint] {
1108 verbose "check_v3_target_cstdint: removing cached result" 2
1109 unset et_cstdint
1113 if [info exists et_cstdint] {
1114 verbose "check_v3_target_cstdint: using cached result" 2
1115 } else {
1116 set et_cstdint 0
1118 # Set up and preprocess a C++0x test program that depends
1119 # on the C99 stdint facilities to be available.
1120 set src cstdint[pid].cc
1122 set f [open $src "w"]
1123 puts $f "#include <tr1/cstdint>"
1124 puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1125 puts $f "# error No C99 stdint"
1126 puts $f "#endif"
1127 close $f
1129 set cxxflags_saved $cxxflags
1130 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1132 set lines [v3_target_compile $src /dev/null preprocess ""]
1133 set cxxflags $cxxflags_saved
1134 file delete $src
1136 if [string match "" $lines] {
1137 # No error message, preprocess succeeded.
1138 set et_cstdint 1
1139 } else {
1140 verbose "check_v3_target_cstdint: compilation failed" 2
1143 verbose "check_v3_target_cstdint: $et_cstdint" 2
1144 return $et_cstdint
1147 proc check_v3_target_cmath { } {
1148 global cxxflags
1149 global DEFAULT_CXXFLAGS
1150 global et_c99_math
1152 global tool
1154 if { ![info exists et_c99_math_target_name] } {
1155 set et_c99_math_target_name ""
1158 # If the target has changed since we set the cached value, clear it.
1159 set current_target [current_target_name]
1160 if { $current_target != $et_c99_math_target_name } {
1161 verbose "check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1162 set et_c99_math_target_name $current_target
1163 if [info exists et_c99_math] {
1164 verbose "check_v3_target_c99_math: removing cached result" 2
1165 unset et_c99_math
1169 if [info exists et_c99_math] {
1170 verbose "check_v3_target_c99_math: using cached result" 2
1171 } else {
1172 set et_c99_math 0
1174 # Set up and preprocess a C++0x test program that depends
1175 # on the C99 math facilities to be available.
1176 set src c99_math[pid].cc
1178 set f [open $src "w"]
1179 puts $f "#include <tr1/cmath>"
1180 puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1181 puts $f "# error No C99 math"
1182 puts $f "#endif"
1183 close $f
1185 set cxxflags_saved $cxxflags
1186 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1188 set lines [v3_target_compile $src /dev/null preprocess ""]
1189 set cxxflags $cxxflags_saved
1190 file delete $src
1192 if [string match "" $lines] {
1193 # No error message, preprocess succeeded.
1194 set et_c99_math 1
1195 } else {
1196 verbose "check_v3_target_c99_math: compilation failed" 2
1199 verbose "check_v3_target_c99_math: $et_c99_math" 2
1200 return $et_c99_math
1203 proc check_v3_target_atomic_builtins { } {
1204 global cxxflags
1205 global DEFAULT_CXXFLAGS
1206 global et_atomic_builtins
1208 global tool
1210 if { ![info exists et_atomic_builtins_target_name] } {
1211 set et_atomic_builtins_target_name ""
1214 # If the target has changed since we set the cached value, clear it.
1215 set current_target [current_target_name]
1216 if { $current_target != $et_atomic_builtins_target_name } {
1217 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1218 set et_atomic_builtins_target_name $current_target
1219 if [info exists et_atomic_builtins] {
1220 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1221 unset et_atomic_builtins
1225 if [info exists et_atomic_builtins] {
1226 verbose "check_v3_target_atomic_builtins: using cached result" 2
1227 } else {
1228 set et_atomic_builtins 0
1230 # Set up and preprocess a C++0x test program that depends
1231 # on the atomic builtin facilities to be available.
1232 set src atomic_builtins[pid].cc
1234 set f [open $src "w"]
1235 puts $f "#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1236 puts $f "# error No atomic bool"
1237 puts $f "#endif"
1238 puts $f "#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1239 puts $f "# error No atomic int"
1240 puts $f "#endif"
1241 close $f
1243 set cxxflags_saved $cxxflags
1244 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++0x"
1246 set lines [v3_target_compile $src /dev/null preprocess ""]
1247 set cxxflags $cxxflags_saved
1248 file delete $src
1250 if [string match "" $lines] {
1251 # No error message, preprocess succeeded.
1252 set et_atomic_builtins 1
1253 } else {
1254 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1257 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1258 return $et_atomic_builtins
1261 proc check_v3_target_gthreads { } {
1262 global cxxflags
1263 global DEFAULT_CXXFLAGS
1264 global et_gthreads
1266 global tool
1268 if { ![info exists et_gthreads_target_name] } {
1269 set et_gthreads_target_name ""
1272 # If the target has changed since we set the cached value, clear it.
1273 set current_target [current_target_name]
1274 if { $current_target != $et_gthreads_target_name } {
1275 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1276 set et_gthreads_target_name $current_target
1277 if [info exists et_gthreads] {
1278 verbose "check_v3_target_gthreads: removing cached result" 2
1279 unset et_gthreads
1283 if [info exists et_gthreads] {
1284 verbose "check_v3_target_gthreads: using cached result" 2
1285 } else {
1286 set et_gthreads 0
1288 # Set up and preprocess a C++0x test program that depends
1289 # on the gthreads facilities to be available.
1290 set src gthreads[pid].cc
1292 set f [open $src "w"]
1293 puts $f "#include <bits/c++config.h>"
1294 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1295 puts $f "# error No gthread"
1296 puts $f "#endif"
1297 close $f
1299 set cxxflags_saved $cxxflags
1300 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1302 set lines [v3_target_compile $src /dev/null preprocess ""]
1303 set cxxflags $cxxflags_saved
1304 file delete $src
1306 if [string match "" $lines] {
1307 # No error message, preprocessing succeeded.
1308 set et_gthreads 1
1309 } else {
1310 verbose "check_v3_target_gthreads: compilation failed" 2
1313 verbose "check_v3_target_gthreads: $et_gthreads" 2
1314 return $et_gthreads
1317 proc check_v3_target_gthreads_timed { } {
1318 global cxxflags
1319 global DEFAULT_CXXFLAGS
1320 global et_gthreads_timed
1322 global tool
1324 if { ![info exists et_gthreads_timed_target_name] } {
1325 set et_gthreads_timed_target_name ""
1328 # If the target has changed since we set the cached value, clear it.
1329 set current_target [current_target_name]
1330 if { $current_target != $et_gthreads_timed_target_name } {
1331 verbose "check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1332 set et_gthreads_timed_target_name $current_target
1333 if [info exists et_gthreads_timed] {
1334 verbose "check_v3_target_gthreads_timed: removing cached result" 2
1335 unset et_gthreads_timed
1339 if [info exists et_gthreads_timed] {
1340 verbose "check_v3_target_gthreads_timed: using cached result" 2
1341 } else {
1342 set et_gthreads_timed 0
1344 # Set up and preprocess a C++0x test program that depends
1345 # on the gthreads timed mutex facilities to be available.
1346 set src gthreads_timed[pid].cc
1348 set f [open $src "w"]
1349 puts $f "#include <bits/c++config.h>"
1350 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1351 puts $f "# error No gthread"
1352 puts $f "#endif"
1353 puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1354 puts $f "# error No gthread timed mutexes"
1355 puts $f "#endif"
1356 close $f
1358 set cxxflags_saved $cxxflags
1359 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1361 set lines [v3_target_compile $src /dev/null preprocess ""]
1362 set cxxflags $cxxflags_saved
1363 file delete $src
1365 if [string match "" $lines] {
1366 # No error message, preprocessing succeeded.
1367 set et_gthreads_timed 1
1368 } else {
1369 verbose "check_v3_target_gthreads_timed: compilation failed" 2
1372 verbose "check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1373 return $et_gthreads_timed
1377 proc check_v3_target_sleep { } {
1378 global cxxflags
1379 global DEFAULT_CXXFLAGS
1380 global et_sleep
1382 global tool
1384 if { ![info exists et_sleep_target_name] } {
1385 set et_sleep_target_name ""
1388 # If the target has changed since we set the cached value, clear it.
1389 set current_target [current_target_name]
1390 if { $current_target != $et_sleep_target_name } {
1391 verbose "check_v3_target_sleep: `$et_sleep_target_name'" 2
1392 set et_sleep_target_name $current_target
1393 if [info exists et_sleep] {
1394 verbose "check_v3_target_sleep: removing cached result" 2
1395 unset et_sleep
1399 if [info exists et_sleep] {
1400 verbose "check_v3_target_sleep: using cached result" 2
1401 } else {
1402 set et_sleep 0
1404 # Set up and preprocess a C++11 test program that depends
1405 # on the sleep facilities to be available.
1406 set src sleep[pid].cc
1408 set f [open $src "w"]
1409 puts $f "#include <bits/c++config.h>"
1410 puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP"
1411 puts $f "# ifndef _GLIBCXX_HAVE_SLEEP"
1412 puts $f "# error No nanosleep or sleep"
1413 puts $f "# endif"
1414 puts $f "#endif"
1415 close $f
1417 set cxxflags_saved $cxxflags
1418 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1420 set lines [v3_target_compile $src /dev/null preprocess ""]
1421 set cxxflags $cxxflags_saved
1422 file delete $src
1424 if [string match "" $lines] {
1425 # No error message, preprocessing succeeded.
1426 set et_sleep 1
1427 } else {
1428 verbose "check_v3_target_sleep: compilation failed" 2
1431 verbose "check_v3_target_sleep: $et_sleep" 2
1432 return $et_sleep
1435 proc check_v3_target_sched_yield { } {
1436 global cxxflags
1437 global DEFAULT_CXXFLAGS
1438 global et_sched_yield
1440 global tool
1442 if { ![info exists et_sched_yield_target_name] } {
1443 set et_sched_yield_target_name ""
1446 # If the target has changed since we set the cached value, clear it.
1447 set current_target [current_target_name]
1448 if { $current_target != $et_sched_yield_target_name } {
1449 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1450 set et_sched_yield_target_name $current_target
1451 if [info exists et_sched_yield] {
1452 verbose "check_v3_target_sched_yield: removing cached result" 2
1453 unset et_sched_yield
1457 if [info exists et_sched_yield] {
1458 verbose "check_v3_target_sched_yield: using cached result" 2
1459 } else {
1460 set et_sched_yield 0
1462 # Set up and preprocess a C++0x test program that depends
1463 # on the sched_yield facility to be available.
1464 set src sched_yield[pid].cc
1466 set f [open $src "w"]
1467 puts $f "#include <bits/c++config.h>"
1468 puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD"
1469 puts $f "# error No sched yield"
1470 puts $f "#endif"
1471 close $f
1473 set cxxflags_saved $cxxflags
1474 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1476 set lines [v3_target_compile $src /dev/null preprocess ""]
1477 set cxxflags $cxxflags_saved
1478 file delete $src
1480 if [string match "" $lines] {
1481 # No error message, preprocessing succeeded.
1482 set et_sched_yield 1
1483 } else {
1484 verbose "check_v3_target_sched_yield: compilation failed" 2
1487 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1488 return $et_sched_yield
1491 proc check_v3_target_string_conversions { } {
1492 global cxxflags
1493 global DEFAULT_CXXFLAGS
1494 global et_string_conversions
1496 global tool
1498 if { ![info exists et_string_conversions_target_name] } {
1499 set et_string_conversions_target_name ""
1502 # If the target has changed since we set the cached value, clear it.
1503 set current_target [current_target_name]
1504 if { $current_target != $et_string_conversions_target_name } {
1505 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1506 set et_string_conversions_target_name $current_target
1507 if [info exists et_string_conversions] {
1508 verbose "check_v3_target_string_conversions: removing cached result" 2
1509 unset et_string_conversions
1513 if [info exists et_string_conversions] {
1514 verbose "check_v3_target_string_conversions: using cached result" 2
1515 } else {
1516 set et_string_conversions 0
1518 # Set up and preprocess a C++0x test program that depends
1519 # on the string_conversions facilities to be available.
1520 set src string_conversions[pid].cc
1522 set f [open $src "w"]
1523 puts $f "#include <bits/c++config.h>"
1524 puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1525 puts $f "# error No string conversions"
1526 puts $f "#endif"
1527 close $f
1529 set cxxflags_saved $cxxflags
1530 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1532 set lines [v3_target_compile $src /dev/null preprocess ""]
1533 set cxxflags $cxxflags_saved
1534 file delete $src
1536 if [string match "" $lines] {
1537 # No error message, preprocessing succeeded.
1538 set et_string_conversions 1
1539 } else {
1540 verbose "check_v3_target_string_conversions: compilation failed" 2
1543 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1544 return $et_string_conversions
1547 proc check_v3_target_swprintf { } {
1548 global cxxflags
1549 global DEFAULT_CXXFLAGS
1550 global et_swprintf
1552 global tool
1554 if { ![info exists et_swprintf_target_name] } {
1555 set et_swprintf_target_name ""
1558 # If the target has changed since we set the cached value, clear it.
1559 set current_target [current_target_name]
1560 if { $current_target != $et_swprintf_target_name } {
1561 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1562 set et_swprintf_target_name $current_target
1563 if [info exists et_swprintf] {
1564 verbose "check_v3_target_swprintf: removing cached result" 2
1565 unset et_swprintf
1569 if [info exists et_swprintf] {
1570 verbose "check_v3_target_swprintf: using cached result" 2
1571 } else {
1572 set et_swprintf 0
1574 # Set up and preprocess a C++0x test program that depends
1575 # on a standard swprintf function to be available.
1576 set src swprintf[pid].cc
1578 set f [open $src "w"]
1579 puts $f "#include <bits/c++config.h>"
1580 puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1581 puts $f "# error No swprintf"
1582 puts $f "#endif"
1583 close $f
1585 set cxxflags_saved $cxxflags
1586 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1588 set lines [v3_target_compile $src /dev/null preprocess ""]
1589 set cxxflags $cxxflags_saved
1590 file delete $src
1592 if [string match "" $lines] {
1593 # No error message, preprocessing succeeded.
1594 set et_swprintf 1
1595 } else {
1596 verbose "check_v3_target_swprintf: compilation failed" 2
1599 verbose "check_v3_target_swprintf: $et_swprintf" 2
1600 return $et_swprintf
1603 proc check_v3_target_binary_io { } {
1604 global cxxflags
1605 global DEFAULT_CXXFLAGS
1606 global et_binary_io
1608 global tool
1610 if { ![info exists et_binary_io_target_name] } {
1611 set et_binary_io_target_name ""
1614 # If the target has changed since we set the cached value, clear it.
1615 set current_target [current_target_name]
1616 if { $current_target != $et_binary_io_target_name } {
1617 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1618 set et_binary_io_target_name $current_target
1619 if [info exists et_binary_io] {
1620 verbose "check_v3_target_binary_io: removing cached result" 2
1621 unset et_binary_io
1625 if [info exists et_binary_io] {
1626 verbose "check_v3_target_binary_io: using cached result" 2
1627 } else {
1628 set et_binary_io 0
1630 # Set up and preprocess a C++0x test program that depends
1631 # on text and binary I/O being the same.
1632 set src binary_io[pid].cc
1634 set f [open $src "w"]
1635 puts $f "#include <bits/c++config.h>"
1636 puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1637 puts $f "# error No binary io"
1638 puts $f "#endif"
1639 close $f
1641 set cxxflags_saved $cxxflags
1642 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1644 set lines [v3_target_compile $src /dev/null preprocess ""]
1645 set cxxflags $cxxflags_saved
1646 file delete $src
1648 if [string match "" $lines] {
1649 # No error message, preprocessing succeeded.
1650 set et_binary_io 1
1651 } else {
1652 verbose "check_v3_target_binary_io: compilation failed" 2
1655 verbose "check_v3_target_binary_io: $et_binary_io" 2
1656 return $et_binary_io
1659 proc check_v3_target_nprocs { } {
1660 global cxxflags
1661 global DEFAULT_CXXFLAGS
1662 global et_nprocs
1664 global tool
1666 if { ![info exists et_nprocs_target_name] } {
1667 set et_nprocs_target_name ""
1670 # If the target has changed since we set the cached value, clear it.
1671 set current_target [current_target_name]
1672 if { $current_target != $et_nprocs_target_name } {
1673 verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1674 set et_nprocs_target_name $current_target
1675 if [info exists et_nprocs] {
1676 verbose "check_v3_target_nprocs: removing cached result" 2
1677 unset et_nprocs
1681 if [info exists et_nprocs] {
1682 verbose "check_v3_target_nprocs: using cached result" 2
1683 } else {
1684 set et_nprocs 0
1686 # Set up and preprocess a C++0x test program that depends
1687 # on either get_nprocs or sysconf to be available.
1688 set src nprocs[pid].cc
1690 set f [open $src "w"]
1691 puts $f "#include <bits/c++config.h>"
1692 puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
1693 puts $f "#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1694 puts $f "#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1695 puts $f "#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1696 puts $f "#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
1697 puts $f "#else"
1698 puts $f "# error hardware_concurrency not implemented"
1699 puts $f "#endif"
1700 close $f
1702 set cxxflags_saved $cxxflags
1703 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1705 set lines [v3_target_compile $src /dev/null preprocess ""]
1706 set cxxflags $cxxflags_saved
1707 file delete $src
1709 if [string match "" $lines] {
1710 # No error message, preprocess succeeded.
1711 set et_nprocs 1
1712 } else {
1713 verbose "check_v3_target_nprocs: compilation failed" 2
1716 verbose "check_v3_target_nprocs: $et_nprocs" 2
1717 return $et_nprocs
1720 proc check_v3_target_static_libstdcxx { } {
1721 global cxxflags
1722 global DEFAULT_CXXFLAGS
1723 global et_static_libstdcxx
1725 global tool
1727 if [info exists et_static_libstdcxx] {
1728 verbose "check_v3_target_static_libstdcxx: using cached result" 2
1729 } else {
1730 set et_static_libstdcxx 0
1732 # Set up and link a C++0x test program that depends
1733 # on static linking
1734 set src static-maybe[pid].cc
1736 set f [open $src "w"]
1737 puts $f "#include <iostream>"
1738 puts $f "int main() {"
1739 puts $f "int i(415);"
1740 puts $f "std::cout<< i << std::endl;"
1741 puts $f "return 0; }"
1742 puts $f ""
1743 close $f
1745 set cxxflags_saved $cxxflags
1746 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -static-libstdc++"
1748 set lines [v3_target_compile $src /dev/null executable ""]
1749 set cxxflags $cxxflags_saved
1750 file delete $src
1752 if [string match "" $lines] {
1753 # No error message, link succeeded.
1754 set et_static_libstdcxx 1
1755 } else {
1756 verbose "check_v3_target_static_libstdcxx: compilation failed" 2
1759 verbose "check_v3_target_static_libstdcxx: $et_static_libstdcxx" 2
1760 return $et_static_libstdcxx
1763 proc check_v3_target_little_endian { } {
1764 global cxxflags
1765 global DEFAULT_CXXFLAGS
1766 global et_little_endian
1768 global tool
1770 if { ![info exists et_little_endian_target_name] } {
1771 set et_little_endian_target_name ""
1774 # If the target has changed since we set the cached value, clear it.
1775 set current_target [current_target_name]
1776 if { $current_target != $et_little_endian_target_name } {
1777 verbose "check_v3_target_little_endian: `$et_little_endian_target_name'" 2
1778 set et_little_endian_target_name $current_target
1779 if [info exists et_little_endian] {
1780 verbose "check_v3_target_little_endian: removing cached result" 2
1781 unset et_little_endian
1785 if [info exists et_little_endian] {
1786 verbose "check_v3_target_little_endian: using cached result" 2
1787 } else {
1788 set et_little_endian 0
1790 set src little_endian[pid].cc
1792 set f [open $src "w"]
1793 puts $f "#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__"
1794 puts $f "# error Not little endian"
1795 puts $f "#endif"
1796 close $f
1798 set cxxflags_saved $cxxflags
1799 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1801 set lines [v3_target_compile $src /dev/null preprocess ""]
1802 set cxxflags $cxxflags_saved
1803 file delete $src
1805 if [string match "" $lines] {
1806 # No error message, preprocessing succeeded.
1807 set et_little_endian 1
1808 } else {
1809 verbose "check_v3_target_little_endian: compilation failed" 2
1812 verbose "check_v3_target_little_endian: $et_little_endian" 2
1813 return $et_little_endian
1816 set additional_prunes ""