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 3 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; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
21 # Define callbacks and load other libraries. This file is loaded relatively
22 # early, and before any other file we write ourselves. "load_lib" will
23 # find anything in the DejaGNU installation tree, or in our lib directory.
24 # "load_gcc_lib" will search the core compiler's .exp collection instead.
26 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
27 # for "tool_" when finding callbacks. Utility routines we define for
28 # our callbacks begin with "v3-".
30 # libstdc++_* callbacks we don't define, but could:
31 # ..._option_help prints additional --help output
32 # ..._option_proc (--foo) process our own options
33 # ..._init (normal.exp) called once per test file
34 # ..._finish bracketing function for libstdc++_init
35 # ...-dg-prune removing output text, see top of system dg.exp
37 # Useful hook: if ${hostname}_init exists, it will be called, almost
38 # the last thing before testing begins. This can be defined in, e.g.,
39 # ~/.dejagnurc or $DEJAGNU.
41 proc load_gcc_lib { filename } {
43 load_file $srcdir/../../gcc/testsuite/lib/$filename
49 # compiler routines, then ours
50 load_gcc_lib target-supports.exp
51 load_gcc_lib target-supports-dg.exp
53 load_lib dg-options.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 } {
63 verbose "++ $var is $val" $n
66 # Called by v3-init below. "Static" to this file.
67 proc v3-copy-files {srcfiles} {
69 if { [catch { set symlink [file readlink $f] } x] } then {
70 remote_download target $f
72 if { [regexp "^/" "$symlink"] } then {
73 remote_download target $symlink
75 set dirname [file dirname $f]
76 remote_download target $dirname/$symlink
82 # Called once, during runtest.exp setup.
83 proc libstdc++_init { testfile } {
85 global v3-sharedlib v3-libgomp
86 global srcdir blddir objdir tool_root_dir
87 global cc cxx cxxflags cxxpchflags cxxldflags
89 global gluefile wrap_flags
90 global ld_library_path
95 # We set LC_ALL and LANG to C so that we get the same error
96 # messages as expected.
100 # Many hosts now default to a non-ASCII C locale, however, so
101 # they can set a charset encoding here if they need.
102 if { [ishost "*-*-cygwin*"] } {
103 setenv LC_ALL C.ASCII
107 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
108 set flags_file "${blddir}/scripts/testsuite_flags"
111 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
112 # Use this variable if the behavior
113 # 1) only applies to libstdc++ testing
114 # 2) might need to be negated
115 # In particular, some tests have to be run without precompiled
116 # headers, or without assertions.
117 global DEFAULT_CXXFLAGS
118 if ![info exists DEFAULT_CXXFLAGS] then {
119 set DEFAULT_CXXFLAGS ""
120 # Host specific goo here.
121 if { [string match "powerpc-*-darwin*" $target_triplet] } {
122 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
125 v3track DEFAULT_CXXFLAGS 2
127 # By default, we assume we want to run program images.
128 global dg-do-what-default
129 set dg-do-what-default run
131 # Copy any required data files.
132 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
133 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
135 set ld_library_path_tmp ""
137 # Locate libgcc.a so we don't need to account for different values of
138 # SHLIB_EXT on different platforms
139 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
141 set gccdir [file dirname $gccdir]
142 append ld_library_path_tmp ":${gccdir}"
146 # Locate libgomp. This is only required for parallel mode.
148 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.so]
149 if {$libgompdir != ""} {
151 set libgompdir [file dirname $libgompdir]
152 append ld_library_path_tmp ":${libgompdir}"
153 verbose -log "libgomp support detected"
157 # Locate libstdc++ shared library. (ie libstdc++.so.)
159 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so]
160 if {$sharedlibdir != ""} {
161 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
163 verbose -log "shared library support detected"
166 v3track v3-sharedlib 3
168 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
170 set compiler ${gccdir}/g++
171 set ld_library_path ${ld_library_path_tmp}
172 append ld_library_path ":${blddir}/src/.libs"
174 if { [is_remote host] == 0 && [which $compiler] != 0 } {
175 foreach i "[exec $compiler --print-multi-lib]" {
177 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
178 set mldir [string trimright $mldir "\;@"]
179 if { "$mldir" == "." } {
182 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
183 append ld_library_path ":${gccdir}/${mldir}"
188 set_ld_library_path_env_vars
189 if [info exists env(LD_LIBRARY_PATH)] {
190 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
193 set compiler [transform "g++"]
196 # Set the default timeout for v3 tests.
200 set cxx [transform "g++"]
201 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
204 set cc [transform "gcc"]
205 # Locate testsuite_hooks.h and other testsuite headers.
206 set includes "-I${srcdir}/util"
207 # Adapt the defaults for special circumstances.
208 if [is_remote host] {
209 # A remote host does not, in general, have access to the
210 # $srcdir so we copy the testsuite headers into the current
211 # directory, and then add that to the search path.
212 foreach src [glob "${srcdir}/util/*.h" \
213 "${srcdir}/util/*.cc" \
214 "${srcdir}/util/*.tcc" \
215 "${srcdir}/util/*.hpp" \
216 "${srcdir}/util/*/*.h" \
217 "${srcdir}/util/*/*.cc" \
218 "${srcdir}/util/*/*.tcc" \
219 "${srcdir}/util/*/*.hpp" \
220 "${srcdir}/util/*/*/*.h" \
221 "${srcdir}/util/*/*/*.cc" \
222 "${srcdir}/util/*/*/*.tcc" \
223 "${srcdir}/util/*/*/*.hpp" \
224 "${srcdir}/util/*/*/*/*.h" \
225 "${srcdir}/util/*/*/*/*.cc" \
226 "${srcdir}/util/*/*/*/*.tcc" \
227 "${srcdir}/util/*/*/*/*.hpp" \
228 "${srcdir}/util/*/*/*/*/*.h" \
229 "${srcdir}/util/*/*/*/*/*.cc" \
230 "${srcdir}/util/*/*/*/*/*.tcc" \
231 "${srcdir}/util/*/*/*/*/*.hpp" ] {
232 # Remove everything up to "util/..."
233 set dst [string range $src [string length "${srcdir}/"] end]
234 # Create the directory containing the file.
235 set dir [file dirname $dst]
236 remote_exec host "mkdir" [list "-p" "$dir"]
238 set result [remote_download host $src $dst]
239 if { $result == "" } {
240 verbose -log "Unable to download ${srcdir}/${src} to host."
244 set includes "-Iutil"
245 } elseif { [file exists $flags_file] } {
246 # If we find a testsuite_flags file, we're testing in the build dir.
247 set cxx [exec sh $flags_file --build-cxx]
248 set cxxflags [exec sh $flags_file --cxxflags]
249 set cxxpchflags [exec sh $flags_file --cxxpchflags]
250 set cxxldflags [exec sh $flags_file --cxxldflags]
251 set cc [exec sh $flags_file --build-cc]
252 set includes [exec sh $flags_file --build-includes]
255 append cxxflags [getenv CXXFLAGS]
258 # Always use MO files built by this test harness.
259 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
260 set ccflags "$cxxflags -DLOCALEDIR=\".\""
262 # If a PCH file is available, use it. We must delay performing
263 # this check until $cxx and such have been initialized because we
264 # perform a test compilation. (Ideally, gcc --print-file-name would
265 # list PCH files, but it does not.)
266 if { $cxxpchflags != "" } {
267 set src "config[pid].cc"
268 set f [open $src "w"]
269 puts $f "int main () {}"
272 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
273 # useful as then the requested variant of the pre-build PCH
274 # files could be tested to see if it works.
275 set lines [v3_target_compile $src "config[pid].o" object \
276 "additional_flags=-include additional_flags=bits/stdc++.h"]
277 if { $lines != "" } {
278 verbose -log "Requested PCH file: $cxxpchflags"
279 verbose -log "is not working, and will not be used."
284 v3track cxxpchflags 2
287 if ![info exists PCH_CXXFLAGS] then {
288 set PCH_CXXFLAGS $cxxpchflags
289 v3track PCH_CXXFLAGS 2
292 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
295 # Callback for cleanup routines.
296 proc libstdc++_exit { } {
299 if [info exists gluefile] {
300 file_on_build delete $gluefile;
305 # Callback from system dg-test.
306 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
307 # Set up the compiler flags, based on what we're going to do.
310 set compile_type "preprocess"
311 set output_file "[file rootname [file tail $prog]].i"
314 set compile_type "assembly"
315 set output_file "[file rootname [file tail $prog]].s"
318 set compile_type "object"
319 set output_file "[file rootname [file tail $prog]].o"
322 set compile_type "executable"
323 set output_file "./[file rootname [file tail $prog]].exe"
326 set compile_type "executable"
327 # FIXME: "./" is to cope with "." not being in $PATH.
328 # Should this be handled elsewhere?
330 set output_file "./[file rootname [file tail $prog]].exe"
331 # This is the only place where we care if an executable was
332 # created or not. If it was, dg.exp will try to run it.
333 catch { remote_file build delete $output_file }
336 perror "$do_what: not a valid dg-do keyword"
341 # Short-circut a bunch of complicated goo here for the special
342 # case of compiling a test file as a "C" file, not as C++. Why? So
343 # -nostdc++ doesn't trip us up. So all the extra object files
344 # don't trip us up. So automatically linking in libstdc++ doesn't
345 # happen. So CXXFLAGS don't error.
346 set select_compile "v3_target_compile"
348 if { $extra_tool_flags != "" } {
349 verbose -log "extra_tool_flags are:"
350 verbose -log $extra_tool_flags
351 if { [string first "-x c" $extra_tool_flags ] != -1 } {
352 verbose -log "compiling and executing as C, not C++"
353 set edit_tool_flags $extra_tool_flags
354 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
355 lappend options "additional_flags=$edit_tool_flags"
356 set select_compile "v3_target_compile_as_c"
358 lappend options "additional_flags=$extra_tool_flags"
362 # There is a libstdc++_compile made for us by default (via the tool-
363 # and-target file), but the defaults are lacking in goodness.
364 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
365 set comp_output [ prune_g++_output $comp_output ];
367 return [list $comp_output $output_file]
370 # Override the DejaGnu dg-test in order to clear flags after a test, as
371 # is done for compiler tests in gcc-dg.exp.
373 if { [info procs saved-dg-test] == [list] } {
374 rename dg-test saved-dg-test
376 proc dg-test { args } {
379 if { [ catch { eval saved-dg-test $args } errmsg ] } {
380 set saved_info $errorInfo
382 error $errmsg $saved_info
388 # True if the library supports wchar_t.
391 # True if the library supports threads.
394 # True if the library supports symbol versioning.
397 # Called from libstdc++-dg-test above. Calls back into system's
398 # target_compile to actually do the work.
399 proc v3_target_compile { source dest type options } {
407 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
408 lappend options "libs=${gluefile}"
409 lappend options "ldflags=${wrap_flags}"
413 set cxxlibglossflags [libgloss_link_flags]
414 set cxx_final [concat $cxx_final $cxxlibglossflags]
415 set cxx_final [concat $cxx_final $cxxflags]
416 set cxx_final [concat $cxx_final $includes]
418 # Flag setting based on type argument.
419 if { $type == "executable" } {
420 # Link the support objects into executables.
421 lappend options "additional_flags=./libtestc++.a $cxxldflags"
423 if { $type == "sharedlib" } {
424 # Don't link in anything.
425 set type "executable"
429 lappend options "compiler=$cxx_final"
430 lappend options "timeout=[timeout_value]"
432 return [target_compile $source $dest $type $options]
436 # Called from libstdc++-dg-test above, but only for "C" compilation.
437 # Calls back into system's target_compile to actually do the work.
438 proc v3_target_compile_as_c { source dest type options } {
447 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
448 lappend options "libs=${gluefile}"
449 lappend options "ldflags=${wrap_flags}"
452 set tname [target_info name]
454 set cxxlibglossflags [libgloss_link_flags]
455 set cc_final [concat $cc_final $cxxlibglossflags]
456 set cc_final [concat $cc_final $cxxflags]
457 set cc_final [concat $cc_final $includes]
458 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
460 # This is needed for "C" tests, as this type of test may need the
461 # C++ includes. And if we're not testing in the build directory,
462 # the includes variable is not likely to include the necessary
464 if { ![file exists $flags_file] } {
465 # ??? We need a --print-include-dirs option to GCC, so that
466 # we can avoid these hacks. The heuristics here will not
467 # work with non-standard --with-includedir= options.
468 set version [remote_exec host ${cc} -dumpversion]
469 # Remove the trailing newline from the output.
470 set version [string trimright [lindex $version 1]]
471 set machine [remote_exec host ${cc} -dumpmachine]
472 set machine [string trimright [lindex $machine 1]]
473 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
474 set comp_base_dir [lindex $comp_base_dir 1]
475 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
476 # For a cross compiler, the header files will be located in a
477 # machine-specific subdirectory.
478 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
479 set crosstarget "${crossbase}/${machine}"
480 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
481 # For a native compiler, the header files will be located at
483 set includesbase "${comp_base_dir}/include/c++/${version}"
484 set includestarget "${includesbase}/${machine}"
485 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
487 set libdir "-L${comp_base_dir}/lib"
489 set libdir "-L${blddir}/libsupc++/.libs"
490 set libdir [concat $libdir "-L${blddir}/src/.libs"]
493 set cc_final [concat $cc_final "$libdir"]
495 lappend options "compiler=$cc_final"
496 lappend options "timeout=[timeout_value]"
498 return [target_compile $source $dest $type $options]
501 # Build the support objects linked in with the libstdc++ tests. In
502 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
503 proc v3-build_support { } {
511 # Figure out whether or not the library supports certain features.
517 set config_src "config.cc"
518 set config_out "config.ii"
519 set f [open $config_src "w"]
520 puts $f "#include <bits/c++config.h>"
521 puts $f "#include <bits/gthr.h>"
523 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
524 set file [open $config_out r]
525 set preprocessed [read $file]
527 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
528 verbose -log "wchar_t support detected"
531 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
532 verbose -log "symbol versioning support detected"
535 if { [string first "__GTHREADS" $preprocessed] != -1 } {
536 verbose -log "thread support detected"
540 # Try to build the MO files that are used by some of the locale
541 # tests. If we can't build them, that's OK; it just means that
542 # those tests will fail.
543 foreach lang [list "fr" "de"] {
545 file mkdir "$lang/LC_MESSAGES"
546 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
547 if [is_remote host] {
548 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
549 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
554 # Build the support objects.
555 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
556 testsuite_character.cc testsuite_hooks.cc \
557 io/verified_cmd_line_input.cc \
558 io/prog_bar.cc performance/time/elapsed_timer.cc ]
559 foreach f $source_files {
560 set obj [file rootname $f].o
561 set object_file [file tail $obj]
562 # Compile with "-w" so that warnings issued by the compiler
563 # do not prevent compilation.
564 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
565 [list "incdir=$srcdir" "additional_flags=-w"]]
567 error "could not compile $f"
569 append libtest_objs "$object_file "
572 # Collect into libtestc++.a
573 if [info exists env(AR)] {
576 set ar [transform "ar"]
578 set arargs "-rc ./libtestc++.a ${libtest_objs}"
579 verbose -log "$ar $arargs"
580 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
581 verbose "link result is $result"
582 if { $result == 0 } {
583 if [info exists env(RANLIB)] {
584 set ranlib $env(RANLIB)
586 set ranlib [transform "ranlib"]
588 set ranlibargs "./libtestc++.a"
589 verbose -log "$ranlib $ranlibargs"
590 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
591 if { $result != 0 } {
592 error "could not link libtestc++.a"
596 # Build any shared objects needed for regression testing.
597 if { ${v3-sharedlib} == 1 } {
598 set source_files [list testsuite_shared.cc]
599 foreach f $source_files {
600 set object_file [file rootname $f].so
601 # Compile with "-w" so that warnings issued by the compiler
602 # do not prevent compilation.
603 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
604 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
606 error "could not compile $f"
612 proc check_v3_target_fileio { } {
613 global et_fileio_saved
614 global et_fileio_target_name
617 if { ![info exists et_fileio_target_name] } {
618 set et_fileio_target_name ""
621 # If the target has changed since we set the cached value, clear it.
622 set current_target [current_target_name]
623 if { $current_target != $et_fileio_target_name } {
624 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
625 set et_fileio_target_name $current_target
626 if [info exists et_fileio_saved] {
627 verbose "check_v3_target_fileio: removing cached result" 2
628 unset et_fileio_saved
632 if [info exists et_fileio_saved] {
633 verbose "check_v3_target_fileio: using cached result" 2
635 set et_fileio_saved 0
637 # Set up, compile, and execute a C++ test program that tries to use
639 set src fileio[pid].cc
640 set exe fileio[pid].x
642 set f [open $src "w"]
643 puts $f "#include <sys/types.h>"
644 puts $f "#include <sys/stat.h>"
645 puts $f "#include <fcntl.h>"
646 puts $f "#include <unistd.h>"
647 puts $f "#include <errno.h>"
648 puts $f "using namespace std;"
649 puts $f "int main ()"
651 puts $f " int fd = open (\".\", O_RDONLY);"
652 puts $f " int ret = 0;"
653 puts $f " if (fd == -1)"
655 puts $f " int err = errno;"
656 puts $f " if (err == EIO || err == ENOSYS)"
661 puts $f " if (lseek (fd, 0, SEEK_CUR) == -1)"
663 puts $f " close (fd);"
665 puts $f " return ret;"
669 set lines [v3_target_compile $src $exe executable ""]
672 if [string match "" $lines] {
673 # No error message, compilation succeeded.
674 set result [${tool}_load "./$exe" "" ""]
675 set status [lindex $result 0]
676 remote_file build delete $exe
678 verbose "check_v3_target_fileio: status is <$status>" 2
680 if { $status == "pass" } {
681 set et_fileio_saved 1
684 verbose "check_v3_target_fileio: compilation failed" 2
687 return $et_fileio_saved
690 # Eventually we want C90/C99 determining and switching from this.
691 proc check_v3_target_c_std { } {
692 global et_c_std_saved
693 global et_c_std_target_name
696 if { ![info exists et_c_std_target_name] } {
697 set et_c_std_target_name ""
700 # If the target has changed since we set the cached value, clear it.
701 set current_target [current_target_name]
702 if { $current_target != $et_c_std_target_name } {
703 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
704 set et_c_std_target_name $current_target
705 if [info exists et_c_std_saved] {
706 verbose "check_v3_target_c_std: removing cached result" 2
711 if [info exists et_c_std_saved] {
712 verbose "check_v3_target_c_std: using cached result" 2
716 # Set up, compile, and execute a C++ test program that tries to use
718 # For math bits, could use check_effective_target_c99_math.
719 set src fileio[pid].cc
720 set exe fileio[pid].x
722 set f [open $src "w"]
723 puts $f "#include <tr1/cmath>"
724 puts $f "#include <cstdlib>"
725 puts $f "int main ()"
727 puts $f " float f = 45.55;"
728 puts $f " int i = std::tr1::isnan(f);"
730 puts $f " using std::wctomb;"
735 set lines [v3_target_compile $src $exe executable ""]
738 if [string match "" $lines] {
739 # No error message, compilation succeeded.
740 set result [${tool}_load "./$exe" "" ""]
741 set status [lindex $result 0]
742 remote_file build delete $exe
744 verbose "check_v3_target_c_std: status is <$status>" 2
746 if { $status == "pass" } {
750 verbose "check_v3_target_c_std: compilation failed" 2
753 return $et_c_std_saved
756 proc check_v3_target_sharedlib { } {
758 return ${v3-sharedlib}
761 proc check_v3_target_time { } {
763 global et_time_target_name
766 if { ![info exists et_time_target_name] } {
767 set et_time_target_name ""
770 # If the target has changed since we set the cached value, clear it.
771 set current_target [current_target_name]
772 if { $current_target != $et_time_target_name } {
773 verbose "check_v3_target_time: `$et_time_target_name'" 2
774 set et_time_target_name $current_target
775 if [info exists et_time_saved] {
776 verbose "check_v3_target_time: removing cached result" 2
781 if [info exists et_time_saved] {
782 verbose "check_v3_target_time: using cached result" 2
786 # Set up and compile a C++ test program that tries to use
791 set f [open $src "w"]
792 puts $f "#include <time.h>"
793 puts $f "using namespace std;"
794 puts $f "int main ()"
800 set lines [v3_target_compile $src $exe executable ""]
803 if [string match "" $lines] {
804 # No error message, compilation succeeded.
805 verbose "check_v3_target_time: compilation succeeded" 2
806 remote_file build delete $exe
809 verbose "check_v3_target_time: compilation failed" 2
812 return $et_time_saved
815 proc check_v3_target_namedlocale { } {
816 global et_namedlocale_saved
817 global et_namedlocale_target_name
820 if { ![info exists et_namedlocale_target_name] } {
821 set et_namedlocale_target_name ""
824 # If the target has changed since we set the cached value, clear it.
825 set current_target [current_target_name]
826 if { $current_target != $et_namedlocale_target_name } {
827 verbose "check_v3_target_namedlocale: `$et_namedlocale_target_name'" 2
828 set et_namedlocale_target_name $current_target
829 if [info exists et_namedlocale_saved] {
830 verbose "check_v3_target_namedlocale: removing cached result" 2
831 unset et_namedlocale_saved
835 if [info exists et_namedlocale_saved] {
836 verbose "check_v3_target_namedlocale: using cached result" 2
838 set et_namedlocale_saved 0
840 # Set up, compile, and execute a C++ test program that tries to use
841 # all the required named locales.
842 set src nlocale[pid].cc
843 set exe nlocale[pid].x
845 set f [open $src "w"]
846 puts $f "#include <locale>"
847 puts $f "using namespace std;"
848 puts $f "int main ()"
852 puts $f " locale(\"\");"
853 puts $f " locale(\"de_DE\");"
854 puts $f " locale(\"de_DE.ISO-8859-15@euro\");"
855 puts $f " locale(\"de_DE@euro\");"
856 puts $f " locale(\"en_HK\");"
857 puts $f " locale(\"en_PH\");"
858 puts $f " locale(\"en_US\");"
859 puts $f " locale(\"en_US.ISO-8859-1\");"
860 puts $f " locale(\"en_US.ISO-8859-15\");"
861 puts $f " locale(\"en_US.UTF-8\");"
862 puts $f " locale(\"es_ES\");"
863 puts $f " locale(\"es_MX\");"
864 puts $f " locale(\"fr_FR\");"
865 puts $f " locale(\"fr_FR@euro\");"
866 puts $f " locale(\"is_IS\");"
867 puts $f " locale(\"is_IS.UTF-8\");"
868 puts $f " locale(\"it_IT\");"
869 puts $f " locale(\"ja_JP.eucjp\");"
870 puts $f " locale(\"se_NO.UTF-8\");"
871 puts $f " locale(\"ta_IN\");"
872 puts $f " locale(\"zh_TW\");"
875 puts $f " catch(...)"
882 set lines [v3_target_compile $src $exe executable ""]
885 if [string match "" $lines] {
886 # No error message, compilation succeeded.
887 set result [${tool}_load "./$exe" "" ""]
888 set status [lindex $result 0]
889 remote_file build delete $exe
891 verbose "check_v3_target_namedlocale: status is <$status>" 2
893 if { $status == "pass" } {
894 set et_namedlocale_saved 1
897 verbose "check_v3_target_namedlocale: compilation failed" 2
900 return $et_namedlocale_saved
903 proc check_v3_target_debug_mode { } {
908 if { ![info exists et_debug_mode_target_name] } {
909 set et_debug_mode_target_name ""
912 # If the target has changed since we set the cached value, clear it.
913 set current_target [current_target_name]
914 if { $current_target != $et_debug_mode_target_name } {
915 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
916 set et_debug_mode_target_name $current_target
917 if [info exists et_debug_mode] {
918 verbose "check_v3_target_debug_mode: removing cached result" 2
923 if [info exists et_debug_mode] {
924 verbose "check_v3_target_debug_mode: using cached result" 2
928 # Set up and compile a C++ test program that depends
929 # on debug mode working.
930 set src debug_mode[pid].cc
931 set exe debug_mode[pid].exe
933 set f [open $src "w"]
934 puts $f "#include <string>"
935 puts $f "using namespace std;"
937 puts $f "{ return 0; }"
940 set cxxflags_saved $cxxflags
941 set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG"
942 set lines [v3_target_compile $src $exe executable ""]
943 set cxxflags $cxxflags_saved
946 if [string match "" $lines] {
947 # No error message, compilation succeeded.
951 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
952 return $et_debug_mode
955 proc check_v3_target_parallel_mode { } {
958 global et_parallel_mode
962 if { ![info exists et_parallel_mode_target_name] } {
963 set et_parallel_mode_target_name ""
966 # If the target has changed since we set the cached value, clear it.
967 set current_target [current_target_name]
968 if { $current_target != $et_parallel_mode_target_name } {
969 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
970 set et_parallel_mode_target_name $current_target
971 if [info exists et_parallel_mode] {
972 verbose "check_v3_target_parallel_mode: removing cached result" 2
973 unset et_parallel_mode
977 if [info exists et_parallel_mode] {
978 verbose "check_v3_target_parallel_mode: using cached result" 2
980 set et_parallel_mode 0
982 # If 'make check-parallel' is running the test succeeds.
983 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
984 set et_parallel_mode 1
987 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
988 return $et_parallel_mode
991 proc check_v3_target_cstdint { } {
993 global DEFAULT_CXXFLAGS
998 if { ![info exists et_cstdint_target_name] } {
999 set et_cstdint_target_name ""
1002 # If the target has changed since we set the cached value, clear it.
1003 set current_target [current_target_name]
1004 if { $current_target != $et_cstdint_target_name } {
1005 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1006 set et_cstdint_target_name $current_target
1007 if [info exists et_cstdint] {
1008 verbose "check_v3_target_cstdint: removing cached result" 2
1013 if [info exists et_cstdint] {
1014 verbose "check_v3_target_cstdint: using cached result" 2
1018 # Set up and compile a C++0x test program that depends
1019 # on the C99 stdint facilities to be available.
1020 set src cstdint[pid].cc
1021 set exe cstdint[pid].exe
1023 set f [open $src "w"]
1024 puts $f "#include <tr1/cstdint>"
1025 puts $f "int main()"
1026 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1027 puts $f "{ return 0; }"
1031 set cxxflags_saved $cxxflags
1032 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1034 set lines [v3_target_compile $src $exe executable ""]
1035 set cxxflags $cxxflags_saved
1038 if [string match "" $lines] {
1039 # No error message, compilation succeeded.
1042 verbose "check_v3_target_cstdint: compilation failed" 2
1045 verbose "check_v3_target_cstdint: $et_cstdint" 2
1049 proc check_v3_target_atomic_builtins { } {
1051 global DEFAULT_CXXFLAGS
1056 if { ![info exists et_atomic_builtins_target_name] } {
1057 set et_atomic_builtins_target_name ""
1060 # If the target has changed since we set the cached value, clear it.
1061 set current_target [current_target_name]
1062 if { $current_target != $et_atomic_builtins_target_name } {
1063 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1064 set et_atomic_builtins_target_name $current_target
1065 if [info exists et_atomic_builtins] {
1066 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1067 unset et_atomic_builtins
1071 if [info exists et_atomic_builtins] {
1072 verbose "check_v3_target_atomic_builtins: using cached result" 2
1074 set et_atomic_builtins 0
1076 # Set up and compile a C++0x test program that depends
1077 # on the atomic builtin facilities to be available.
1078 set src atomic_builtins[pid].cc
1079 set exe atomic_builtins[pid].exe
1081 set f [open $src "w"]
1082 puts $f "#include <bits/c++config.h>"
1083 puts $f "int main()"
1084 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1085 puts $f "{ return 0; }"
1089 set cxxflags_saved $cxxflags
1090 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1092 set lines [v3_target_compile $src $exe executable ""]
1093 set cxxflags $cxxflags_saved
1096 if [string match "" $lines] {
1097 # No error message, compilation succeeded.
1098 set et_atomic_builtins 1
1100 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1103 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1104 return $et_atomic_builtins
1107 proc check_v3_target_gthreads { } {
1109 global DEFAULT_CXXFLAGS
1114 if { ![info exists et_gthreads_target_name] } {
1115 set et_gthreads_target_name ""
1118 # If the target has changed since we set the cached value, clear it.
1119 set current_target [current_target_name]
1120 if { $current_target != $et_gthreads_target_name } {
1121 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1122 set et_gthreads_target_name $current_target
1123 if [info exists et_gthreads] {
1124 verbose "check_v3_target_gthreads: removing cached result" 2
1129 if [info exists et_gthreads] {
1130 verbose "check_v3_target_gthreads: using cached result" 2
1134 # Set up and compile a C++0x test program that depends
1135 # on the gthreads facilities to be available.
1136 set src gthreads[pid].cc
1137 set exe gthreads[pid].exe
1139 set f [open $src "w"]
1140 puts $f "#include <bits/c++config.h>"
1141 puts $f "int main()"
1142 puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
1143 puts $f "{ return 0; }"
1147 set cxxflags_saved $cxxflags
1148 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1150 set lines [v3_target_compile $src $exe executable ""]
1151 set cxxflags $cxxflags_saved
1154 if [string match "" $lines] {
1155 # No error message, compilation succeeded.
1158 verbose "check_v3_target_gthreads: compilation failed" 2
1161 verbose "check_v3_target_gthreads: $et_gthreads" 2
1165 proc check_v3_target_nanosleep { } {
1167 global DEFAULT_CXXFLAGS
1172 if { ![info exists et_nanosleep_target_name] } {
1173 set et_nanosleep_target_name ""
1176 # If the target has changed since we set the cached value, clear it.
1177 set current_target [current_target_name]
1178 if { $current_target != $et_nanosleep_target_name } {
1179 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1180 set et_nanosleep_target_name $current_target
1181 if [info exists et_nanosleep] {
1182 verbose "check_v3_target_nanosleep: removing cached result" 2
1187 if [info exists et_nanosleep] {
1188 verbose "check_v3_target_nanosleep: using cached result" 2
1192 # Set up and compile a C++0x test program that depends
1193 # on the nanosleep facilities to be available.
1194 set src nanosleep[pid].cc
1195 set exe nanosleep[pid].exe
1197 set f [open $src "w"]
1198 puts $f "#include <bits/c++config.h>"
1199 puts $f "int main()"
1200 puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
1201 puts $f "{ return 0; }"
1205 set cxxflags_saved $cxxflags
1206 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1208 set lines [v3_target_compile $src $exe executable ""]
1209 set cxxflags $cxxflags_saved
1212 if [string match "" $lines] {
1213 # No error message, compilation succeeded.
1216 verbose "check_v3_target_nanosleep: compilation failed" 2
1219 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1220 return $et_nanosleep
1223 proc check_v3_target_sched_yield { } {
1225 global DEFAULT_CXXFLAGS
1226 global et_sched_yield
1230 if { ![info exists et_sched_yield_target_name] } {
1231 set et_sched_yield_target_name ""
1234 # If the target has changed since we set the cached value, clear it.
1235 set current_target [current_target_name]
1236 if { $current_target != $et_sched_yield_target_name } {
1237 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1238 set et_sched_yield_target_name $current_target
1239 if [info exists et_sched_yield] {
1240 verbose "check_v3_target_sched_yield: removing cached result" 2
1241 unset et_sched_yield
1245 if [info exists et_sched_yield] {
1246 verbose "check_v3_target_sched_yield: using cached result" 2
1248 set et_sched_yield 0
1250 # Set up and compile a C++0x test program that depends
1251 # on the sched_yield facility to be available.
1252 set src sched_yield[pid].cc
1253 set exe sched_yield[pid].exe
1255 set f [open $src "w"]
1256 puts $f "#include <bits/c++config.h>"
1257 puts $f "int main()"
1258 puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
1259 puts $f "{ return 0; }"
1263 set cxxflags_saved $cxxflags
1264 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1266 set lines [v3_target_compile $src $exe executable ""]
1267 set cxxflags $cxxflags_saved
1270 if [string match "" $lines] {
1271 # No error message, compilation succeeded.
1272 set et_sched_yield 1
1274 verbose "check_v3_target_sched_yield: compilation failed" 2
1277 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1278 return $et_sched_yield
1281 proc check_v3_target_string_conversions { } {
1283 global DEFAULT_CXXFLAGS
1284 global et_string_conversions
1288 if { ![info exists et_string_conversions_target_name] } {
1289 set et_string_conversions_target_name ""
1292 # If the target has changed since we set the cached value, clear it.
1293 set current_target [current_target_name]
1294 if { $current_target != $et_string_conversions_target_name } {
1295 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1296 set et_string_conversions_target_name $current_target
1297 if [info exists et_string_conversions] {
1298 verbose "check_v3_target_string_conversions: removing cached result" 2
1299 unset et_string_conversions
1303 if [info exists et_string_conversions] {
1304 verbose "check_v3_target_string_conversions: using cached result" 2
1306 set et_string_conversions 0
1308 # Set up and compile a C++0x test program that depends
1309 # on the string_conversions facilities to be available.
1310 set src string_conversions[pid].cc
1311 set exe string_conversions[pid].exe
1313 set f [open $src "w"]
1314 puts $f "#include <bits/c++config.h>"
1315 puts $f "int main()"
1316 puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1317 puts $f "{ return 0; }"
1321 set cxxflags_saved $cxxflags
1322 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1324 set lines [v3_target_compile $src $exe executable ""]
1325 set cxxflags $cxxflags_saved
1328 if [string match "" $lines] {
1329 # No error message, compilation succeeded.
1330 set et_string_conversions 1
1332 verbose "check_v3_target_string_conversions: compilation failed" 2
1335 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1336 return $et_string_conversions
1339 proc check_v3_target_swprintf { } {
1341 global DEFAULT_CXXFLAGS
1346 if { ![info exists et_swprintf_target_name] } {
1347 set et_swprintf_target_name ""
1350 # If the target has changed since we set the cached value, clear it.
1351 set current_target [current_target_name]
1352 if { $current_target != $et_swprintf_target_name } {
1353 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1354 set et_swprintf_target_name $current_target
1355 if [info exists et_swprintf] {
1356 verbose "check_v3_target_swprintf: removing cached result" 2
1361 if [info exists et_swprintf] {
1362 verbose "check_v3_target_swprintf: using cached result" 2
1366 # Set up and compile a C++0x test program that depends
1367 # on a standard swprintf function to be available.
1368 set src swprintf[pid].cc
1369 set exe swprintf[pid].exe
1371 set f [open $src "w"]
1372 puts $f "#include <bits/c++config.h>"
1373 puts $f "int main()"
1374 puts $f "#if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1375 puts $f "{ return 0; }"
1379 set cxxflags_saved $cxxflags
1380 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1382 set lines [v3_target_compile $src $exe executable ""]
1383 set cxxflags $cxxflags_saved
1386 if [string match "" $lines] {
1387 # No error message, compilation succeeded.
1390 verbose "check_v3_target_swprintf: compilation failed" 2
1393 verbose "check_v3_target_swprintf: $et_swprintf" 2
1397 proc check_v3_target_binary_io { } {
1399 global DEFAULT_CXXFLAGS
1404 if { ![info exists et_binary_io_target_name] } {
1405 set et_binary_io_target_name ""
1408 # If the target has changed since we set the cached value, clear it.
1409 set current_target [current_target_name]
1410 if { $current_target != $et_binary_io_target_name } {
1411 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1412 set et_binary_io_target_name $current_target
1413 if [info exists et_binary_io] {
1414 verbose "check_v3_target_binary_io: removing cached result" 2
1419 if [info exists et_binary_io] {
1420 verbose "check_v3_target_binary_io: using cached result" 2
1424 # Set up and compile a C++0x test program that depends
1425 # on text and binary I/O being the same.
1426 set src binary_io[pid].cc
1427 set exe binary_io[pid].exe
1429 set f [open $src "w"]
1430 puts $f "#include <bits/c++config.h>"
1431 puts $f "int main()"
1432 puts $f "#if !defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1433 puts $f "{ return 0; }"
1437 set cxxflags_saved $cxxflags
1438 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1440 set lines [v3_target_compile $src $exe executable ""]
1441 set cxxflags $cxxflags_saved
1444 if [string match "" $lines] {
1445 # No error message, compilation succeeded.
1448 verbose "check_v3_target_binary_io: compilation failed" 2
1451 verbose "check_v3_target_binary_io: $et_binary_io" 2
1452 return $et_binary_io