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 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
94 global DEFAULT_CXXFLAGS
95 global STATIC_LIBCXXFLAGS
97 # We set LC_ALL and LANG to C so that we get the same error
98 # messages as expected.
102 # Many hosts now default to a non-ASCII C locale, however, so
103 # they can set a charset encoding here if they need.
104 if { [ishost "*-*-cygwin*"] } {
105 setenv LC_ALL C.ASCII
109 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
110 set flags_file "${blddir}/scripts/testsuite_flags"
111 set shlib_ext [get_shlib_extension]
114 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
115 # Use this variable if the behavior
116 # 1) only applies to libstdc++ testing
117 # 2) might need to be negated
118 # In particular, some tests have to be run without precompiled
119 # headers, or without assertions.
121 if ![info exists DEFAULT_CXXFLAGS] then {
122 set DEFAULT_CXXFLAGS ""
123 # Host specific goo here.
124 if { [string match "powerpc-*-darwin*" $target_triplet] } {
125 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
128 v3track DEFAULT_CXXFLAGS 2
130 # By default, we assume we want to run program images.
131 global dg-do-what-default
132 set dg-do-what-default run
134 # Copy any required data files.
135 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
136 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
138 set ld_library_path_tmp ""
140 # Locate libgcc.a so we don't need to account for different values of
141 # SHLIB_EXT on different platforms
142 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
144 set gccdir [file dirname $gccdir]
145 append ld_library_path_tmp ":${gccdir}"
149 # Locate libgomp. This is only required for parallel mode.
151 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
152 if {$libgompdir != ""} {
154 set libgompdir [file dirname $libgompdir]
155 append ld_library_path_tmp ":${libgompdir}"
156 verbose -log "libgomp support detected"
160 # Locate libstdc++ shared library. (ie libstdc++.so.)
162 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
163 if {$sharedlibdir != ""} {
164 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
166 verbose -log "shared library support detected"
169 v3track v3-sharedlib 3
171 set STATIC_LIBCXXFLAGS ""
172 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
173 if {$staticlibdir != ""} {
174 set staticlibdir [file dirname $staticlibdir]
175 # Some targets use libstdc++.a%s in their specs, so they need a
176 # -B option for uninstalled testing.
177 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
180 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
182 set compiler ${gccdir}/g++
183 set ld_library_path ${ld_library_path_tmp}
184 append ld_library_path ":${blddir}/src/.libs"
186 if { [is_remote host] == 0 && [which $compiler] != 0 } {
187 foreach i "[exec $compiler --print-multi-lib]" {
189 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
190 set mldir [string trimright $mldir "\;@"]
191 if { "$mldir" == "." } {
194 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
195 append ld_library_path ":${gccdir}/${mldir}"
200 set_ld_library_path_env_vars
201 if [info exists env(LD_LIBRARY_PATH)] {
202 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
205 set compiler [transform "g++"]
208 # Set the default timeout for v3 tests.
212 set cxx [transform "g++"]
213 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
216 set cc [transform "gcc"]
217 # Locate testsuite_hooks.h and other testsuite headers.
218 set includes "-I${srcdir}/util"
219 # Adapt the defaults for special circumstances.
220 if [is_remote host] {
221 # A remote host does not, in general, have access to the
222 # $srcdir so we copy the testsuite headers into the current
223 # directory, and then add that to the search path.
224 foreach src [glob "${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 "${srcdir}/util/*/*/*.h" \
233 "${srcdir}/util/*/*/*.cc" \
234 "${srcdir}/util/*/*/*.tcc" \
235 "${srcdir}/util/*/*/*.hpp" \
236 "${srcdir}/util/*/*/*/*.h" \
237 "${srcdir}/util/*/*/*/*.cc" \
238 "${srcdir}/util/*/*/*/*.tcc" \
239 "${srcdir}/util/*/*/*/*.hpp" \
240 "${srcdir}/util/*/*/*/*/*.h" \
241 "${srcdir}/util/*/*/*/*/*.cc" \
242 "${srcdir}/util/*/*/*/*/*.tcc" \
243 "${srcdir}/util/*/*/*/*/*.hpp" ] {
244 # Remove everything up to "util/..."
245 set dst [string range $src [string length "${srcdir}/"] end]
246 # Create the directory containing the file.
247 set dir [file dirname $dst]
248 remote_exec host "mkdir" [list "-p" "$dir"]
250 set result [remote_download host $src $dst]
251 if { $result == "" } {
252 verbose -log "Unable to download ${srcdir}/${src} to host."
256 set includes "-Iutil"
257 } elseif { [file exists $flags_file] } {
258 # If we find a testsuite_flags file, we're testing in the build dir.
259 set cxx [exec sh $flags_file --build-cxx]
260 set cxxflags [exec sh $flags_file --cxxflags]
261 set cxxpchflags [exec sh $flags_file --cxxpchflags]
262 set cxxldflags [exec sh $flags_file --cxxldflags]
263 set cc [exec sh $flags_file --build-cc]
264 set includes [exec sh $flags_file --build-includes]
267 append cxxflags [getenv CXXFLAGS]
270 # Always use MO files built by this test harness.
271 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
272 set ccflags "$cxxflags -DLOCALEDIR=\".\""
274 # If a PCH file is available, use it. We must delay performing
275 # this check until $cxx and such have been initialized because we
276 # perform a test compilation. (Ideally, gcc --print-file-name would
277 # list PCH files, but it does not.)
278 if { $cxxpchflags != "" } {
279 set src "config[pid].cc"
280 set f [open $src "w"]
281 puts $f "int main () {}"
284 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
285 # useful as then the requested variant of the pre-build PCH
286 # files could be tested to see if it works.
287 set lines [v3_target_compile $src "config[pid].o" object \
288 "additional_flags=-include additional_flags=bits/stdc++.h"]
289 if { $lines != "" } {
290 verbose -log "Requested PCH file: $cxxpchflags"
291 verbose -log "is not working, and will not be used."
296 v3track cxxpchflags 2
299 if ![info exists PCH_CXXFLAGS] then {
300 set PCH_CXXFLAGS $cxxpchflags
301 v3track PCH_CXXFLAGS 2
304 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
307 # Callback for cleanup routines.
308 proc libstdc++_exit { } {
311 if [info exists gluefile] {
312 file_on_build delete $gluefile;
317 # Callback from system dg-test.
318 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
319 # Set up the compiler flags, based on what we're going to do.
322 set compile_type "preprocess"
323 set output_file "[file rootname [file tail $prog]].i"
326 set compile_type "assembly"
327 set output_file "[file rootname [file tail $prog]].s"
330 set compile_type "object"
331 set output_file "[file rootname [file tail $prog]].o"
334 set compile_type "executable"
335 set output_file "./[file rootname [file tail $prog]].exe"
338 set compile_type "executable"
339 # FIXME: "./" is to cope with "." not being in $PATH.
340 # Should this be handled elsewhere?
342 set output_file "./[file rootname [file tail $prog]].exe"
343 # This is the only place where we care if an executable was
344 # created or not. If it was, dg.exp will try to run it.
345 catch { remote_file build delete $output_file }
348 perror "$do_what: not a valid dg-do keyword"
353 # Short-circut a bunch of complicated goo here for the special
354 # case of compiling a test file as a "C" file, not as C++. Why? So
355 # -nostdc++ doesn't trip us up. So all the extra object files
356 # don't trip us up. So automatically linking in libstdc++ doesn't
357 # happen. So CXXFLAGS don't error.
358 set select_compile "v3_target_compile"
360 if { $extra_tool_flags != "" } {
361 verbose -log "extra_tool_flags are:"
362 verbose -log $extra_tool_flags
363 if { [string first "-x c" $extra_tool_flags ] != -1 } {
364 verbose -log "compiling and executing as C, not C++"
365 set edit_tool_flags $extra_tool_flags
366 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
367 lappend options "additional_flags=$edit_tool_flags"
368 set select_compile "v3_target_compile_as_c"
370 lappend options "additional_flags=$extra_tool_flags"
374 # There is a libstdc++_compile made for us by default (via the tool-
375 # and-target file), but the defaults are lacking in goodness.
376 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
378 return [list $comp_output $output_file]
381 # Override the DejaGnu dg-test in order to clear flags after a test, as
382 # is done for compiler tests in gcc-dg.exp.
384 if { [info procs saved-dg-test] == [list] } {
385 rename dg-test saved-dg-test
387 proc dg-test { args } {
388 global additional_prunes
391 if { [ catch { eval saved-dg-test $args } errmsg ] } {
392 set saved_info $errorInfo
393 set additional_prunes ""
395 error $errmsg $saved_info
397 set additional_prunes ""
402 # True if the library supports wchar_t.
405 # True if the library supports threads.
408 # True if the library supports symbol versioning.
411 # Called from libstdc++-dg-test above. Calls back into system's
412 # target_compile to actually do the work.
413 proc v3_target_compile { source dest type options } {
420 global STATIC_LIBCXXFLAGS
422 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
423 lappend options "libs=${gluefile}"
424 lappend options "ldflags=${wrap_flags}"
428 set cxxlibglossflags [libgloss_link_flags]
429 set cxx_final [concat $cxx_final $cxxlibglossflags]
430 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
431 set cxx_final [concat $cxx_final $cxxflags]
432 set cxx_final [concat $cxx_final $includes]
434 # Flag setting based on type argument.
435 if { $type == "executable" } {
436 # Link the support objects into executables.
437 lappend options "additional_flags=./libtestc++.a $cxxldflags"
439 if { $type == "sharedlib" } {
440 # Don't link in anything.
441 set type "executable"
445 lappend options "compiler=$cxx_final"
446 lappend options "timeout=[timeout_value]"
448 return [target_compile $source $dest $type $options]
452 # Called from libstdc++-dg-test above, but only for "C" compilation.
453 # Calls back into system's target_compile to actually do the work.
454 proc v3_target_compile_as_c { source dest type options } {
462 global STATIC_LIBCXXFLAGS
464 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
465 lappend options "libs=${gluefile}"
466 lappend options "ldflags=${wrap_flags}"
469 set tname [target_info name]
471 set cxxlibglossflags [libgloss_link_flags]
472 set cc_final [concat $cc_final $cxxlibglossflags]
473 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
474 set cc_final [concat $cc_final $cxxflags]
475 set cc_final [concat $cc_final $includes]
476 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
478 # This is needed for "C" tests, as this type of test may need the
479 # C++ includes. And if we're not testing in the build directory,
480 # the includes variable is not likely to include the necessary
482 if { ![file exists $flags_file] } {
483 # ??? We need a --print-include-dirs option to GCC, so that
484 # we can avoid these hacks. The heuristics here will not
485 # work with non-standard --with-includedir= options.
486 set version [remote_exec host ${cc} -dumpversion]
487 # Remove the trailing newline from the output.
488 set version [string trimright [lindex $version 1]]
489 set machine [remote_exec host ${cc} -dumpmachine]
490 set machine [string trimright [lindex $machine 1]]
491 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
492 set comp_base_dir [lindex $comp_base_dir 1]
493 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
494 # For a cross compiler, the header files will be located in a
495 # machine-specific subdirectory.
496 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
497 set crosstarget "${crossbase}/${machine}"
498 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
499 # For a native compiler, the header files will be located at
501 set includesbase "${comp_base_dir}/include/c++/${version}"
502 set includestarget "${includesbase}/${machine}"
503 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
505 set libdir "-L${comp_base_dir}/lib"
507 set libdir "-L${blddir}/libsupc++/.libs"
508 set libdir [concat $libdir "-L${blddir}/src/.libs"]
511 set cc_final [concat $cc_final "$libdir"]
513 lappend options "compiler=$cc_final"
514 lappend options "timeout=[timeout_value]"
516 return [target_compile $source $dest $type $options]
519 # Build the support objects linked in with the libstdc++ tests. In
520 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
521 proc v3-build_support { } {
529 # Figure out whether or not the library supports certain features.
535 set config_src "config.cc"
536 set config_out "config.ii"
537 set f [open $config_src "w"]
538 puts $f "#include <bits/c++config.h>"
539 puts $f "#include <bits/gthr.h>"
541 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
542 set file [open $config_out r]
543 set preprocessed [read $file]
545 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
546 verbose -log "wchar_t support detected"
549 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
550 verbose -log "symbol versioning support detected"
553 if { [string first "__GTHREADS" $preprocessed] != -1 } {
554 verbose -log "thread support detected"
558 # Try to build the MO files that are used by some of the locale
559 # tests. If we can't build them, that's OK; it just means that
560 # those tests will fail.
561 foreach lang [list "fr" "de"] {
563 file mkdir "$lang/LC_MESSAGES"
564 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
565 if [is_remote host] {
566 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
567 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
572 # Build the support objects.
573 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
574 testsuite_character.cc testsuite_hooks.cc \
575 io/verified_cmd_line_input.cc \
576 io/prog_bar.cc performance/time/elapsed_timer.cc ]
577 foreach f $source_files {
578 set obj [file rootname $f].o
579 set object_file [file tail $obj]
580 # Compile with "-w" so that warnings issued by the compiler
581 # do not prevent compilation.
582 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
583 [list "incdir=$srcdir" "additional_flags=-w"]]
585 error "could not compile $f"
587 append libtest_objs "$object_file "
590 # Collect into libtestc++.a
591 if [info exists env(AR)] {
594 set ar [transform "ar"]
596 set arargs "-rc ./libtestc++.a ${libtest_objs}"
597 verbose -log "$ar $arargs"
598 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
599 verbose "link result is $result"
600 if { $result == 0 } {
601 if [info exists env(RANLIB)] {
602 set ranlib $env(RANLIB)
604 set ranlib [transform "ranlib"]
606 set ranlibargs "./libtestc++.a"
607 verbose -log "$ranlib $ranlibargs"
608 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
609 if { $result != 0 } {
610 error "could not link libtestc++.a"
614 # Build any shared objects needed for regression testing.
615 if { ${v3-sharedlib} == 1 } {
616 set source_files [list testsuite_shared.cc]
617 foreach f $source_files {
618 set object_file [file rootname $f].so
619 # Compile with "-w" so that warnings issued by the compiler
620 # do not prevent compilation.
621 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
622 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
624 error "could not compile $f"
630 proc check_v3_target_fileio { } {
631 global et_fileio_saved
632 global et_fileio_target_name
636 if { ![info exists et_fileio_target_name] } {
637 set et_fileio_target_name ""
640 # If the target has changed since we set the cached value, clear it.
641 set current_target [current_target_name]
642 if { $current_target != $et_fileio_target_name } {
643 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
644 set et_fileio_target_name $current_target
645 if [info exists et_fileio_saved] {
646 verbose "check_v3_target_fileio: removing cached result" 2
647 unset et_fileio_saved
651 if [info exists et_fileio_saved] {
652 verbose "check_v3_target_fileio: using cached result" 2
654 set et_fileio_saved 0
656 # Set up, compile, and execute a C++ test program that tries to use
658 set src fileio[pid].cc
659 set exe fileio[pid].x
660 set testfile "cin_unget-1.txt"
661 v3-copy-files "$srcdir/data/$testfile"
663 set f [open $src "w"]
664 puts $f "#include <sys/types.h>"
665 puts $f "#include <sys/stat.h>"
666 puts $f "#include <fcntl.h>"
667 puts $f "#include <unistd.h>"
668 puts $f "#include <errno.h>"
669 puts $f "#include <string.h>"
670 puts $f "using namespace std;"
671 puts $f "int main ()"
673 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
674 puts $f " int ret = 0;"
675 puts $f " char buf\[10\];"
676 puts $f " if (fd == -1)"
680 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
682 puts $f " errno = 0;"
683 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
684 puts $f " || read (fd, buf, 4) != 4"
685 puts $f " || memcmp (buf, \"1234\", 4) != 0"
686 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
687 puts $f " || read (fd, buf, 2) != 2"
688 puts $f " || memcmp (buf, \"34\", 2) != 0)"
690 puts $f " close (fd);"
692 puts $f " return ret;"
696 set lines [v3_target_compile $src $exe executable ""]
699 if [string match "" $lines] {
700 # No error message, compilation succeeded.
701 set result [${tool}_load "./$exe" "" ""]
702 set status [lindex $result 0]
703 remote_file build delete $exe
705 verbose "check_v3_target_fileio: status is <$status>" 2
707 if { $status == "pass" } {
708 set et_fileio_saved 1
711 verbose "check_v3_target_fileio: compilation failed" 2
714 return $et_fileio_saved
717 # Eventually we want C90/C99 determining and switching from this.
718 proc check_v3_target_c_std { } {
719 global et_c_std_saved
720 global et_c_std_target_name
723 if { ![info exists et_c_std_target_name] } {
724 set et_c_std_target_name ""
727 # If the target has changed since we set the cached value, clear it.
728 set current_target [current_target_name]
729 if { $current_target != $et_c_std_target_name } {
730 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
731 set et_c_std_target_name $current_target
732 if [info exists et_c_std_saved] {
733 verbose "check_v3_target_c_std: removing cached result" 2
738 if [info exists et_c_std_saved] {
739 verbose "check_v3_target_c_std: using cached result" 2
743 # Set up, compile, and execute a C++ test program that tries to use
745 # For math bits, could use check_effective_target_c99_math.
746 set src fileio[pid].cc
747 set exe fileio[pid].x
749 set f [open $src "w"]
750 puts $f "#include <tr1/cmath>"
751 puts $f "#include <cstdlib>"
752 puts $f "int main ()"
754 puts $f " float f = 45.55;"
755 puts $f " int i = std::tr1::isnan(f);"
757 puts $f " using std::wctomb;"
762 set lines [v3_target_compile $src $exe executable ""]
765 if [string match "" $lines] {
766 # No error message, compilation succeeded.
767 set result [${tool}_load "./$exe" "" ""]
768 set status [lindex $result 0]
769 remote_file build delete $exe
771 verbose "check_v3_target_c_std: status is <$status>" 2
773 if { $status == "pass" } {
777 verbose "check_v3_target_c_std: compilation failed" 2
780 return $et_c_std_saved
783 proc check_v3_target_sharedlib { } {
785 return ${v3-sharedlib}
788 proc check_v3_target_time { } {
790 global et_time_target_name
793 if { ![info exists et_time_target_name] } {
794 set et_time_target_name ""
797 # If the target has changed since we set the cached value, clear it.
798 set current_target [current_target_name]
799 if { $current_target != $et_time_target_name } {
800 verbose "check_v3_target_time: `$et_time_target_name'" 2
801 set et_time_target_name $current_target
802 if [info exists et_time_saved] {
803 verbose "check_v3_target_time: removing cached result" 2
808 if [info exists et_time_saved] {
809 verbose "check_v3_target_time: using cached result" 2
813 # Set up and compile a C++ test program that tries to use
818 set f [open $src "w"]
819 puts $f "#include <time.h>"
820 puts $f "using namespace std;"
821 puts $f "int main ()"
827 set lines [v3_target_compile $src $exe executable ""]
830 if [string match "" $lines] {
831 # No error message, compilation succeeded.
832 verbose "check_v3_target_time: compilation succeeded" 2
833 remote_file build delete $exe
836 verbose "check_v3_target_time: compilation failed" 2
839 return $et_time_saved
842 proc check_v3_target_namedlocale { args } {
843 global et_namedlocale
848 # Set up, compile, and execute a C++ test program that tries to use
849 # the required named locale.
850 set exe nlocale[pid].x
852 if ![file exists ./$exe] {
853 set src nlocale[pid].cc
855 set f [open $src "w"]
856 puts $f "#include <locale>"
857 puts $f "#include <cstdio>"
858 puts $f "using namespace std;"
859 puts $f "int main (int argc, char** argv)"
863 puts $f " locale(*(argv + 1));"
866 puts $f " catch(...)"
868 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
874 set lines [v3_target_compile $src $exe executable ""]
877 if ![string match "" $lines] {
878 verbose "check_v3_target_namedlocale: compilation failed" 2
879 return $et_namedlocale
881 # else No error message, compilation succeeded.
884 set result [${tool}_load "./$exe" "$args" ""]
885 set status [lindex $result 0]
887 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
889 if { $status == "pass" } {
892 return $et_namedlocale
895 proc check_v3_target_debug_mode { } {
899 if { ![info exists et_debug_mode_target_name] } {
900 set et_debug_mode_target_name ""
903 # If the target has changed since we set the cached value, clear it.
904 set current_target [current_target_name]
905 if { $current_target != $et_debug_mode_target_name } {
906 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
907 set et_debug_mode_target_name $current_target
908 if [info exists et_debug_mode] {
909 verbose "check_v3_target_debug_mode: removing cached result" 2
914 if [info exists et_debug_mode] {
915 verbose "check_v3_target_debug_mode: using cached result" 2
919 # Set up and compile a C++ test program that depends
920 # on debug mode activated.
921 set src debug_mode[pid].cc
922 set exe debug_mode[pid].exe
924 set f [open $src "w"]
925 puts $f "#ifndef _GLIBCXX_DEBUG"
926 puts $f "# error No debug mode"
929 puts $f "{ return 0; }"
932 set lines [v3_target_compile $src $exe executable ""]
935 if [string match "" $lines] {
936 # No error message, compilation succeeded.
941 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
942 return $et_debug_mode
945 proc check_v3_target_normal_mode { } {
946 global et_normal_mode
949 if { ![info exists et_normal_mode_target_name] } {
950 set et_normal_mode_target_name ""
953 # If the target has changed since we set the cached value, clear it.
954 set current_target [current_target_name]
955 if { $current_target != $et_normal_mode_target_name } {
956 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
957 set et_normal_mode_target_name $current_target
958 if [info exists et_normal_mode] {
959 verbose "check_v3_target_normal_mode: removing cached result" 2
964 if [info exists et_normal_mode] {
965 verbose "check_v3_target_normal_mode: using cached result" 2
969 # Set up and compile a C++ test program that depends
970 # on normal mode activated.
971 set src normal_mode[pid].cc
972 set exe normal_mode[pid].exe
974 set f [open $src "w"]
975 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
976 puts $f "# error No normal mode"
979 puts $f "{ return 0; }"
982 set lines [v3_target_compile $src $exe executable ""]
985 if [string match "" $lines] {
986 # No error message, compilation succeeded.
990 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
991 return $et_normal_mode
994 proc check_v3_target_parallel_mode { } {
997 global et_parallel_mode
1001 if { ![info exists et_parallel_mode_target_name] } {
1002 set et_parallel_mode_target_name ""
1005 # If the target has changed since we set the cached value, clear it.
1006 set current_target [current_target_name]
1007 if { $current_target != $et_parallel_mode_target_name } {
1008 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1009 set et_parallel_mode_target_name $current_target
1010 if [info exists et_parallel_mode] {
1011 verbose "check_v3_target_parallel_mode: removing cached result" 2
1012 unset et_parallel_mode
1016 if [info exists et_parallel_mode] {
1017 verbose "check_v3_target_parallel_mode: using cached result" 2
1019 set et_parallel_mode 0
1021 # If 'make check-parallel' is running the test succeeds.
1022 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1023 set et_parallel_mode 1
1026 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1027 return $et_parallel_mode
1030 proc check_v3_target_cstdint { } {
1032 global DEFAULT_CXXFLAGS
1037 if { ![info exists et_cstdint_target_name] } {
1038 set et_cstdint_target_name ""
1041 # If the target has changed since we set the cached value, clear it.
1042 set current_target [current_target_name]
1043 if { $current_target != $et_cstdint_target_name } {
1044 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1045 set et_cstdint_target_name $current_target
1046 if [info exists et_cstdint] {
1047 verbose "check_v3_target_cstdint: removing cached result" 2
1052 if [info exists et_cstdint] {
1053 verbose "check_v3_target_cstdint: using cached result" 2
1057 # Set up and compile a C++0x test program that depends
1058 # on the C99 stdint facilities to be available.
1059 set src cstdint[pid].cc
1060 set exe cstdint[pid].exe
1062 set f [open $src "w"]
1063 puts $f "#include <tr1/cstdint>"
1064 puts $f "int main()"
1065 puts $f "#ifdef _GLIBCXX_USE_C99_STDINT_TR1"
1066 puts $f "{ return 0; }"
1070 set cxxflags_saved $cxxflags
1071 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1073 set lines [v3_target_compile $src $exe executable ""]
1074 set cxxflags $cxxflags_saved
1077 if [string match "" $lines] {
1078 # No error message, compilation succeeded.
1081 verbose "check_v3_target_cstdint: compilation failed" 2
1084 verbose "check_v3_target_cstdint: $et_cstdint" 2
1088 proc check_v3_target_atomic_builtins { } {
1090 global DEFAULT_CXXFLAGS
1095 if { ![info exists et_atomic_builtins_target_name] } {
1096 set et_atomic_builtins_target_name ""
1099 # If the target has changed since we set the cached value, clear it.
1100 set current_target [current_target_name]
1101 if { $current_target != $et_atomic_builtins_target_name } {
1102 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1103 set et_atomic_builtins_target_name $current_target
1104 if [info exists et_atomic_builtins] {
1105 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1106 unset et_atomic_builtins
1110 if [info exists et_atomic_builtins] {
1111 verbose "check_v3_target_atomic_builtins: using cached result" 2
1113 set et_atomic_builtins 0
1115 # Set up and compile a C++0x test program that depends
1116 # on the atomic builtin facilities to be available.
1117 set src atomic_builtins[pid].cc
1118 set exe atomic_builtins[pid].exe
1120 set f [open $src "w"]
1121 puts $f "#include <bits/c++config.h>"
1122 puts $f "int main()"
1123 puts $f "#ifdef _GLIBCXX_ATOMIC_BUILTINS_4"
1124 puts $f "{ return 0; }"
1128 set cxxflags_saved $cxxflags
1129 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1131 set lines [v3_target_compile $src $exe executable ""]
1132 set cxxflags $cxxflags_saved
1135 if [string match "" $lines] {
1136 # No error message, compilation succeeded.
1137 set et_atomic_builtins 1
1139 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1142 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1143 return $et_atomic_builtins
1146 proc check_v3_target_gthreads { } {
1148 global DEFAULT_CXXFLAGS
1153 if { ![info exists et_gthreads_target_name] } {
1154 set et_gthreads_target_name ""
1157 # If the target has changed since we set the cached value, clear it.
1158 set current_target [current_target_name]
1159 if { $current_target != $et_gthreads_target_name } {
1160 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1161 set et_gthreads_target_name $current_target
1162 if [info exists et_gthreads] {
1163 verbose "check_v3_target_gthreads: removing cached result" 2
1168 if [info exists et_gthreads] {
1169 verbose "check_v3_target_gthreads: using cached result" 2
1173 # Set up and compile a C++0x test program that depends
1174 # on the gthreads facilities to be available.
1175 set src gthreads[pid].cc
1176 set exe gthreads[pid].exe
1178 set f [open $src "w"]
1179 puts $f "#include <bits/c++config.h>"
1180 puts $f "int main()"
1181 puts $f "#ifdef _GLIBCXX_HAS_GTHREADS"
1182 puts $f "{ return 0; }"
1186 set cxxflags_saved $cxxflags
1187 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1189 set lines [v3_target_compile $src $exe executable ""]
1190 set cxxflags $cxxflags_saved
1193 if [string match "" $lines] {
1194 # No error message, compilation succeeded.
1197 verbose "check_v3_target_gthreads: compilation failed" 2
1200 verbose "check_v3_target_gthreads: $et_gthreads" 2
1204 proc check_v3_target_nanosleep { } {
1206 global DEFAULT_CXXFLAGS
1211 if { ![info exists et_nanosleep_target_name] } {
1212 set et_nanosleep_target_name ""
1215 # If the target has changed since we set the cached value, clear it.
1216 set current_target [current_target_name]
1217 if { $current_target != $et_nanosleep_target_name } {
1218 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1219 set et_nanosleep_target_name $current_target
1220 if [info exists et_nanosleep] {
1221 verbose "check_v3_target_nanosleep: removing cached result" 2
1226 if [info exists et_nanosleep] {
1227 verbose "check_v3_target_nanosleep: using cached result" 2
1231 # Set up and compile a C++0x test program that depends
1232 # on the nanosleep facilities to be available.
1233 set src nanosleep[pid].cc
1234 set exe nanosleep[pid].exe
1236 set f [open $src "w"]
1237 puts $f "#include <bits/c++config.h>"
1238 puts $f "int main()"
1239 puts $f "#ifdef _GLIBCXX_USE_NANOSLEEP"
1240 puts $f "{ return 0; }"
1244 set cxxflags_saved $cxxflags
1245 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1247 set lines [v3_target_compile $src $exe executable ""]
1248 set cxxflags $cxxflags_saved
1251 if [string match "" $lines] {
1252 # No error message, compilation succeeded.
1255 verbose "check_v3_target_nanosleep: compilation failed" 2
1258 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1259 return $et_nanosleep
1262 proc check_v3_target_sched_yield { } {
1264 global DEFAULT_CXXFLAGS
1265 global et_sched_yield
1269 if { ![info exists et_sched_yield_target_name] } {
1270 set et_sched_yield_target_name ""
1273 # If the target has changed since we set the cached value, clear it.
1274 set current_target [current_target_name]
1275 if { $current_target != $et_sched_yield_target_name } {
1276 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1277 set et_sched_yield_target_name $current_target
1278 if [info exists et_sched_yield] {
1279 verbose "check_v3_target_sched_yield: removing cached result" 2
1280 unset et_sched_yield
1284 if [info exists et_sched_yield] {
1285 verbose "check_v3_target_sched_yield: using cached result" 2
1287 set et_sched_yield 0
1289 # Set up and compile a C++0x test program that depends
1290 # on the sched_yield facility to be available.
1291 set src sched_yield[pid].cc
1292 set exe sched_yield[pid].exe
1294 set f [open $src "w"]
1295 puts $f "#include <bits/c++config.h>"
1296 puts $f "int main()"
1297 puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
1298 puts $f "{ return 0; }"
1302 set cxxflags_saved $cxxflags
1303 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1305 set lines [v3_target_compile $src $exe executable ""]
1306 set cxxflags $cxxflags_saved
1309 if [string match "" $lines] {
1310 # No error message, compilation succeeded.
1311 set et_sched_yield 1
1313 verbose "check_v3_target_sched_yield: compilation failed" 2
1316 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1317 return $et_sched_yield
1320 proc check_v3_target_string_conversions { } {
1322 global DEFAULT_CXXFLAGS
1323 global et_string_conversions
1327 if { ![info exists et_string_conversions_target_name] } {
1328 set et_string_conversions_target_name ""
1331 # If the target has changed since we set the cached value, clear it.
1332 set current_target [current_target_name]
1333 if { $current_target != $et_string_conversions_target_name } {
1334 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1335 set et_string_conversions_target_name $current_target
1336 if [info exists et_string_conversions] {
1337 verbose "check_v3_target_string_conversions: removing cached result" 2
1338 unset et_string_conversions
1342 if [info exists et_string_conversions] {
1343 verbose "check_v3_target_string_conversions: using cached result" 2
1345 set et_string_conversions 0
1347 # Set up and compile a C++0x test program that depends
1348 # on the string_conversions facilities to be available.
1349 set src string_conversions[pid].cc
1350 set exe string_conversions[pid].exe
1352 set f [open $src "w"]
1353 puts $f "#include <bits/c++config.h>"
1354 puts $f "int main()"
1355 puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1356 puts $f "{ return 0; }"
1360 set cxxflags_saved $cxxflags
1361 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1363 set lines [v3_target_compile $src $exe executable ""]
1364 set cxxflags $cxxflags_saved
1367 if [string match "" $lines] {
1368 # No error message, compilation succeeded.
1369 set et_string_conversions 1
1371 verbose "check_v3_target_string_conversions: compilation failed" 2
1374 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1375 return $et_string_conversions
1378 proc check_v3_target_swprintf { } {
1380 global DEFAULT_CXXFLAGS
1385 if { ![info exists et_swprintf_target_name] } {
1386 set et_swprintf_target_name ""
1389 # If the target has changed since we set the cached value, clear it.
1390 set current_target [current_target_name]
1391 if { $current_target != $et_swprintf_target_name } {
1392 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1393 set et_swprintf_target_name $current_target
1394 if [info exists et_swprintf] {
1395 verbose "check_v3_target_swprintf: removing cached result" 2
1400 if [info exists et_swprintf] {
1401 verbose "check_v3_target_swprintf: using cached result" 2
1405 # Set up and compile a C++0x test program that depends
1406 # on a standard swprintf function to be available.
1407 set src swprintf[pid].cc
1408 set exe swprintf[pid].exe
1410 set f [open $src "w"]
1411 puts $f "#include <bits/c++config.h>"
1412 puts $f "int main()"
1413 puts $f "#if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1414 puts $f "{ return 0; }"
1418 set cxxflags_saved $cxxflags
1419 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1421 set lines [v3_target_compile $src $exe executable ""]
1422 set cxxflags $cxxflags_saved
1425 if [string match "" $lines] {
1426 # No error message, compilation succeeded.
1429 verbose "check_v3_target_swprintf: compilation failed" 2
1432 verbose "check_v3_target_swprintf: $et_swprintf" 2
1436 proc check_v3_target_binary_io { } {
1438 global DEFAULT_CXXFLAGS
1443 if { ![info exists et_binary_io_target_name] } {
1444 set et_binary_io_target_name ""
1447 # If the target has changed since we set the cached value, clear it.
1448 set current_target [current_target_name]
1449 if { $current_target != $et_binary_io_target_name } {
1450 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1451 set et_binary_io_target_name $current_target
1452 if [info exists et_binary_io] {
1453 verbose "check_v3_target_binary_io: removing cached result" 2
1458 if [info exists et_binary_io] {
1459 verbose "check_v3_target_binary_io: using cached result" 2
1463 # Set up and compile a C++0x test program that depends
1464 # on text and binary I/O being the same.
1465 set src binary_io[pid].cc
1466 set exe binary_io[pid].exe
1468 set f [open $src "w"]
1469 puts $f "#include <bits/c++config.h>"
1470 puts $f "int main()"
1471 puts $f "#if !defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1472 puts $f "{ return 0; }"
1476 set cxxflags_saved $cxxflags
1477 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1479 set lines [v3_target_compile $src $exe executable ""]
1480 set cxxflags $cxxflags_saved
1483 if [string match "" $lines] {
1484 # No error message, compilation succeeded.
1487 verbose "check_v3_target_binary_io: compilation failed" 2
1490 verbose "check_v3_target_binary_io: $et_binary_io" 2
1491 return $et_binary_io
1494 set additional_prunes ""