1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 scanasm.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
95 global DEFAULT_CXXFLAGS
96 global STATIC_LIBCXXFLAGS
98 # We set LC_ALL and LANG to C so that we get the same error
99 # messages as expected.
103 # Many hosts now default to a non-ASCII C locale, however, so
104 # they can set a charset encoding here if they need.
105 if { [ishost "*-*-cygwin*"] } {
106 setenv LC_ALL C.ASCII
110 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
111 set flags_file "${blddir}/scripts/testsuite_flags"
112 set shlib_ext [get_shlib_extension]
115 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
116 # Use this variable if the behavior
117 # 1) only applies to libstdc++ testing
118 # 2) might need to be negated
119 # In particular, some tests have to be run without precompiled
120 # headers, or without assertions.
122 if ![info exists DEFAULT_CXXFLAGS] then {
123 set DEFAULT_CXXFLAGS ""
124 # Host specific goo here.
125 if { [string match "powerpc-*-darwin*" $target_triplet] } {
126 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
129 v3track DEFAULT_CXXFLAGS 2
131 # By default, we assume we want to run program images.
132 global dg-do-what-default
133 set dg-do-what-default run
135 # Copy any required data files.
136 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
137 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
139 set ld_library_path_tmp ""
141 # Locate libgcc.a so we don't need to account for different values of
142 # SHLIB_EXT on different platforms
143 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
145 set gccdir [file dirname $gccdir]
146 append ld_library_path_tmp ":${gccdir}"
150 # Locate libgomp. This is only required for parallel mode.
152 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
153 if {$libgompdir != ""} {
155 set libgompdir [file dirname $libgompdir]
156 append ld_library_path_tmp ":${libgompdir}"
157 verbose -log "libgomp support detected"
161 # Locate libstdc++ shared library. (ie libstdc++.so.)
163 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
164 if {$sharedlibdir != ""} {
165 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
167 verbose -log "shared library support detected"
170 v3track v3-sharedlib 3
172 set STATIC_LIBCXXFLAGS ""
173 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
174 if {$staticlibdir != ""} {
175 set staticlibdir [file dirname $staticlibdir]
176 # Some targets use libstdc++.a%s in their specs, so they need a
177 # -B option for uninstalled testing.
178 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
181 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
183 set compiler ${gccdir}/g++
184 set ld_library_path ${ld_library_path_tmp}
185 append ld_library_path ":${blddir}/src/.libs"
187 if { [is_remote host] == 0 && [which $compiler] != 0 } {
188 foreach i "[exec $compiler --print-multi-lib]" {
190 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
191 set mldir [string trimright $mldir "\;@"]
192 if { "$mldir" == "." } {
195 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
196 append ld_library_path ":${gccdir}/${mldir}"
201 set_ld_library_path_env_vars
202 if [info exists env(LD_LIBRARY_PATH)] {
203 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
206 set compiler [transform "g++"]
209 # Set the default timeout for v3 tests.
213 set cxx [transform "g++"]
214 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
217 set cc [transform "gcc"]
218 # Locate testsuite_hooks.h and other testsuite headers.
219 set includes "-I${srcdir}/util"
220 # Adapt the defaults for special circumstances.
221 if [is_remote host] {
222 # A remote host does not, in general, have access to the
223 # $srcdir so we copy the testsuite headers into the current
224 # directory, and then add that to the search path.
225 foreach src [glob "${srcdir}/util/*.h" \
226 "${srcdir}/util/*.cc" \
227 "${srcdir}/util/*.tcc" \
228 "${srcdir}/util/*.hpp" \
229 "${srcdir}/util/*/*.h" \
230 "${srcdir}/util/*/*.cc" \
231 "${srcdir}/util/*/*.tcc" \
232 "${srcdir}/util/*/*.hpp" \
233 "${srcdir}/util/*/*/*.h" \
234 "${srcdir}/util/*/*/*.cc" \
235 "${srcdir}/util/*/*/*.tcc" \
236 "${srcdir}/util/*/*/*.hpp" \
237 "${srcdir}/util/*/*/*/*.h" \
238 "${srcdir}/util/*/*/*/*.cc" \
239 "${srcdir}/util/*/*/*/*.tcc" \
240 "${srcdir}/util/*/*/*/*.hpp" \
241 "${srcdir}/util/*/*/*/*/*.h" \
242 "${srcdir}/util/*/*/*/*/*.cc" \
243 "${srcdir}/util/*/*/*/*/*.tcc" \
244 "${srcdir}/util/*/*/*/*/*.hpp" ] {
245 # Remove everything up to "util/..."
246 set dst [string range $src [string length "${srcdir}/"] end]
247 # Create the directory containing the file.
248 set dir [file dirname $dst]
249 remote_exec host "mkdir" [list "-p" "$dir"]
251 set result [remote_download host $src $dst]
252 if { $result == "" } {
253 verbose -log "Unable to download ${srcdir}/${src} to host."
257 set includes "-Iutil"
258 } elseif { [file exists $flags_file] } {
259 # If we find a testsuite_flags file, we're testing in the build dir.
260 set cxx [exec sh $flags_file --build-cxx]
261 set cxxflags [exec sh $flags_file --cxxflags]
262 set cxxpchflags [exec sh $flags_file --cxxpchflags]
263 set cxxldflags [exec sh $flags_file --cxxldflags]
264 set cc [exec sh $flags_file --build-cc]
265 set includes [exec sh $flags_file --build-includes]
268 append cxxflags [getenv CXXFLAGS]
271 # Always use MO files built by this test harness.
272 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
273 set ccflags "$cxxflags -DLOCALEDIR=\".\""
275 # If a PCH file is available, use it. We must delay performing
276 # this check until $cxx and such have been initialized because we
277 # perform a test compilation. (Ideally, gcc --print-file-name would
278 # list PCH files, but it does not.)
279 if { $cxxpchflags != "" } {
280 set src "config[pid].cc"
281 set f [open $src "w"]
282 puts $f "int main () {}"
285 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
286 # useful as then the requested variant of the pre-build PCH
287 # files could be tested to see if it works.
288 set lines [v3_target_compile $src "config[pid].o" object \
289 "additional_flags=-include additional_flags=bits/stdc++.h"]
290 if { $lines != "" } {
291 verbose -log "Requested PCH file: $cxxpchflags"
292 verbose -log "is not working, and will not be used."
297 v3track cxxpchflags 2
300 if ![info exists PCH_CXXFLAGS] then {
301 set PCH_CXXFLAGS $cxxpchflags
302 v3track PCH_CXXFLAGS 2
305 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
308 # Callback for cleanup routines.
309 proc libstdc++_exit { } {
312 if [info exists gluefile] {
313 file_on_build delete $gluefile;
318 # Callback from system dg-test.
319 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
320 # Set up the compiler flags, based on what we're going to do.
323 set compile_type "preprocess"
324 set output_file "[file rootname [file tail $prog]].i"
327 set compile_type "assembly"
328 set output_file "[file rootname [file tail $prog]].s"
331 set compile_type "object"
332 set output_file "[file rootname [file tail $prog]].o"
335 set compile_type "executable"
336 set output_file "./[file rootname [file tail $prog]].exe"
339 set compile_type "executable"
340 # FIXME: "./" is to cope with "." not being in $PATH.
341 # Should this be handled elsewhere?
343 set output_file "./[file rootname [file tail $prog]].exe"
344 # This is the only place where we care if an executable was
345 # created or not. If it was, dg.exp will try to run it.
346 catch { remote_file build delete $output_file }
349 perror "$do_what: not a valid dg-do keyword"
354 # Short-circut a bunch of complicated goo here for the special
355 # case of compiling a test file as a "C" file, not as C++. Why? So
356 # -nostdc++ doesn't trip us up. So all the extra object files
357 # don't trip us up. So automatically linking in libstdc++ doesn't
358 # happen. So CXXFLAGS don't error.
359 set select_compile "v3_target_compile"
361 if { $extra_tool_flags != "" } {
362 verbose -log "extra_tool_flags are:"
363 verbose -log $extra_tool_flags
364 if { [string first "-x c" $extra_tool_flags ] != -1 } {
365 verbose -log "compiling and executing as C, not C++"
366 set edit_tool_flags $extra_tool_flags
367 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
368 lappend options "additional_flags=$edit_tool_flags"
369 set select_compile "v3_target_compile_as_c"
371 lappend options "additional_flags=$extra_tool_flags"
375 # There is a libstdc++_compile made for us by default (via the tool-
376 # and-target file), but the defaults are lacking in goodness.
377 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
379 return [list $comp_output $output_file]
382 # Override the DejaGnu dg-test in order to clear flags after a test, as
383 # is done for compiler tests in gcc-dg.exp.
385 if { [info procs saved-dg-test] == [list] } {
386 rename dg-test saved-dg-test
388 proc dg-test { args } {
389 global additional_prunes
392 if { [ catch { eval saved-dg-test $args } errmsg ] } {
393 set saved_info $errorInfo
394 set additional_prunes ""
396 error $errmsg $saved_info
398 set additional_prunes ""
403 # True if the library supports wchar_t.
406 # True if the library supports threads.
409 # True if the library supports symbol versioning.
412 # Called from libstdc++-dg-test above. Calls back into system's
413 # target_compile to actually do the work.
414 proc v3_target_compile { source dest type options } {
421 global STATIC_LIBCXXFLAGS
423 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
424 lappend options "libs=${gluefile}"
425 lappend options "ldflags=${wrap_flags}"
429 set cxxlibglossflags [libgloss_link_flags]
430 set cxx_final [concat $cxx_final $cxxlibglossflags]
431 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
432 set cxx_final [concat $cxx_final $cxxflags]
433 set cxx_final [concat $cxx_final $includes]
435 # Flag setting based on type argument.
436 if { $type == "executable" } {
437 # Link the support objects into executables.
438 lappend options "additional_flags=./libtestc++.a $cxxldflags"
440 if { $type == "sharedlib" } {
441 # Don't link in anything.
442 set type "executable"
446 lappend options "compiler=$cxx_final"
447 lappend options "timeout=[timeout_value]"
449 return [target_compile $source $dest $type $options]
453 # Called from libstdc++-dg-test above, but only for "C" compilation.
454 # Calls back into system's target_compile to actually do the work.
455 proc v3_target_compile_as_c { source dest type options } {
463 global STATIC_LIBCXXFLAGS
465 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
466 lappend options "libs=${gluefile}"
467 lappend options "ldflags=${wrap_flags}"
470 set tname [target_info name]
472 set cxxlibglossflags [libgloss_link_flags]
473 set cc_final [concat $cc_final $cxxlibglossflags]
474 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
475 set cc_final [concat $cc_final $cxxflags]
476 set cc_final [concat $cc_final $includes]
477 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
479 # This is needed for "C" tests, as this type of test may need the
480 # C++ includes. And if we're not testing in the build directory,
481 # the includes variable is not likely to include the necessary
483 if { ![file exists $flags_file] } {
484 # ??? We need a --print-include-dirs option to GCC, so that
485 # we can avoid these hacks. The heuristics here will not
486 # work with non-standard --with-includedir= options.
487 set version [remote_exec host ${cc} -dumpversion]
488 # Remove the trailing newline from the output.
489 set version [string trimright [lindex $version 1]]
490 set machine [remote_exec host ${cc} -dumpmachine]
491 set machine [string trimright [lindex $machine 1]]
492 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
493 set comp_base_dir [lindex $comp_base_dir 1]
494 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
495 # For a cross compiler, the header files will be located in a
496 # machine-specific subdirectory.
497 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
498 set crosstarget "${crossbase}/${machine}"
499 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
500 # For a native compiler, the header files will be located at
502 set includesbase "${comp_base_dir}/include/c++/${version}"
503 set includestarget "${includesbase}/${machine}"
504 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
506 set libdir "-L${comp_base_dir}/lib"
508 set libdir "-L${blddir}/libsupc++/.libs"
509 set libdir [concat $libdir "-L${blddir}/src/.libs"]
512 set cc_final [concat $cc_final "$libdir"]
514 lappend options "compiler=$cc_final"
515 lappend options "timeout=[timeout_value]"
517 return [target_compile $source $dest $type $options]
520 # Build the support objects linked in with the libstdc++ tests. In
521 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
522 proc v3-build_support { } {
530 # Figure out whether or not the library supports certain features.
536 set config_src "config.cc"
537 set config_out "config.ii"
538 set f [open $config_src "w"]
539 puts $f "#include <bits/c++config.h>"
540 puts $f "#include <bits/gthr.h>"
542 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
543 set file [open $config_out r]
544 set preprocessed [read $file]
546 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
547 verbose -log "wchar_t support detected"
550 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
551 verbose -log "symbol versioning support detected"
554 if { [string first "__GTHREADS" $preprocessed] != -1 } {
555 verbose -log "thread support detected"
559 # Try to build the MO files that are used by some of the locale
560 # tests. If we can't build them, that's OK; it just means that
561 # those tests will fail.
562 foreach lang [list "fr" "de"] {
564 file mkdir "$lang/LC_MESSAGES"
565 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
566 if [is_remote host] {
567 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
568 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
573 # Build the support objects.
574 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
575 testsuite_character.cc testsuite_hooks.cc \
576 io/verified_cmd_line_input.cc \
577 io/prog_bar.cc performance/time/elapsed_timer.cc ]
578 foreach f $source_files {
579 set obj [file rootname $f].o
580 set object_file [file tail $obj]
581 # Compile with "-w" so that warnings issued by the compiler
582 # do not prevent compilation.
583 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
584 [list "incdir=$srcdir" "additional_flags=-w"]]
586 error "could not compile $f"
588 append libtest_objs "$object_file "
591 # Collect into libtestc++.a
592 if [info exists env(AR)] {
595 set ar [transform "ar"]
597 set arargs "-rc ./libtestc++.a ${libtest_objs}"
598 verbose -log "$ar $arargs"
599 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
600 verbose "link result is $result"
601 if { $result == 0 } {
602 if [info exists env(RANLIB)] {
603 set ranlib $env(RANLIB)
605 set ranlib [transform "ranlib"]
607 set ranlibargs "./libtestc++.a"
608 verbose -log "$ranlib $ranlibargs"
609 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
610 if { $result != 0 } {
611 error "could not link libtestc++.a"
615 # Build any shared objects needed for regression testing.
616 if { ${v3-sharedlib} == 1 } {
617 set source_files [list testsuite_shared.cc]
618 foreach f $source_files {
619 set object_file [file rootname $f].so
620 # Compile with "-w" so that warnings issued by the compiler
621 # do not prevent compilation.
622 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
623 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
625 error "could not compile $f"
631 proc check_v3_target_fileio { } {
632 global et_fileio_saved
633 global et_fileio_target_name
637 if { ![info exists et_fileio_target_name] } {
638 set et_fileio_target_name ""
641 # If the target has changed since we set the cached value, clear it.
642 set current_target [current_target_name]
643 if { $current_target != $et_fileio_target_name } {
644 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
645 set et_fileio_target_name $current_target
646 if [info exists et_fileio_saved] {
647 verbose "check_v3_target_fileio: removing cached result" 2
648 unset et_fileio_saved
652 if [info exists et_fileio_saved] {
653 verbose "check_v3_target_fileio: using cached result" 2
655 set et_fileio_saved 0
657 # Set up, compile, and execute a C++ test program that tries to use
659 set src fileio[pid].cc
660 set exe fileio[pid].x
661 set testfile "cin_unget-1.txt"
662 v3-copy-files "$srcdir/data/$testfile"
664 set f [open $src "w"]
665 puts $f "#include <sys/types.h>"
666 puts $f "#include <sys/stat.h>"
667 puts $f "#include <fcntl.h>"
668 puts $f "#include <unistd.h>"
669 puts $f "#include <errno.h>"
670 puts $f "#include <string.h>"
671 puts $f "using namespace std;"
672 puts $f "int main ()"
674 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
675 puts $f " int ret = 0;"
676 puts $f " char buf\[10\];"
677 puts $f " if (fd == -1)"
681 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
683 puts $f " errno = 0;"
684 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
685 puts $f " || read (fd, buf, 4) != 4"
686 puts $f " || memcmp (buf, \"1234\", 4) != 0"
687 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
688 puts $f " || read (fd, buf, 2) != 2"
689 puts $f " || memcmp (buf, \"34\", 2) != 0)"
691 puts $f " close (fd);"
693 puts $f " return ret;"
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_fileio: status is <$status>" 2
708 if { $status == "pass" } {
709 set et_fileio_saved 1
712 verbose "check_v3_target_fileio: compilation failed" 2
715 return $et_fileio_saved
718 # Eventually we want C90/C99 determining and switching from this.
719 proc check_v3_target_c_std { } {
720 global et_c_std_saved
721 global et_c_std_target_name
724 if { ![info exists et_c_std_target_name] } {
725 set et_c_std_target_name ""
728 # If the target has changed since we set the cached value, clear it.
729 set current_target [current_target_name]
730 if { $current_target != $et_c_std_target_name } {
731 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
732 set et_c_std_target_name $current_target
733 if [info exists et_c_std_saved] {
734 verbose "check_v3_target_c_std: removing cached result" 2
739 if [info exists et_c_std_saved] {
740 verbose "check_v3_target_c_std: using cached result" 2
744 # Set up, compile, and execute a C++ test program that tries to use
746 # For math bits, could use check_effective_target_c99_math.
747 set src fileio[pid].cc
748 set exe fileio[pid].x
750 set f [open $src "w"]
751 puts $f "#include <tr1/cmath>"
752 puts $f "#include <cstdlib>"
753 puts $f "int main ()"
755 puts $f " float f = 45.55;"
756 puts $f " int i = std::tr1::isnan(f);"
758 puts $f " using std::wctomb;"
763 set lines [v3_target_compile $src $exe executable ""]
766 if [string match "" $lines] {
767 # No error message, compilation succeeded.
768 set result [${tool}_load "./$exe" "" ""]
769 set status [lindex $result 0]
770 remote_file build delete $exe
772 verbose "check_v3_target_c_std: status is <$status>" 2
774 if { $status == "pass" } {
778 verbose "check_v3_target_c_std: compilation failed" 2
781 return $et_c_std_saved
784 proc check_v3_target_sharedlib { } {
786 return ${v3-sharedlib}
789 proc check_v3_target_time { } {
791 global et_time_target_name
794 if { ![info exists et_time_target_name] } {
795 set et_time_target_name ""
798 # If the target has changed since we set the cached value, clear it.
799 set current_target [current_target_name]
800 if { $current_target != $et_time_target_name } {
801 verbose "check_v3_target_time: `$et_time_target_name'" 2
802 set et_time_target_name $current_target
803 if [info exists et_time_saved] {
804 verbose "check_v3_target_time: removing cached result" 2
809 if [info exists et_time_saved] {
810 verbose "check_v3_target_time: using cached result" 2
814 # Set up and compile a C++ test program that tries to use
819 set f [open $src "w"]
820 puts $f "#include <time.h>"
821 puts $f "using namespace std;"
822 puts $f "int main ()"
828 set lines [v3_target_compile $src $exe executable ""]
831 if [string match "" $lines] {
832 # No error message, compilation succeeded.
833 verbose "check_v3_target_time: compilation succeeded" 2
834 remote_file build delete $exe
837 verbose "check_v3_target_time: compilation failed" 2
840 return $et_time_saved
843 proc check_v3_target_namedlocale { args } {
844 global et_namedlocale
849 # Set up, compile, and execute a C++ test program that tries to use
850 # the required named locale.
851 set exe nlocale[pid].x
853 if ![file exists ./$exe] {
854 set src nlocale[pid].cc
856 set f [open $src "w"]
857 puts $f "#include <locale>"
858 puts $f "#include <cstdio>"
859 puts $f "using namespace std;"
860 puts $f "int main (int argc, char** argv)"
864 puts $f " locale(*(argv + 1));"
867 puts $f " catch(...)"
869 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
875 set lines [v3_target_compile $src $exe executable ""]
878 if ![string match "" $lines] {
879 verbose "check_v3_target_namedlocale: compilation failed" 2
880 return $et_namedlocale
882 # else No error message, compilation succeeded.
885 set result [${tool}_load "./$exe" "$args" ""]
886 set status [lindex $result 0]
888 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
890 if { $status == "pass" } {
893 return $et_namedlocale
896 proc check_v3_target_debug_mode { } {
900 if { ![info exists et_debug_mode_target_name] } {
901 set et_debug_mode_target_name ""
904 # If the target has changed since we set the cached value, clear it.
905 set current_target [current_target_name]
906 if { $current_target != $et_debug_mode_target_name } {
907 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
908 set et_debug_mode_target_name $current_target
909 if [info exists et_debug_mode] {
910 verbose "check_v3_target_debug_mode: removing cached result" 2
915 if [info exists et_debug_mode] {
916 verbose "check_v3_target_debug_mode: using cached result" 2
920 # Set up and compile a C++ test program that depends
921 # on debug mode activated.
922 set src debug_mode[pid].cc
923 set exe debug_mode[pid].exe
925 set f [open $src "w"]
926 puts $f "#ifndef _GLIBCXX_DEBUG"
927 puts $f "# error No debug mode"
930 puts $f "{ return 0; }"
933 set lines [v3_target_compile $src $exe executable ""]
936 if [string match "" $lines] {
937 # No error message, compilation succeeded.
942 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
943 return $et_debug_mode
946 proc check_v3_target_normal_mode { } {
947 global et_normal_mode
950 if { ![info exists et_normal_mode_target_name] } {
951 set et_normal_mode_target_name ""
954 # If the target has changed since we set the cached value, clear it.
955 set current_target [current_target_name]
956 if { $current_target != $et_normal_mode_target_name } {
957 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
958 set et_normal_mode_target_name $current_target
959 if [info exists et_normal_mode] {
960 verbose "check_v3_target_normal_mode: removing cached result" 2
965 if [info exists et_normal_mode] {
966 verbose "check_v3_target_normal_mode: using cached result" 2
970 # Set up and compile a C++ test program that depends
971 # on normal mode activated.
972 set src normal_mode[pid].cc
973 set exe normal_mode[pid].exe
975 set f [open $src "w"]
976 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
977 puts $f "# error No normal mode"
980 puts $f "{ return 0; }"
983 set lines [v3_target_compile $src $exe executable ""]
986 if [string match "" $lines] {
987 # No error message, compilation succeeded.
991 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
992 return $et_normal_mode
995 proc check_v3_target_parallel_mode { } {
998 global et_parallel_mode
1002 if { ![info exists et_parallel_mode_target_name] } {
1003 set et_parallel_mode_target_name ""
1006 # If the target has changed since we set the cached value, clear it.
1007 set current_target [current_target_name]
1008 if { $current_target != $et_parallel_mode_target_name } {
1009 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1010 set et_parallel_mode_target_name $current_target
1011 if [info exists et_parallel_mode] {
1012 verbose "check_v3_target_parallel_mode: removing cached result" 2
1013 unset et_parallel_mode
1017 if [info exists et_parallel_mode] {
1018 verbose "check_v3_target_parallel_mode: using cached result" 2
1020 set et_parallel_mode 0
1022 # If 'make check-parallel' is running the test succeeds.
1023 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1024 set et_parallel_mode 1
1027 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1028 return $et_parallel_mode
1031 proc check_v3_target_cstdint { } {
1033 global DEFAULT_CXXFLAGS
1038 if { ![info exists et_cstdint_target_name] } {
1039 set et_cstdint_target_name ""
1042 # If the target has changed since we set the cached value, clear it.
1043 set current_target [current_target_name]
1044 if { $current_target != $et_cstdint_target_name } {
1045 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1046 set et_cstdint_target_name $current_target
1047 if [info exists et_cstdint] {
1048 verbose "check_v3_target_cstdint: removing cached result" 2
1053 if [info exists et_cstdint] {
1054 verbose "check_v3_target_cstdint: using cached result" 2
1058 # Set up and compile a C++0x test program that depends
1059 # on the C99 stdint facilities to be available.
1060 set src cstdint[pid].cc
1061 set exe cstdint[pid].exe
1063 set f [open $src "w"]
1064 puts $f "#include <tr1/cstdint>"
1065 puts $f "int main()"
1066 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1067 puts $f "{ return 0; }"
1071 set cxxflags_saved $cxxflags
1072 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1074 set lines [v3_target_compile $src $exe executable ""]
1075 set cxxflags $cxxflags_saved
1078 if [string match "" $lines] {
1079 # No error message, compilation succeeded.
1082 verbose "check_v3_target_cstdint: compilation failed" 2
1085 verbose "check_v3_target_cstdint: $et_cstdint" 2
1089 proc check_v3_target_atomic_builtins { } {
1091 global DEFAULT_CXXFLAGS
1096 if { ![info exists et_atomic_builtins_target_name] } {
1097 set et_atomic_builtins_target_name ""
1100 # If the target has changed since we set the cached value, clear it.
1101 set current_target [current_target_name]
1102 if { $current_target != $et_atomic_builtins_target_name } {
1103 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1104 set et_atomic_builtins_target_name $current_target
1105 if [info exists et_atomic_builtins] {
1106 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1107 unset et_atomic_builtins
1111 if [info exists et_atomic_builtins] {
1112 verbose "check_v3_target_atomic_builtins: using cached result" 2
1114 set et_atomic_builtins 0
1116 # Set up and compile a C++0x test program that depends
1117 # on the atomic builtin facilities to be available.
1118 set src atomic_builtins[pid].cc
1119 set exe atomic_builtins[pid].exe
1121 set f [open $src "w"]
1122 puts $f "#include <bits/c++config.h>"
1123 puts $f "int main()"
1124 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1125 puts $f "{ return 0; }"
1129 set cxxflags_saved $cxxflags
1130 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1132 set lines [v3_target_compile $src $exe executable ""]
1133 set cxxflags $cxxflags_saved
1136 if [string match "" $lines] {
1137 # No error message, compilation succeeded.
1138 set et_atomic_builtins 1
1140 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1143 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1144 return $et_atomic_builtins
1147 proc check_v3_target_gthreads { } {
1149 global DEFAULT_CXXFLAGS
1154 if { ![info exists et_gthreads_target_name] } {
1155 set et_gthreads_target_name ""
1158 # If the target has changed since we set the cached value, clear it.
1159 set current_target [current_target_name]
1160 if { $current_target != $et_gthreads_target_name } {
1161 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1162 set et_gthreads_target_name $current_target
1163 if [info exists et_gthreads] {
1164 verbose "check_v3_target_gthreads: removing cached result" 2
1169 if [info exists et_gthreads] {
1170 verbose "check_v3_target_gthreads: using cached result" 2
1174 # Set up and compile a C++0x test program that depends
1175 # on the gthreads facilities to be available.
1176 set src gthreads[pid].cc
1177 set exe gthreads[pid].exe
1179 set f [open $src "w"]
1180 puts $f "#include <bits/c++config.h>"
1181 puts $f "int main()"
1182 puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
1183 puts $f "{ return 0; }"
1187 set cxxflags_saved $cxxflags
1188 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1190 set lines [v3_target_compile $src $exe executable ""]
1191 set cxxflags $cxxflags_saved
1194 if [string match "" $lines] {
1195 # No error message, compilation succeeded.
1198 verbose "check_v3_target_gthreads: compilation failed" 2
1201 verbose "check_v3_target_gthreads: $et_gthreads" 2
1205 proc check_v3_target_nanosleep { } {
1207 global DEFAULT_CXXFLAGS
1212 if { ![info exists et_nanosleep_target_name] } {
1213 set et_nanosleep_target_name ""
1216 # If the target has changed since we set the cached value, clear it.
1217 set current_target [current_target_name]
1218 if { $current_target != $et_nanosleep_target_name } {
1219 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1220 set et_nanosleep_target_name $current_target
1221 if [info exists et_nanosleep] {
1222 verbose "check_v3_target_nanosleep: removing cached result" 2
1227 if [info exists et_nanosleep] {
1228 verbose "check_v3_target_nanosleep: using cached result" 2
1232 # Set up and compile a C++0x test program that depends
1233 # on the nanosleep facilities to be available.
1234 set src nanosleep[pid].cc
1235 set exe nanosleep[pid].exe
1237 set f [open $src "w"]
1238 puts $f "#include <bits/c++config.h>"
1239 puts $f "int main()"
1240 puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
1241 puts $f "{ return 0; }"
1245 set cxxflags_saved $cxxflags
1246 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1248 set lines [v3_target_compile $src $exe executable ""]
1249 set cxxflags $cxxflags_saved
1252 if [string match "" $lines] {
1253 # No error message, compilation succeeded.
1256 verbose "check_v3_target_nanosleep: compilation failed" 2
1259 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1260 return $et_nanosleep
1263 proc check_v3_target_sched_yield { } {
1265 global DEFAULT_CXXFLAGS
1266 global et_sched_yield
1270 if { ![info exists et_sched_yield_target_name] } {
1271 set et_sched_yield_target_name ""
1274 # If the target has changed since we set the cached value, clear it.
1275 set current_target [current_target_name]
1276 if { $current_target != $et_sched_yield_target_name } {
1277 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1278 set et_sched_yield_target_name $current_target
1279 if [info exists et_sched_yield] {
1280 verbose "check_v3_target_sched_yield: removing cached result" 2
1281 unset et_sched_yield
1285 if [info exists et_sched_yield] {
1286 verbose "check_v3_target_sched_yield: using cached result" 2
1288 set et_sched_yield 0
1290 # Set up and compile a C++0x test program that depends
1291 # on the sched_yield facility to be available.
1292 set src sched_yield[pid].cc
1293 set exe sched_yield[pid].exe
1295 set f [open $src "w"]
1296 puts $f "#include <bits/c++config.h>"
1297 puts $f "int main()"
1298 puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
1299 puts $f "{ return 0; }"
1303 set cxxflags_saved $cxxflags
1304 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1306 set lines [v3_target_compile $src $exe executable ""]
1307 set cxxflags $cxxflags_saved
1310 if [string match "" $lines] {
1311 # No error message, compilation succeeded.
1312 set et_sched_yield 1
1314 verbose "check_v3_target_sched_yield: compilation failed" 2
1317 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1318 return $et_sched_yield
1321 proc check_v3_target_string_conversions { } {
1323 global DEFAULT_CXXFLAGS
1324 global et_string_conversions
1328 if { ![info exists et_string_conversions_target_name] } {
1329 set et_string_conversions_target_name ""
1332 # If the target has changed since we set the cached value, clear it.
1333 set current_target [current_target_name]
1334 if { $current_target != $et_string_conversions_target_name } {
1335 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1336 set et_string_conversions_target_name $current_target
1337 if [info exists et_string_conversions] {
1338 verbose "check_v3_target_string_conversions: removing cached result" 2
1339 unset et_string_conversions
1343 if [info exists et_string_conversions] {
1344 verbose "check_v3_target_string_conversions: using cached result" 2
1346 set et_string_conversions 0
1348 # Set up and compile a C++0x test program that depends
1349 # on the string_conversions facilities to be available.
1350 set src string_conversions[pid].cc
1351 set exe string_conversions[pid].exe
1353 set f [open $src "w"]
1354 puts $f "#include <bits/c++config.h>"
1355 puts $f "int main()"
1356 puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1357 puts $f "{ return 0; }"
1361 set cxxflags_saved $cxxflags
1362 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1364 set lines [v3_target_compile $src $exe executable ""]
1365 set cxxflags $cxxflags_saved
1368 if [string match "" $lines] {
1369 # No error message, compilation succeeded.
1370 set et_string_conversions 1
1372 verbose "check_v3_target_string_conversions: compilation failed" 2
1375 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1376 return $et_string_conversions
1379 proc check_v3_target_swprintf { } {
1381 global DEFAULT_CXXFLAGS
1386 if { ![info exists et_swprintf_target_name] } {
1387 set et_swprintf_target_name ""
1390 # If the target has changed since we set the cached value, clear it.
1391 set current_target [current_target_name]
1392 if { $current_target != $et_swprintf_target_name } {
1393 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1394 set et_swprintf_target_name $current_target
1395 if [info exists et_swprintf] {
1396 verbose "check_v3_target_swprintf: removing cached result" 2
1401 if [info exists et_swprintf] {
1402 verbose "check_v3_target_swprintf: using cached result" 2
1406 # Set up and compile a C++0x test program that depends
1407 # on a standard swprintf function to be available.
1408 set src swprintf[pid].cc
1409 set exe swprintf[pid].exe
1411 set f [open $src "w"]
1412 puts $f "#include <bits/c++config.h>"
1413 puts $f "int main()"
1414 puts $f "#if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1415 puts $f "{ return 0; }"
1419 set cxxflags_saved $cxxflags
1420 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1422 set lines [v3_target_compile $src $exe executable ""]
1423 set cxxflags $cxxflags_saved
1426 if [string match "" $lines] {
1427 # No error message, compilation succeeded.
1430 verbose "check_v3_target_swprintf: compilation failed" 2
1433 verbose "check_v3_target_swprintf: $et_swprintf" 2
1437 proc check_v3_target_binary_io { } {
1439 global DEFAULT_CXXFLAGS
1444 if { ![info exists et_binary_io_target_name] } {
1445 set et_binary_io_target_name ""
1448 # If the target has changed since we set the cached value, clear it.
1449 set current_target [current_target_name]
1450 if { $current_target != $et_binary_io_target_name } {
1451 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1452 set et_binary_io_target_name $current_target
1453 if [info exists et_binary_io] {
1454 verbose "check_v3_target_binary_io: removing cached result" 2
1459 if [info exists et_binary_io] {
1460 verbose "check_v3_target_binary_io: using cached result" 2
1464 # Set up and compile a C++0x test program that depends
1465 # on text and binary I/O being the same.
1466 set src binary_io[pid].cc
1467 set exe binary_io[pid].exe
1469 set f [open $src "w"]
1470 puts $f "#include <bits/c++config.h>"
1471 puts $f "int main()"
1472 puts $f "#if !defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1473 puts $f "{ return 0; }"
1477 set cxxflags_saved $cxxflags
1478 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1480 set lines [v3_target_compile $src $exe executable ""]
1481 set cxxflags $cxxflags_saved
1484 if [string match "" $lines] {
1485 # No error message, compilation succeeded.
1488 verbose "check_v3_target_binary_io: compilation failed" 2
1491 verbose "check_v3_target_binary_io: $et_binary_io" 2
1492 return $et_binary_io
1495 set additional_prunes ""