1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 # Free Software Foundation, Inc.
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.
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.
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
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
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.
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-".
31 # libstdc++_* callbacks we don't define, but could:
32 # ..._option_help prints additional --help output
33 # ..._option_proc (--foo) process our own options
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
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.
42 proc load_gcc_lib { filename } {
44 load_file $srcdir/../../gcc/testsuite/lib/$filename
50 # compiler routines, then ours
51 load_gcc_lib target-supports.exp
52 load_gcc_lib target-supports-dg.exp
54 load_lib dg-options.exp
55 load_gcc_lib target-libpath.exp
56 load_gcc_lib timeout.exp
57 load_gcc_lib timeout-dg.exp
58 load_gcc_lib wrapper.exp
60 # Useful for debugging. Pass the name of a variable and the verbosity
61 # threshold (number of -v's on the command line).
62 proc v3track { var n } {
64 verbose "++ $var is $val" $n
67 # Called by v3-init below. "Static" to this file.
68 proc v3-copy-files {srcfiles} {
70 if { [catch { set symlink [file readlink $f] } x] } then {
71 remote_download target $f
73 if { [regexp "^/" "$symlink"] } then {
74 remote_download target $symlink
76 set dirname [file dirname $f]
77 remote_download target $dirname/$symlink
83 # Called once, during runtest.exp setup.
84 proc libstdc++_init { testfile } {
86 global v3-sharedlib v3-libgomp
87 global srcdir blddir objdir tool_root_dir
88 global cc cxx cxxflags cxxpchflags cxxldflags
90 global gluefile wrap_flags
91 global ld_library_path
96 # We set LC_ALL and LANG to C so that we get the same error
97 # messages as expected.
101 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
102 set flags_file "${blddir}/scripts/testsuite_flags"
105 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
106 # Use this variable if the behavior
107 # 1) only applies to libstdc++ testing
108 # 2) might need to be negated
109 # In particular, some tests have to be run without precompiled
110 # headers, or without assertions.
111 global DEFAULT_CXXFLAGS
112 if ![info exists DEFAULT_CXXFLAGS] then {
113 set DEFAULT_CXXFLAGS ""
114 # Host specific goo here.
115 if { [string match "powerpc-*-darwin*" $target_triplet] } {
116 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
119 v3track DEFAULT_CXXFLAGS 2
121 # By default, we assume we want to run program images.
122 global dg-do-what-default
123 set dg-do-what-default run
125 # Copy any required data files.
126 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
127 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
129 set ld_library_path_tmp ""
131 # Locate libgcc.a so we don't need to account for different values of
132 # SHLIB_EXT on different platforms
133 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
135 set gccdir [file dirname $gccdir]
136 append ld_library_path_tmp ":${gccdir}"
140 # Locate libgomp. This is only required for parallel mode.
142 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.so]
143 if {$libgompdir != ""} {
145 set libgompdir [file dirname $libgompdir]
146 append ld_library_path_tmp ":${libgompdir}"
147 verbose -log "libgomp support detected"
151 # Locate libstdc++ shared library. (ie libstdc++.so.)
153 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so]
154 if {$sharedlibdir != ""} {
155 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
157 verbose -log "shared library support detected"
160 v3track v3-sharedlib 3
162 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
164 set compiler ${gccdir}/g++
165 set ld_library_path ${ld_library_path_tmp}
166 append ld_library_path ":${blddir}/src/.libs"
168 if { [is_remote host] == 0 && [which $compiler] != 0 } {
169 foreach i "[exec $compiler --print-multi-lib]" {
171 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
172 set mldir [string trimright $mldir "\;@"]
173 if { "$mldir" == "." } {
176 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
177 append ld_library_path ":${gccdir}/${mldir}"
182 set_ld_library_path_env_vars
183 if [info exists env(LD_LIBRARY_PATH)] {
184 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
187 set compiler [transform "g++"]
190 # Set the default timeout for v3 tests.
194 set cxx [transform "g++"]
195 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
198 set cc [transform "gcc"]
199 # Locate testsuite_hooks.h and other testsuite headers.
200 set includes "-I${srcdir}/util"
201 # Adapt the defaults for special circumstances.
202 if [is_remote host] {
203 # A remote host does not, in general, have access to the
204 # $srcdir so we copy the testsuite headers into the current
205 # directory, and then add that to the search path.
206 foreach src [glob "${srcdir}/util/*.h" \
207 "${srcdir}/util/*.cc" \
208 "${srcdir}/util/*/*.hpp" \
209 "${srcdir}/util/*/*.cc" \
210 "${srcdir}/util/*/*.hpp" \
211 "${srcdir}/util/*/*/*.cc" \
212 "${srcdir}/util/*/*/*.hpp" \
213 "${srcdir}/util/*/*/*/*.cc" \
214 "${srcdir}/util/*/*/*/*.hpp" \
215 "${srcdir}/util/*/*/*/*/*.cc" \
216 "${srcdir}/util/*/*/*/*/*.hpp" ] {
217 # Remove everything up to "util/..."
218 set dst [string range $src [string length "${srcdir}/"] end]
219 # Create the directory containing the file.
220 set dir [file dirname $dst]
221 remote_exec host "mkdir" [list "-p" "$dir"]
223 set result [remote_download host $src $dst]
224 if { $result == "" } {
225 verbose -log "Unable to download ${srcdir}/${src} to host."
229 set includes "-Iutil"
230 } elseif { [file exists $flags_file] } {
231 # If we find a testsuite_flags file, we're testing in the build dir.
232 set cxx [exec sh $flags_file --build-cxx]
233 set cxxflags [exec sh $flags_file --cxxflags]
234 set cxxpchflags [exec sh $flags_file --cxxpchflags]
235 set cxxldflags [exec sh $flags_file --cxxldflags]
236 set cc [exec sh $flags_file --build-cc]
237 set includes [exec sh $flags_file --build-includes]
240 append cxxflags [getenv CXXFLAGS]
243 # Always use MO files built by this test harness.
244 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
245 set ccflags "$cxxflags -DLOCALEDIR=\".\""
247 # If a PCH file is available, use it. We must delay performing
248 # this check until $cxx and such have been initialized because we
249 # perform a test compilation. (Ideally, gcc --print-file-name would
250 # list PCH files, but it does not.)
251 if { $cxxpchflags != "" } {
252 set src "config[pid].cc"
253 set f [open $src "w"]
254 puts $f "int main () {}"
257 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
258 # useful as then the requested variant of the pre-build PCH
259 # files could be tested to see if it works.
260 set lines [v3_target_compile $src "config[pid].o" object \
261 "additional_flags=-include additional_flags=bits/stdc++.h"]
262 if { $lines != "" } {
263 verbose -log "Requested PCH file: $cxxpchflags"
264 verbose -log "is not working, and will not be used."
269 v3track cxxpchflags 2
272 if ![info exists PCH_CXXFLAGS] then {
273 set PCH_CXXFLAGS $cxxpchflags
274 v3track PCH_CXXFLAGS 2
277 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
280 # Callback for cleanup routines.
281 proc libstdc++_exit { } {
284 if [info exists gluefile] {
285 file_on_build delete $gluefile;
290 # Callback from system dg-test.
291 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
292 # Set up the compiler flags, based on what we're going to do.
295 set compile_type "preprocess"
296 set output_file "[file rootname [file tail $prog]].i"
299 set compile_type "assembly"
300 set output_file "[file rootname [file tail $prog]].s"
303 set compile_type "object"
304 set output_file "[file rootname [file tail $prog]].o"
307 set compile_type "executable"
308 set output_file "./[file rootname [file tail $prog]].exe"
311 set compile_type "executable"
312 # FIXME: "./" is to cope with "." not being in $PATH.
313 # Should this be handled elsewhere?
315 set output_file "./[file rootname [file tail $prog]].exe"
316 # This is the only place where we care if an executable was
317 # created or not. If it was, dg.exp will try to run it.
318 catch { remote_file build delete $output_file }
321 perror "$do_what: not a valid dg-do keyword"
326 # Short-circut a bunch of complicated goo here for the special
327 # case of compiling a test file as a "C" file, not as C++. Why? So
328 # -nostdc++ doesn't trip us up. So all the extra object files
329 # don't trip us up. So automatically linking in libstdc++ doesn't
330 # happen. So CXXFLAGS don't error.
331 set select_compile "v3_target_compile"
333 if { $extra_tool_flags != "" } {
334 verbose -log "extra_tool_flags are:"
335 verbose -log $extra_tool_flags
336 if { [string first "-x c" $extra_tool_flags ] != -1 } {
337 verbose -log "compiling and executing as C, not C++"
338 set edit_tool_flags $extra_tool_flags
339 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
340 lappend options "additional_flags=$edit_tool_flags"
341 set select_compile "v3_target_compile_as_c"
343 lappend options "additional_flags=$extra_tool_flags"
347 # There is a libstdc++_compile made for us by default (via the tool-
348 # and-target file), but the defaults are lacking in goodness.
349 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
350 set comp_output [ prune_g++_output $comp_output ];
352 return [list $comp_output $output_file]
355 # Override the DejaGnu dg-test in order to clear flags after a test, as
356 # is done for compiler tests in gcc-dg.exp.
358 if { [info procs saved-dg-test] == [list] } {
359 rename dg-test saved-dg-test
361 proc dg-test { args } {
364 if { [ catch { eval saved-dg-test $args } errmsg ] } {
365 set saved_info $errorInfo
367 error $errmsg $saved_info
373 # True if the library supports wchar_t.
376 # True if the library supports threads.
379 # True if the library supports symbol versioning.
382 # Called from libstdc++-dg-test above. Calls back into system's
383 # target_compile to actually do the work.
384 proc v3_target_compile { source dest type options } {
392 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
393 lappend options "libs=${gluefile}"
394 lappend options "ldflags=${wrap_flags}"
398 set cxxlibglossflags [libgloss_link_flags]
399 set cxx_final [concat $cxx_final $cxxlibglossflags]
400 set cxx_final [concat $cxx_final $cxxflags]
401 set cxx_final [concat $cxx_final $includes]
403 # Flag setting based on type argument.
404 if { $type == "executable" } {
405 # Link the support objects into executables.
406 set cxx_final [concat $cxx_final $cxxldflags]
407 lappend options "additional_flags=./libtestc++.a"
409 if { $type == "sharedlib" } {
410 # Don't link in anything.
411 set type "executable"
415 lappend options "compiler=$cxx_final"
416 lappend options "timeout=[timeout_value]"
418 return [target_compile $source $dest $type $options]
422 # Called from libstdc++-dg-test above, but only for "C" compilation.
423 # Calls back into system's target_compile to actually do the work.
424 proc v3_target_compile_as_c { source dest type options } {
433 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
434 lappend options "libs=${gluefile}"
435 lappend options "ldflags=${wrap_flags}"
438 set tname [target_info name]
440 set cxxlibglossflags [libgloss_link_flags]
441 set cc_final [concat $cc_final $cxxlibglossflags]
442 set cc_final [concat $cc_final $cxxflags]
443 set cc_final [concat $cc_final $includes]
444 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
446 # This is needed for "C" tests, as this type of test may need the
447 # C++ includes. And if we're not testing in the build directory,
448 # the includes variable is not likely to include the necessary
450 if { ![file exists $flags_file] } {
451 # ??? We need a --print-include-dirs option to GCC, so that
452 # we can avoid these hacks. The heuristics here will not
453 # work with non-standard --with-includedir= options.
454 set version [remote_exec host ${cc} -dumpversion]
455 # Remove the trailing newline from the output.
456 set version [string trimright [lindex $version 1]]
457 set machine [remote_exec host ${cc} -dumpmachine]
458 set machine [string trimright [lindex $machine 1]]
459 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
460 set comp_base_dir [lindex $comp_base_dir 1]
461 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
462 # For a cross compiler, the header files will be located in a
463 # machine-specific subdirectory.
464 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
465 set crosstarget "${crossbase}/${machine}"
466 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
467 # For a native compiler, the header files will be located at
469 set includesbase "${comp_base_dir}/include/c++/${version}"
470 set includestarget "${includesbase}/${machine}"
471 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
473 set libdir "-L${comp_base_dir}/lib"
475 set libdir "-L${blddir}/libsupc++/.libs"
476 set libdir [concat $libdir "-L${blddir}/src/.libs"]
479 set cc_final [concat $cc_final "$libdir"]
481 lappend options "compiler=$cc_final"
482 lappend options "timeout=[timeout_value]"
484 return [target_compile $source $dest $type $options]
487 # Build the support objects linked in with the libstdc++ tests. In
488 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
489 proc v3-build_support { } {
497 # Figure out whether or not the library supports certain features.
503 set config_src "config.cc"
504 set config_out "config.ii"
505 set f [open $config_src "w"]
506 puts $f "#include <bits/c++config.h>"
507 puts $f "#include <bits/gthr.h>"
509 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
510 set file [open $config_out r]
511 set preprocessed [read $file]
513 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
514 verbose -log "wchar_t support detected"
517 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
518 verbose -log "symbol versioning support detected"
521 if { [string first "__GTHREADS" $preprocessed] != -1 } {
522 verbose -log "thread support detected"
526 # Try to build the MO files that are used by some of the locale
527 # tests. If we can't build them, that's OK; it just means that
528 # those tests will fail.
529 foreach lang [list "fr" "de"] {
531 file mkdir "$lang/LC_MESSAGES"
532 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
533 if [is_remote host] {
534 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
535 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
540 # Build the support objects.
541 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
542 testsuite_character.cc testsuite_hooks.cc \
543 io/verified_cmd_line_input.cc \
544 io/prog_bar.cc performance/time/elapsed_timer.cc ]
545 foreach f $source_files {
546 set obj [file rootname $f].o
547 set object_file [file tail $obj]
548 # Compile with "-w" so that warnings issued by the compiler
549 # do not prevent compilation.
550 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
551 [list "incdir=$srcdir" "additional_flags=-w"]]
553 error "could not compile $f"
555 append libtest_objs "$object_file "
558 # Collect into libtestc++.a
559 if [info exists env(AR)] {
562 set ar [transform "ar"]
564 set arargs "-rc ./libtestc++.a ${libtest_objs}"
565 verbose -log "$ar $arargs"
566 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
567 verbose "link result is $result"
568 if { $result == 0 } {
569 if [info exists env(RANLIB)] {
570 set ranlib $env(RANLIB)
572 set ranlib [transform "ranlib"]
574 set ranlibargs "./libtestc++.a"
575 verbose -log "$ranlib $ranlibargs"
576 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
577 if { $result != 0 } {
578 error "could not link libtestc++.a"
582 # Build any shared objects needed for regression testing.
583 if { ${v3-sharedlib} == 1 } {
584 set source_files [list testsuite_shared.cc]
585 foreach f $source_files {
586 set object_file [file rootname $f].so
587 # Compile with "-w" so that warnings issued by the compiler
588 # do not prevent compilation.
589 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
590 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
592 error "could not compile $f"
598 proc check_v3_target_fileio { } {
599 global et_fileio_saved
600 global et_fileio_target_name
603 if { ![info exists et_fileio_target_name] } {
604 set et_fileio_target_name ""
607 # If the target has changed since we set the cached value, clear it.
608 set current_target [current_target_name]
609 if { $current_target != $et_fileio_target_name } {
610 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
611 set et_fileio_target_name $current_target
612 if [info exists et_fileio_saved] {
613 verbose "check_v3_target_fileio: removing cached result" 2
614 unset et_fileio_saved
618 if [info exists et_fileio_saved] {
619 verbose "check_v3_target_fileio: using cached result" 2
621 set et_fileio_saved 0
623 # Set up, compile, and execute a C++ test program that tries to use
625 set src fileio[pid].cc
626 set exe fileio[pid].x
628 set f [open $src "w"]
629 puts $f "#include <sys/types.h>"
630 puts $f "#include <sys/stat.h>"
631 puts $f "#include <fcntl.h>"
632 puts $f "#include <unistd.h>"
633 puts $f "#include <errno.h>"
634 puts $f "using namespace std;"
635 puts $f "int main ()"
637 puts $f " int fd = open (\".\", O_RDONLY);"
638 puts $f " int ret = 0;"
639 puts $f " if (fd == -1)"
641 puts $f " int err = errno;"
642 puts $f " if (err == EIO || err == ENOSYS)"
647 puts $f " if (lseek (fd, 0, SEEK_CUR) == -1)"
649 puts $f " close (fd);"
651 puts $f " return ret;"
655 set lines [v3_target_compile $src $exe executable ""]
658 if [string match "" $lines] {
659 # No error message, compilation succeeded.
660 set result [${tool}_load "./$exe" "" ""]
661 set status [lindex $result 0]
662 remote_file build delete $exe
664 verbose "check_v3_target_fileio: status is <$status>" 2
666 if { $status == "pass" } {
667 set et_fileio_saved 1
670 verbose "check_v3_target_fileio: compilation failed" 2
673 return $et_fileio_saved
676 # Eventually we want C90/C99 determining and switching from this.
677 proc check_v3_target_c_std { } {
678 global et_c_std_saved
679 global et_c_std_target_name
682 if { ![info exists et_c_std_target_name] } {
683 set et_c_std_target_name ""
686 # If the target has changed since we set the cached value, clear it.
687 set current_target [current_target_name]
688 if { $current_target != $et_c_std_target_name } {
689 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
690 set et_c_std_target_name $current_target
691 if [info exists et_c_std_saved] {
692 verbose "check_v3_target_c_std: removing cached result" 2
697 if [info exists et_c_std_saved] {
698 verbose "check_v3_target_c_std: using cached result" 2
702 # Set up, compile, and execute a C++ test program that tries to use
704 # For math bits, could use check_effective_target_c99_math.
705 set src fileio[pid].cc
706 set exe fileio[pid].x
708 set f [open $src "w"]
709 puts $f "#include <tr1/cmath>"
710 puts $f "#include <cstdlib>"
711 puts $f "int main ()"
713 puts $f " float f = 45.55;"
714 puts $f " int i = std::tr1::isnan(f);"
716 puts $f " using std::wctomb;"
721 set lines [v3_target_compile $src $exe executable ""]
724 if [string match "" $lines] {
725 # No error message, compilation succeeded.
726 set result [${tool}_load "./$exe" "" ""]
727 set status [lindex $result 0]
728 remote_file build delete $exe
730 verbose "check_v3_target_c_std: status is <$status>" 2
732 if { $status == "pass" } {
736 verbose "check_v3_target_c_std: compilation failed" 2
739 return $et_c_std_saved
742 proc check_v3_target_sharedlib { } {
744 return ${v3-sharedlib}
747 proc check_v3_target_time { } {
749 global et_time_target_name
752 if { ![info exists et_time_target_name] } {
753 set et_time_target_name ""
756 # If the target has changed since we set the cached value, clear it.
757 set current_target [current_target_name]
758 if { $current_target != $et_time_target_name } {
759 verbose "check_v3_target_time: `$et_time_target_name'" 2
760 set et_time_target_name $current_target
761 if [info exists et_time_saved] {
762 verbose "check_v3_target_time: removing cached result" 2
767 if [info exists et_time_saved] {
768 verbose "check_v3_target_time: using cached result" 2
772 # Set up and compile a C++ test program that tries to use
777 set f [open $src "w"]
778 puts $f "#include <time.h>"
779 puts $f "using namespace std;"
780 puts $f "int main ()"
786 set lines [v3_target_compile $src $exe executable ""]
789 if [string match "" $lines] {
790 # No error message, compilation succeeded.
791 verbose "check_v3_target_time: compilation succeeded" 2
792 remote_file build delete $exe
795 verbose "check_v3_target_time: compilation failed" 2
798 return $et_time_saved
801 proc check_v3_target_rvalref { } {
802 global et_rvalref_saved
803 global et_rvalref_target_name
806 if { ![info exists et_rvalref_target_name] } {
807 set et_rvalref_target_name ""
810 # If the target has changed since we set the cached value, clear it.
811 set current_target [current_target_name]
812 if { $current_target != $et_rvalref_target_name } {
813 verbose "check_v3_target_rvalref: `$et_rvalref_target_name'" 2
814 set et_rvalref_target_name $current_target
815 if [info exists et_rvalref_saved] {
816 verbose "check_v3_target_rvalref: removing cached result" 2
817 unset et_rvalref_saved
821 if [info exists et_rvalref_saved] {
822 verbose "check_v3_target_rvalref: using cached result" 2
824 set et_rvalref_saved 0
826 # Set up and compile a C++ test program that tries to use
827 # the library components of rval references
828 set src rvalref[pid].cc
829 set exe rvalref[pid].x
831 set f [open $src "w"]
832 puts $f "#include <iterator>"
833 puts $f "#include <utility>"
834 puts $f "using std::move;"
835 puts $f "using std::identity;"
836 puts $f "using std::forward;"
837 puts $f "using std::move_iterator;"
838 puts $f "using std::make_move_iterator;"
841 set lines [v3_target_compile $src $exe executable ""]
844 if [string match "" $lines] {
845 # No error message, compilation succeeded.
846 verbose "check_v3_target_rvalref: compilation succeeded" 2
847 remote_file build delete $exe
848 set et_rvalref_saved 1
850 verbose "check_v3_target_rvalref: compilation failed" 2
853 return $et_rvalref_saved
856 proc check_v3_target_namedlocale { } {
857 global et_namedlocale_saved
858 global et_namedlocale_target_name
861 if { ![info exists et_namedlocale_target_name] } {
862 set et_namedlocale_target_name ""
865 # If the target has changed since we set the cached value, clear it.
866 set current_target [current_target_name]
867 if { $current_target != $et_namedlocale_target_name } {
868 verbose "check_v3_target_namedlocale: `$et_namedlocale_target_name'" 2
869 set et_namedlocale_target_name $current_target
870 if [info exists et_namedlocale_saved] {
871 verbose "check_v3_target_namedlocale: removing cached result" 2
872 unset et_namedlocale_saved
876 if [info exists et_namedlocale_saved] {
877 verbose "check_v3_target_namedlocale: using cached result" 2
879 set et_namedlocale_saved 0
881 # Set up, compile, and execute a C++ test program that tries to use
882 # all the required named locales.
883 set src nlocale[pid].cc
884 set exe nlocale[pid].x
886 set f [open $src "w"]
887 puts $f "#include <locale>"
888 puts $f "using namespace std;"
889 puts $f "int main ()"
893 puts $f " locale(\"\");"
894 puts $f " locale(\"de_DE\");"
895 puts $f " locale(\"de_DE.ISO-8859-15@euro\");"
896 puts $f " locale(\"de_DE@euro\");"
897 puts $f " locale(\"en_HK\");"
898 puts $f " locale(\"en_PH\");"
899 puts $f " locale(\"en_US\");"
900 puts $f " locale(\"en_US.ISO-8859-1\");"
901 puts $f " locale(\"en_US.ISO-8859-15\");"
902 puts $f " locale(\"en_US.UTF-8\");"
903 puts $f " locale(\"es_ES\");"
904 puts $f " locale(\"es_MX\");"
905 puts $f " locale(\"fr_FR\");"
906 puts $f " locale(\"fr_FR@euro\");"
907 puts $f " locale(\"is_IS\");"
908 puts $f " locale(\"is_IS.UTF-8\");"
909 puts $f " locale(\"it_IT\");"
910 puts $f " locale(\"ja_JP.eucjp\");"
911 puts $f " locale(\"se_NO.UTF-8\");"
912 puts $f " locale(\"ta_IN\");"
913 puts $f " locale(\"zh_TW\");"
916 puts $f " catch(...)"
923 set lines [v3_target_compile $src $exe executable ""]
926 if [string match "" $lines] {
927 # No error message, compilation succeeded.
928 set result [${tool}_load "./$exe" "" ""]
929 set status [lindex $result 0]
930 remote_file build delete $exe
932 verbose "check_v3_target_namedlocale: status is <$status>" 2
934 if { $status == "pass" } {
935 set et_namedlocale_saved 1
938 verbose "check_v3_target_namedlocale: compilation failed" 2
941 return $et_namedlocale_saved
944 proc check_v3_target_debug_mode { } {
949 if { ![info exists et_debug_mode_target_name] } {
950 set et_debug_mode_target_name ""
953 # If the target has changed since we set the cached value, clear it.
954 set current_target [current_target_name]
955 if { $current_target != $et_debug_mode_target_name } {
956 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
957 set et_debug_mode_target_name $current_target
958 if [info exists et_debug_mode] {
959 verbose "check_v3_target_debug_mode: removing cached result" 2
964 if [info exists et_debug_mode] {
965 verbose "check_v3_target_debug_mode: using cached result" 2
969 # Set up and compile a C++ test program that depends
970 # on debug mode working.
971 set src debug_mode[pid].cc
972 set exe debug_mode[pid].exe
974 set f [open $src "w"]
975 puts $f "#include <string>"
976 puts $f "using namespace std;"
978 puts $f "{ return 0; }"
981 set cxxflags_saved $cxxflags
982 set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG"
983 set lines [v3_target_compile $src $exe executable ""]
984 set cxxflags $cxxflags_saved
987 if [string match "" $lines] {
988 # No error message, compilation succeeded.
992 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
993 return $et_debug_mode
996 proc check_v3_target_parallel_mode { } {
999 global et_parallel_mode
1003 if { ![info exists et_parallel_mode_target_name] } {
1004 set et_parallel_mode_target_name ""
1007 # If the target has changed since we set the cached value, clear it.
1008 set current_target [current_target_name]
1009 if { $current_target != $et_parallel_mode_target_name } {
1010 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1011 set et_parallel_mode_target_name $current_target
1012 if [info exists et_parallel_mode] {
1013 verbose "check_v3_target_parallel_mode: removing cached result" 2
1014 unset et_parallel_mode
1018 if [info exists et_parallel_mode] {
1019 verbose "check_v3_target_parallel_mode: using cached result" 2
1021 set et_parallel_mode 0
1023 # If 'make check-parallel' is running the test succeeds.
1024 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1025 set et_parallel_mode 1
1028 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1029 return $et_parallel_mode
1032 proc check_v3_target_cstdint { } {
1034 global DEFAULT_CXXFLAGS
1039 if { ![info exists et_cstdint_target_name] } {
1040 set et_cstdint_target_name ""
1043 # If the target has changed since we set the cached value, clear it.
1044 set current_target [current_target_name]
1045 if { $current_target != $et_cstdint_target_name } {
1046 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1047 set et_cstdint_target_name $current_target
1048 if [info exists et_cstdint] {
1049 verbose "check_v3_target_cstdint: removing cached result" 2
1054 if [info exists et_cstdint] {
1055 verbose "check_v3_target_cstdint: using cached result" 2
1059 # Set up and compile a C++0x test program that depends
1060 # on the C99 stdint facilities to be available.
1061 set src cstdint[pid].cc
1062 set exe cstdint[pid].exe
1064 set f [open $src "w"]
1065 puts $f "#include <tr1/cstdint>"
1066 puts $f "int main()"
1067 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1068 puts $f "{ return 0; }"
1072 set cxxflags_saved $cxxflags
1073 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1075 set lines [v3_target_compile $src $exe executable ""]
1076 set cxxflags $cxxflags_saved
1079 if [string match "" $lines] {
1080 # No error message, compilation succeeded.
1083 verbose "check_v3_target_cstdint: compilation failed" 2
1086 verbose "check_v3_target_cstdint: $et_cstdint" 2
1090 proc check_v3_target_atomic_builtins { } {
1092 global DEFAULT_CXXFLAGS
1097 if { ![info exists et_atomic_builtins_target_name] } {
1098 set et_atomic_builtins_target_name ""
1101 # If the target has changed since we set the cached value, clear it.
1102 set current_target [current_target_name]
1103 if { $current_target != $et_atomic_builtins_target_name } {
1104 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1105 set et_atomic_builtins_target_name $current_target
1106 if [info exists et_atomic_builtins] {
1107 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1108 unset et_atomic_builtins
1112 if [info exists et_atomic_builtins] {
1113 verbose "check_v3_target_atomic_builtins: using cached result" 2
1115 set et_atomic_builtins 0
1117 # Set up and compile a C++0x test program that depends
1118 # on the atomic builtin facilities to be available.
1119 set src atomic_builtins[pid].cc
1120 set exe atomic_builtins[pid].exe
1122 set f [open $src "w"]
1123 puts $f "#include <bits/c++config.h>"
1124 puts $f "int main()"
1125 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1126 puts $f "{ return 0; }"
1130 set cxxflags_saved $cxxflags
1131 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1133 set lines [v3_target_compile $src $exe executable ""]
1134 set cxxflags $cxxflags_saved
1137 if [string match "" $lines] {
1138 # No error message, compilation succeeded.
1139 set et_atomic_builtins 1
1141 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1144 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1145 return $et_atomic_builtins
1148 proc check_v3_target_gthreads { } {
1150 global DEFAULT_CXXFLAGS
1155 if { ![info exists et_gthreads_target_name] } {
1156 set et_gthreads_target_name ""
1159 # If the target has changed since we set the cached value, clear it.
1160 set current_target [current_target_name]
1161 if { $current_target != $et_gthreads_target_name } {
1162 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1163 set et_gthreads_target_name $current_target
1164 if [info exists et_gthreads] {
1165 verbose "check_v3_target_gthreads: removing cached result" 2
1170 if [info exists et_gthreads] {
1171 verbose "check_v3_target_gthreads: using cached result" 2
1175 # Set up and compile a C++0x test program that depends
1176 # on the gthreads facilities to be available.
1177 set src gthreads[pid].cc
1178 set exe gthreads[pid].exe
1180 set f [open $src "w"]
1181 puts $f "#include <bits/c++config.h>"
1182 puts $f "int main()"
1183 puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
1184 puts $f "{ return 0; }"
1188 set cxxflags_saved $cxxflags
1189 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1191 set lines [v3_target_compile $src $exe executable ""]
1192 set cxxflags $cxxflags_saved
1195 if [string match "" $lines] {
1196 # No error message, compilation succeeded.
1199 verbose "check_v3_target_gthreads: compilation failed" 2
1202 verbose "check_v3_target_gthreads: $et_gthreads" 2
1206 proc check_v3_target_nanosleep { } {
1208 global DEFAULT_CXXFLAGS
1213 if { ![info exists et_nanosleep_target_name] } {
1214 set et_nanosleep_target_name ""
1217 # If the target has changed since we set the cached value, clear it.
1218 set current_target [current_target_name]
1219 if { $current_target != $et_nanosleep_target_name } {
1220 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1221 set et_nanosleep_target_name $current_target
1222 if [info exists et_nanosleep] {
1223 verbose "check_v3_target_nanosleep: removing cached result" 2
1228 if [info exists et_nanosleep] {
1229 verbose "check_v3_target_nanosleep: using cached result" 2
1233 # Set up and compile a C++0x test program that depends
1234 # on the nanosleep facilities to be available.
1235 set src nanosleep[pid].cc
1236 set exe nanosleep[pid].exe
1238 set f [open $src "w"]
1239 puts $f "#include <bits/c++config.h>"
1240 puts $f "int main()"
1241 puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
1242 puts $f "{ return 0; }"
1246 set cxxflags_saved $cxxflags
1247 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1249 set lines [v3_target_compile $src $exe executable ""]
1250 set cxxflags $cxxflags_saved
1253 if [string match "" $lines] {
1254 # No error message, compilation succeeded.
1257 verbose "check_v3_target_nanosleep: compilation failed" 2
1260 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1261 return $et_nanosleep
1264 proc check_v3_target_sched_yield { } {
1266 global DEFAULT_CXXFLAGS
1267 global et_sched_yield
1271 if { ![info exists et_sched_yield_target_name] } {
1272 set et_sched_yield_target_name ""
1275 # If the target has changed since we set the cached value, clear it.
1276 set current_target [current_target_name]
1277 if { $current_target != $et_sched_yield_target_name } {
1278 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1279 set et_sched_yield_target_name $current_target
1280 if [info exists et_sched_yield] {
1281 verbose "check_v3_target_sched_yield: removing cached result" 2
1282 unset et_sched_yield
1286 if [info exists et_sched_yield] {
1287 verbose "check_v3_target_sched_yield: using cached result" 2
1289 set et_sched_yield 0
1291 # Set up and compile a C++0x test program that depends
1292 # on the sched_yield facility to be available.
1293 set src sched_yield[pid].cc
1294 set exe sched_yield[pid].exe
1296 set f [open $src "w"]
1297 puts $f "#include <bits/c++config.h>"
1298 puts $f "int main()"
1299 puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
1300 puts $f "{ return 0; }"
1304 set cxxflags_saved $cxxflags
1305 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1307 set lines [v3_target_compile $src $exe executable ""]
1308 set cxxflags $cxxflags_saved
1311 if [string match "" $lines] {
1312 # No error message, compilation succeeded.
1313 set et_sched_yield 1
1315 verbose "check_v3_target_sched_yield: compilation failed" 2
1318 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1319 return $et_sched_yield
1322 proc check_v3_target_string_conversions { } {
1324 global DEFAULT_CXXFLAGS
1325 global et_string_conversions
1329 if { ![info exists et_string_conversions_target_name] } {
1330 set et_string_conversions_target_name ""
1333 # If the target has changed since we set the cached value, clear it.
1334 set current_target [current_target_name]
1335 if { $current_target != $et_string_conversions_target_name } {
1336 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1337 set et_string_conversions_target_name $current_target
1338 if [info exists et_string_conversions] {
1339 verbose "check_v3_target_string_conversions: removing cached result" 2
1340 unset et_string_conversions
1344 if [info exists et_string_conversions] {
1345 verbose "check_v3_target_string_conversions: using cached result" 2
1347 set et_string_conversions 0
1349 # Set up and compile a C++0x test program that depends
1350 # on the string_conversions facilities to be available.
1351 set src string_conversions[pid].cc
1352 set exe string_conversions[pid].exe
1354 set f [open $src "w"]
1355 puts $f "#include <bits/c++config.h>"
1356 puts $f "int main()"
1357 puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1358 puts $f "{ return 0; }"
1362 set cxxflags_saved $cxxflags
1363 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1365 set lines [v3_target_compile $src $exe executable ""]
1366 set cxxflags $cxxflags_saved
1369 if [string match "" $lines] {
1370 # No error message, compilation succeeded.
1371 set et_string_conversions 1
1373 verbose "check_v3_target_string_conversions: compilation failed" 2
1376 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1377 return $et_string_conversions