1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
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 wrapper.exp
58 # Useful for debugging. Pass the name of a variable and the verbosity
59 # threshold (number of -v's on the command line).
60 proc v3track { var n } {
62 verbose "++ $var is $val" $n
65 # Called by v3-init below. "Static" to this file.
66 proc v3-copy-files {srcfiles} {
68 if { [catch { set symlink [file readlink $f] } x] } then {
69 remote_download target $f
71 if { [regexp "^/" "$symlink"] } then {
72 remote_download target $symlink
74 set dirname [file dirname $f]
75 remote_download target $dirname/$symlink
81 # Called once, during runtest.exp setup.
82 proc libstdc++_init { testfile } {
84 global v3-sharedlib v3-libgomp
85 global srcdir blddir objdir tool_root_dir
86 global cc cxx cxxflags cxxpchflags cxxldflags
88 global gluefile wrap_flags
89 global ld_library_path
93 # We set LC_ALL and LANG to C so that we get the same error
94 # messages as expected.
98 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
99 set flags_file "${blddir}/scripts/testsuite_flags"
102 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
103 # Use this variable if the behavior
104 # 1) only applies to libstdc++ testing
105 # 2) might need to be negated
106 # In particular, some tests have to be run without precompiled
107 # headers, or without assertions.
108 global DEFAULT_CXXFLAGS
109 if ![info exists DEFAULT_CXXFLAGS] then {
110 set DEFAULT_CXXFLAGS ""
111 # Host specific goo here.
112 if { [string match "powerpc-*-darwin*" $target_triplet] } {
113 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
116 v3track DEFAULT_CXXFLAGS 2
118 # By default, we assume we want to run program images.
119 global dg-do-what-default
120 set dg-do-what-default run
122 # Copy any required data files.
123 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
124 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
126 set ld_library_path_tmp ""
128 # Locate libgcc.a so we don't need to account for different values of
129 # SHLIB_EXT on different platforms
130 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
132 set gccdir [file dirname $gccdir]
133 append ld_library_path_tmp ":${gccdir}"
137 # Locate libgomp. This is only required for parallel mode.
139 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.so]
140 if {$libgompdir != ""} {
142 set libgompdir [file dirname $libgompdir]
143 append ld_library_path_tmp ":${libgompdir}"
144 verbose -log "libgomp support detected"
148 # Locate libstdc++ shared library. (ie libstdc++.so.)
150 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so]
151 if {$sharedlibdir != ""} {
152 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
154 verbose -log "shared library support detected"
157 v3track v3-sharedlib 3
159 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
161 set compiler ${gccdir}/g++
162 set ld_library_path ${ld_library_path_tmp}
163 append ld_library_path ":${blddir}/src/.libs"
165 if { [is_remote host] == 0 && [which $compiler] != 0 } {
166 foreach i "[exec $compiler --print-multi-lib]" {
168 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
169 set mldir [string trimright $mldir "\;@"]
170 if { "$mldir" == "." } {
173 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
174 append ld_library_path ":${gccdir}/${mldir}"
179 set_ld_library_path_env_vars
180 if [info exists env(LD_LIBRARY_PATH)] {
181 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
184 set compiler [transform "g++"]
188 set cxx [transform "g++"]
189 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
192 set cc [transform "gcc"]
193 # Locate testsuite_hooks.h and other testsuite headers.
194 set includes "-I${srcdir}/util"
195 # Adapt the defaults for special circumstances.
196 if [is_remote host] {
197 # A remote host does not, in general, have access to the
198 # $srcdir so we copy the testsuite headers into the current
199 # directory, and then add that to the search path.
200 foreach src [glob "${srcdir}/util/*.h" \
201 "${srcdir}/util/*.cc" \
202 "${srcdir}/util/*/*.hpp" \
203 "${srcdir}/util/*/*.cc" \
204 "${srcdir}/util/*/*.hpp" \
205 "${srcdir}/util/*/*/*.cc" \
206 "${srcdir}/util/*/*/*.hpp" \
207 "${srcdir}/util/*/*/*/*.cc" \
208 "${srcdir}/util/*/*/*/*.hpp" \
209 "${srcdir}/util/*/*/*/*/*.cc" \
210 "${srcdir}/util/*/*/*/*/*.hpp" ] {
211 # Remove everything up to "util/..."
212 set dst [string range $src [string length "${srcdir}/"] end]
213 # Create the directory containing the file.
214 set dir [file dirname $dst]
215 remote_exec host "mkdir" [list "-p" "$dir"]
217 set result [remote_download host $src $dst]
218 if { $result == "" } {
219 verbose -log "Unable to download ${srcdir}/${src} to host."
223 set includes "-Iutil"
224 } elseif { [file exists $flags_file] } {
225 # If we find a testsuite_flags file, we're testing in the build dir.
226 set cxx [exec sh $flags_file --build-cxx]
227 set cxxflags [exec sh $flags_file --cxxflags]
228 set cxxpchflags [exec sh $flags_file --cxxpchflags]
229 set cxxldflags [exec sh $flags_file --cxxldflags]
230 set cc [exec sh $flags_file --build-cc]
231 set includes [exec sh $flags_file --build-includes]
234 append cxxflags [getenv CXXFLAGS]
237 # Always use MO files built by this test harness.
238 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
239 set ccflags "$cxxflags -DLOCALEDIR=\".\""
241 # If a PCH file is available, use it. We must delay performing
242 # this check until $cxx and such have been initialized because we
243 # perform a test compilation. (Ideally, gcc --print-file-name would
244 # list PCH files, but it does not.)
245 if { $cxxpchflags != "" } {
246 set src "config[pid].cc"
247 set f [open $src "w"]
248 puts $f "int main () {}"
251 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
252 # useful as then the requested variant of the pre-build PCH
253 # files could be tested to see if it works.
254 set lines [v3_target_compile $src "config[pid].o" object \
255 "additional_flags=-include additional_flags=bits/stdc++.h"]
256 if { $lines != "" } {
257 verbose -log "Requested PCH file: $cxxpchflags"
258 verbose -log "is not working, and will not be used."
263 v3track cxxpchflags 2
266 if ![info exists PCH_CXXFLAGS] then {
267 set PCH_CXXFLAGS $cxxpchflags
268 v3track PCH_CXXFLAGS 2
271 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
274 # Callback for cleanup routines.
275 proc libstdc++_exit { } {
278 if [info exists gluefile] {
279 file_on_build delete $gluefile;
284 # Callback from system dg-test.
285 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
286 # Set up the compiler flags, based on what we're going to do.
289 set compile_type "preprocess"
290 set output_file "[file rootname [file tail $prog]].i"
293 set compile_type "assembly"
294 set output_file "[file rootname [file tail $prog]].s"
297 set compile_type "object"
298 set output_file "[file rootname [file tail $prog]].o"
301 set compile_type "executable"
302 set output_file "./[file rootname [file tail $prog]].exe"
305 set compile_type "executable"
306 # FIXME: "./" is to cope with "." not being in $PATH.
307 # Should this be handled elsewhere?
309 set output_file "./[file rootname [file tail $prog]].exe"
310 # This is the only place where we care if an executable was
311 # created or not. If it was, dg.exp will try to run it.
312 catch { remote_file build delete $output_file }
315 perror "$do_what: not a valid dg-do keyword"
320 # Short-circut a bunch of complicated goo here for the special
321 # case of compiling a test file as a "C" file, not as C++. Why? So
322 # -nostdc++ doesn't trip us up. So all the extra object files
323 # don't trip us up. So automatically linking in libstdc++ doesn't
324 # happen. So CXXFLAGS don't error.
325 set select_compile "v3_target_compile"
327 if { $extra_tool_flags != "" } {
328 verbose -log "extra_tool_flags are:"
329 verbose -log $extra_tool_flags
330 if { [string first "-x c" $extra_tool_flags ] != -1 } {
331 verbose -log "compiling and executing as C, not C++"
332 set edit_tool_flags $extra_tool_flags
333 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
334 lappend options "additional_flags=$edit_tool_flags"
335 set select_compile "v3_target_compile_as_c"
337 lappend options "additional_flags=$extra_tool_flags"
341 # There is a libstdc++_compile made for us by default (via the tool-
342 # and-target file), but the defaults are lacking in goodness.
343 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
344 set comp_output [ prune_g++_output $comp_output ];
346 return [list $comp_output $output_file]
349 # True if the library supports wchar_t.
352 # True if the library supports threads.
355 # True if the library supports symbol versioning.
358 # Called from libstdc++-dg-test above. Calls back into system's
359 # target_compile to actually do the work.
360 proc v3_target_compile { source dest type options } {
368 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
369 lappend options "libs=${gluefile}"
370 lappend options "ldflags=${wrap_flags}"
374 set cxxlibglossflags [libgloss_link_flags]
375 set cxx_final [concat $cxx_final $cxxlibglossflags]
376 set cxx_final [concat $cxx_final $cxxflags]
377 set cxx_final [concat $cxx_final $includes]
379 # Flag setting based on type argument.
380 if { $type == "executable" } {
381 # Link the support objects into executables.
382 set cxx_final [concat $cxx_final $cxxldflags]
383 lappend options "additional_flags=./libtestc++.a"
385 if { $type == "sharedlib" } {
386 # Don't link in anything.
387 set type "executable"
391 lappend options "compiler=$cxx_final"
392 lappend options "timeout=600"
394 return [target_compile $source $dest $type $options]
398 # Called from libstdc++-dg-test above, but only for "C" compilation.
399 # Calls back into system's target_compile to actually do the work.
400 proc v3_target_compile_as_c { source dest type options } {
409 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
410 lappend options "libs=${gluefile}"
411 lappend options "ldflags=${wrap_flags}"
414 set tname [target_info name]
416 set cxxlibglossflags [libgloss_link_flags]
417 set cc_final [concat $cc_final $cxxlibglossflags]
418 set cc_final [concat $cc_final $cxxflags]
419 set cc_final [concat $cc_final $includes]
420 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
422 # This is needed for "C" tests, as this type of test may need the
423 # C++ includes. And if we're not testing in the build directory,
424 # the includes variable is not likely to include the necessary
426 if { ![file exists $flags_file] } {
427 # ??? We need a --print-include-dirs option to GCC, so that
428 # we can avoid these hacks. The heuristics here will not
429 # work with non-standard --with-includedir= options.
430 set version [remote_exec host ${cc} -dumpversion]
431 # Remove the trailing newline from the output.
432 set version [string trimright [lindex $version 1]]
433 set machine [remote_exec host ${cc} -dumpmachine]
434 set machine [string trimright [lindex $machine 1]]
435 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
436 set comp_base_dir [lindex $comp_base_dir 1]
437 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
438 # For a cross compiler, the header files will be located in a
439 # machine-specific subdirectory.
440 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
441 set crosstarget "${crossbase}/${machine}"
442 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
443 # For a native compiler, the header files will be located at
445 set includesbase "${comp_base_dir}/include/c++/${version}"
446 set includestarget "${includesbase}/${machine}"
447 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
449 set libdir "-L${comp_base_dir}/lib"
451 set libdir "-L${blddir}/libsupc++/.libs"
452 set libdir [concat $libdir "-L${blddir}/src/.libs"]
455 set cc_final [concat $cc_final "$libdir"]
457 lappend options "compiler=$cc_final"
458 lappend options "timeout=600"
460 return [target_compile $source $dest $type $options]
463 # Build the support objects linked in with the libstdc++ tests. In
464 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
465 proc v3-build_support { } {
473 # Figure out whether or not the library supports certain features.
479 set config_src "config.cc"
480 set config_out "config.ii"
481 set f [open $config_src "w"]
482 puts $f "#include <bits/c++config.h>"
483 puts $f "#include <bits/gthr.h>"
485 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
486 set file [open $config_out r]
487 set preprocessed [read $file]
489 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
490 verbose -log "wchar_t support detected"
493 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
494 verbose -log "symbol versioning support detected"
497 if { [string first "__GTHREADS" $preprocessed] != -1 } {
498 verbose -log "thread support detected"
502 # Try to build the MO files that are used by some of the locale
503 # tests. If we can't build them, that's OK; it just means that
504 # those tests will fail.
505 foreach lang [list "fr" "de"] {
507 file mkdir "$lang/LC_MESSAGES"
508 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
509 if [is_remote host] {
510 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
511 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
516 # Build the support objects.
517 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
518 testsuite_character.cc testsuite_hooks.cc \
519 io/verified_cmd_line_input.cc \
520 io/prog_bar.cc performance/time/elapsed_timer.cc ]
521 foreach f $source_files {
522 set obj [file rootname $f].o
523 set object_file [file tail $obj]
524 # Compile with "-w" so that warnings issued by the compiler
525 # do not prevent compilation.
526 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
527 [list "incdir=$srcdir" "additional_flags=-w"]]
529 error "could not compile $f"
531 append libtest_objs "$object_file "
534 # Collect into libtestc++.a
535 if [info exists env(AR)] {
538 set ar [transform "ar"]
540 set arargs "-rc ./libtestc++.a ${libtest_objs}"
541 verbose -log "$ar $arargs"
542 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
543 verbose "link result is $result"
544 if { $result == 0 } {
545 if [info exists env(RANLIB)] {
546 set ranlib $env(RANLIB)
548 set ranlib [transform "ranlib"]
550 set ranlibargs "./libtestc++.a"
551 verbose -log "$ranlib $ranlibargs"
552 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
553 if { $result != 0 } {
554 error "could not link libtestc++.a"
558 # Build any shared objects needed for regression testing.
559 if { ${v3-sharedlib} == 1 } {
560 set source_files [list testsuite_shared.cc]
561 foreach f $source_files {
562 set object_file [file rootname $f].so
563 # Compile with "-w" so that warnings issued by the compiler
564 # do not prevent compilation.
565 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
566 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
568 error "could not compile $f"
574 proc check_v3_target_fileio { } {
575 global et_fileio_saved
576 global et_fileio_target_name
579 if { ![info exists et_fileio_target_name] } {
580 set et_fileio_target_name ""
583 # If the target has changed since we set the cached value, clear it.
584 set current_target [current_target_name]
585 if { $current_target != $et_fileio_target_name } {
586 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
587 set et_fileio_target_name $current_target
588 if [info exists et_fileio_saved] {
589 verbose "check_v3_target_fileio: removing cached result" 2
590 unset et_fileio_saved
594 if [info exists et_fileio_saved] {
595 verbose "check_v3_target_fileio: using cached result" 2
597 set et_fileio_saved 0
599 # Set up, compile, and execute a C++ test program that tries to use
601 set src fileio[pid].cc
602 set exe fileio[pid].x
604 set f [open $src "w"]
605 puts $f "#include <sys/types.h>"
606 puts $f "#include <sys/stat.h>"
607 puts $f "#include <fcntl.h>"
608 puts $f "#include <unistd.h>"
609 puts $f "#include <errno.h>"
610 puts $f "using namespace std;"
611 puts $f "int main ()"
613 puts $f " int fd = open (\".\", O_RDONLY);"
614 puts $f " int ret = 0;"
615 puts $f " if (fd == -1)"
617 puts $f " int err = errno;"
618 puts $f " if (err == EIO || err == ENOSYS)"
623 puts $f " if (lseek (fd, 0, SEEK_CUR) == -1)"
625 puts $f " close (fd);"
627 puts $f " return ret;"
631 set lines [v3_target_compile $src $exe executable ""]
634 if [string match "" $lines] {
635 # No error message, compilation succeeded.
636 set result [${tool}_load "./$exe" "" ""]
637 set status [lindex $result 0]
638 remote_file build delete $exe
640 verbose "check_v3_target_fileio: status is <$status>" 2
642 if { $status == "pass" } {
643 set et_fileio_saved 1
646 verbose "check_v3_target_fileio: compilation failed" 2
649 return $et_fileio_saved
652 # Eventually we want C90/C99 determining and switching from this.
653 proc check_v3_target_c_std { } {
654 global et_c_std_saved
655 global et_c_std_target_name
658 if { ![info exists et_c_std_target_name] } {
659 set et_c_std_target_name ""
662 # If the target has changed since we set the cached value, clear it.
663 set current_target [current_target_name]
664 if { $current_target != $et_c_std_target_name } {
665 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
666 set et_c_std_target_name $current_target
667 if [info exists et_c_std_saved] {
668 verbose "check_v3_target_c_std: removing cached result" 2
673 if [info exists et_c_std_saved] {
674 verbose "check_v3_target_c_std: using cached result" 2
678 # Set up, compile, and execute a C++ test program that tries to use
680 # For math bits, could use check_effective_target_c99_math.
681 set src fileio[pid].cc
682 set exe fileio[pid].x
684 set f [open $src "w"]
685 puts $f "#include <tr1/cmath>"
686 puts $f "#include <cstdlib>"
687 puts $f "int main ()"
689 puts $f " float f = 45.55;"
690 puts $f " int i = std::tr1::isnan(f);"
692 puts $f " using std::wctomb;"
697 set lines [v3_target_compile $src $exe executable ""]
700 if [string match "" $lines] {
701 # No error message, compilation succeeded.
702 set result [${tool}_load "./$exe" "" ""]
703 set status [lindex $result 0]
704 remote_file build delete $exe
706 verbose "check_v3_target_c_std: status is <$status>" 2
708 if { $status == "pass" } {
712 verbose "check_v3_target_c_std: compilation failed" 2
715 return $et_c_std_saved
718 proc check_v3_target_sharedlib { } {
720 return ${v3-sharedlib}
723 proc check_v3_target_time { } {
725 global et_time_target_name
728 if { ![info exists et_time_target_name] } {
729 set et_time_target_name ""
732 # If the target has changed since we set the cached value, clear it.
733 set current_target [current_target_name]
734 if { $current_target != $et_time_target_name } {
735 verbose "check_v3_target_time: `$et_time_target_name'" 2
736 set et_time_target_name $current_target
737 if [info exists et_time_saved] {
738 verbose "check_v3_target_time: removing cached result" 2
743 if [info exists et_time_saved] {
744 verbose "check_v3_target_time: using cached result" 2
748 # Set up and compile a C++ test program that tries to use
753 set f [open $src "w"]
754 puts $f "#include <time.h>"
755 puts $f "using namespace std;"
756 puts $f "int main ()"
762 set lines [v3_target_compile $src $exe executable ""]
765 if [string match "" $lines] {
766 # No error message, compilation succeeded.
767 verbose "check_v3_target_time: compilation succeeded" 2
768 remote_file build delete $exe
771 verbose "check_v3_target_time: compilation failed" 2
774 return $et_time_saved
777 proc check_v3_target_rvalref { } {
778 global et_rvalref_saved
779 global et_rvalref_target_name
782 if { ![info exists et_rvalref_target_name] } {
783 set et_rvalref_target_name ""
786 # If the target has changed since we set the cached value, clear it.
787 set current_target [current_target_name]
788 if { $current_target != $et_rvalref_target_name } {
789 verbose "check_v3_target_rvalref: `$et_rvalref_target_name'" 2
790 set et_rvalref_target_name $current_target
791 if [info exists et_rvalref_saved] {
792 verbose "check_v3_target_rvalref: removing cached result" 2
793 unset et_rvalref_saved
797 if [info exists et_rvalref_saved] {
798 verbose "check_v3_target_rvalref: using cached result" 2
800 set et_rvalref_saved 0
802 # Set up and compile a C++ test program that tries to use
803 # the library components of rval references
804 set src rvalref[pid].cc
805 set exe rvalref[pid].x
807 set f [open $src "w"]
808 puts $f "#include <iterator>"
809 puts $f "#include <utility>"
810 puts $f "using std::move;"
811 puts $f "using std::identity;"
812 puts $f "using std::forward;"
813 puts $f "using std::move_iterator;"
814 puts $f "using std::make_move_iterator;"
817 set lines [v3_target_compile $src $exe executable ""]
820 if [string match "" $lines] {
821 # No error message, compilation succeeded.
822 verbose "check_v3_target_rvalref: compilation succeeded" 2
823 remote_file build delete $exe
824 set et_rvalref_saved 1
826 verbose "check_v3_target_rvalref: compilation failed" 2
829 return $et_rvalref_saved
832 proc check_v3_target_namedlocale { } {
833 global et_namedlocale_saved
834 global et_namedlocale_target_name
837 if { ![info exists et_namedlocale_target_name] } {
838 set et_namedlocale_target_name ""
841 # If the target has changed since we set the cached value, clear it.
842 set current_target [current_target_name]
843 if { $current_target != $et_namedlocale_target_name } {
844 verbose "check_v3_target_namedlocale: `$et_namedlocale_target_name'" 2
845 set et_namedlocale_target_name $current_target
846 if [info exists et_namedlocale_saved] {
847 verbose "check_v3_target_namedlocale: removing cached result" 2
848 unset et_namedlocale_saved
852 if [info exists et_namedlocale_saved] {
853 verbose "check_v3_target_namedlocale: using cached result" 2
855 set et_namedlocale_saved 0
857 # Set up, compile, and execute a C++ test program that tries to use
858 # all the required named locales.
859 set src nlocale[pid].cc
860 set exe nlocale[pid].x
862 set f [open $src "w"]
863 puts $f "#include <locale>"
864 puts $f "using namespace std;"
865 puts $f "int main ()"
869 puts $f " locale(\"\");"
870 puts $f " locale(\"de_DE\");"
871 puts $f " locale(\"de_DE.ISO-8859-15@euro\");"
872 puts $f " locale(\"de_DE@euro\");"
873 puts $f " locale(\"en_HK\");"
874 puts $f " locale(\"en_PH\");"
875 puts $f " locale(\"en_US\");"
876 puts $f " locale(\"en_US.ISO-8859-1\");"
877 puts $f " locale(\"en_US.ISO-8859-15\");"
878 puts $f " locale(\"en_US.UTF-8\");"
879 puts $f " locale(\"es_ES\");"
880 puts $f " locale(\"es_MX\");"
881 puts $f " locale(\"fr_FR\");"
882 puts $f " locale(\"fr_FR@euro\");"
883 puts $f " locale(\"is_IS\");"
884 puts $f " locale(\"is_IS.UTF-8\");"
885 puts $f " locale(\"it_IT\");"
886 puts $f " locale(\"ja_JP.eucjp\");"
887 puts $f " locale(\"se_NO.UTF-8\");"
888 puts $f " locale(\"ta_IN\");"
889 puts $f " locale(\"zh_TW\");"
892 puts $f " catch(...)"
899 set lines [v3_target_compile $src $exe executable ""]
902 if [string match "" $lines] {
903 # No error message, compilation succeeded.
904 set result [${tool}_load "./$exe" "" ""]
905 set status [lindex $result 0]
906 remote_file build delete $exe
908 verbose "check_v3_target_namedlocale: status is <$status>" 2
910 if { $status == "pass" } {
911 set et_namedlocale_saved 1
914 verbose "check_v3_target_namedlocale: compilation failed" 2
917 return $et_namedlocale_saved
920 proc check_v3_target_debug_mode { } {
925 if { ![info exists et_debug_mode_target_name] } {
926 set et_debug_mode_target_name ""
929 # If the target has changed since we set the cached value, clear it.
930 set current_target [current_target_name]
931 if { $current_target != $et_debug_mode_target_name } {
932 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
933 set et_debug_mode_target_name $current_target
934 if [info exists et_debug_mode] {
935 verbose "check_v3_target_debug_mode: removing cached result" 2
940 if [info exists et_debug_mode] {
941 verbose "check_v3_target_debug_mode: using cached result" 2
945 # Set up and compile a C++ test program that depends
946 # on debug mode working.
947 set src debug_mode[pid].cc
948 set exe debug_mode[pid].exe
950 set f [open $src "w"]
951 puts $f "#include <string>"
952 puts $f "using namespace std;"
954 puts $f "{ return 0; }"
957 set cxxflags_saved $cxxflags
958 set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG"
959 set lines [v3_target_compile $src $exe executable ""]
960 set cxxflags $cxxflags_saved
963 if [string match "" $lines] {
964 # No error message, compilation succeeded.
968 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
969 return $et_debug_mode
972 proc check_v3_target_parallel_mode { } {
975 global et_parallel_mode
979 if { ![info exists et_parallel_mode_target_name] } {
980 set et_parallel_mode_target_name ""
983 # If the target has changed since we set the cached value, clear it.
984 set current_target [current_target_name]
985 if { $current_target != $et_parallel_mode_target_name } {
986 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
987 set et_parallel_mode_target_name $current_target
988 if [info exists et_parallel_mode] {
989 verbose "check_v3_target_parallel_mode: removing cached result" 2
990 unset et_parallel_mode
994 if [info exists et_parallel_mode] {
995 verbose "check_v3_target_parallel_mode: using cached result" 2
997 set et_parallel_mode 0
999 # If 'make check-parallel' is running the test succeeds.
1000 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1001 set et_parallel_mode 1
1004 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1005 return $et_parallel_mode
1008 proc check_v3_target_cstdint { } {
1010 global DEFAULT_CXXFLAGS
1015 if { ![info exists et_cstdint_target_name] } {
1016 set et_cstdint_target_name ""
1019 # If the target has changed since we set the cached value, clear it.
1020 set current_target [current_target_name]
1021 if { $current_target != $et_cstdint_target_name } {
1022 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1023 set et_cstdint_target_name $current_target
1024 if [info exists et_cstdint] {
1025 verbose "check_v3_target_cstdint: removing cached result" 2
1030 if [info exists et_cstdint] {
1031 verbose "check_v3_target_cstdint: using cached result" 2
1035 # Set up and compile a C++0x test program that depends
1036 # on the C99 stdint facilities to be available.
1037 set src cstdint[pid].cc
1038 set exe cstdint[pid].exe
1040 set f [open $src "w"]
1041 puts $f "#include <tr1/cstdint>"
1042 puts $f "int main()"
1043 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1044 puts $f "{ return 0; }"
1048 set cxxflags_saved $cxxflags
1049 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1051 set lines [v3_target_compile $src $exe executable ""]
1052 set cxxflags $cxxflags_saved
1055 if [string match "" $lines] {
1056 # No error message, compilation succeeded.
1059 verbose "check_v3_target_cstdint: compilation failed" 2
1062 verbose "check_v3_target_cstdint: $et_cstdint" 2
1066 proc check_v3_target_atomic_builtins { } {
1068 global DEFAULT_CXXFLAGS
1073 if { ![info exists et_atomic_builtins_target_name] } {
1074 set et_atomic_builtins_target_name ""
1077 # If the target has changed since we set the cached value, clear it.
1078 set current_target [current_target_name]
1079 if { $current_target != $et_atomic_builtins_target_name } {
1080 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1081 set et_atomic_builtins_target_name $current_target
1082 if [info exists et_atomic_builtins] {
1083 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1084 unset et_atomic_builtins
1088 if [info exists et_atomic_builtins] {
1089 verbose "check_v3_target_atomic_builtins: using cached result" 2
1091 set et_atomic_builtins 0
1093 # Set up and compile a C++0x test program that depends
1094 # on the C99 stdint facilities to be available.
1095 set src atomic_builtins[pid].cc
1096 set exe atomic_builtins[pid].exe
1098 set f [open $src "w"]
1099 puts $f "#include <bits/c++config.h>"
1100 puts $f "int main()"
1101 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1102 puts $f "{ return 0; }"
1106 set cxxflags_saved $cxxflags
1107 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1109 set lines [v3_target_compile $src $exe executable ""]
1110 set cxxflags $cxxflags_saved
1113 if [string match "" $lines] {
1114 # No error message, compilation succeeded.
1115 set et_atomic_builtins 1
1117 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1120 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1121 return $et_atomic_builtins