1 # libstdc++ "tool init file" for DejaGNU
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
5 # Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
22 # Define callbacks and load other libraries. This file is loaded relatively
23 # early, and before any other file we write ourselves. "load_lib" will
24 # find anything in the DejaGNU installation tree, or in our lib directory.
25 # "load_gcc_lib" will search the core compiler's .exp collection instead.
27 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
28 # for "tool_" when finding callbacks. Utility routines we define for
29 # our callbacks begin with "v3-".
31 # libstdc++_* callbacks we don't define, but could:
32 # ..._option_help prints additional --help output
33 # ..._option_proc (--foo) process our own options
34 # ..._init (normal.exp) called once per test file
35 # ..._finish bracketing function for libstdc++_init
36 # ...-dg-prune removing output text, see top of system dg.exp
38 # Useful hook: if ${hostname}_init exists, it will be called, almost
39 # the last thing before testing begins. This can be defined in, e.g.,
40 # ~/.dejagnurc or $DEJAGNU.
42 proc load_gcc_lib { filename } {
44 load_file $srcdir/../../gcc/testsuite/lib/$filename
50 # compiler routines, then ours
51 load_gcc_lib target-supports.exp
52 load_gcc_lib target-supports-dg.exp
54 load_lib dg-options.exp
55 load_gcc_lib scanasm.exp
56 load_gcc_lib target-libpath.exp
57 load_gcc_lib timeout.exp
58 load_gcc_lib timeout-dg.exp
59 load_gcc_lib wrapper.exp
61 # Useful for debugging. Pass the name of a variable and the verbosity
62 # threshold (number of -v's on the command line).
63 proc v3track { var n } {
65 verbose "++ $var is $val" $n
68 # Called by v3-init below. "Static" to this file.
69 proc v3-copy-files {srcfiles} {
71 if { [catch { set symlink [file readlink $f] } x] } then {
72 remote_download target $f
74 if { [regexp "^/" "$symlink"] } then {
75 remote_download target $symlink
77 set dirname [file dirname $f]
78 remote_download target $dirname/$symlink
84 # Called once, during runtest.exp setup.
85 proc libstdc++_init { testfile } {
87 global v3-sharedlib v3-libgomp
88 global srcdir blddir objdir tool_root_dir
89 global cc cxx cxxflags cxxpchflags cxxldflags
91 global gluefile wrap_flags
92 global ld_library_path
96 global DEFAULT_CXXFLAGS
97 global STATIC_LIBCXXFLAGS
99 # We set LC_ALL and LANG to C so that we get the same error
100 # messages as expected.
104 # Many hosts now default to a non-ASCII C locale, however, so
105 # they can set a charset encoding here if they need.
106 if { [ishost "*-*-cygwin*"] } {
107 setenv LC_ALL C.ASCII
111 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
112 set flags_file "${blddir}/scripts/testsuite_flags"
113 set shlib_ext [get_shlib_extension]
116 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
117 # Use this variable if the behavior
118 # 1) only applies to libstdc++ testing
119 # 2) might need to be negated
120 # In particular, some tests have to be run without precompiled
121 # headers, or without assertions.
123 if ![info exists DEFAULT_CXXFLAGS] then {
124 set DEFAULT_CXXFLAGS ""
125 # Host specific goo here.
126 if { [string match "powerpc-*-darwin*" $target_triplet] } {
127 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
130 v3track DEFAULT_CXXFLAGS 2
132 # By default, we assume we want to run program images.
133 global dg-do-what-default
134 set dg-do-what-default run
136 # Copy any required data files.
137 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
138 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
140 set ld_library_path_tmp ""
142 # Locate libgcc.a so we don't need to account for different values of
143 # SHLIB_EXT on different platforms
144 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
146 set gccdir [file dirname $gccdir]
147 append ld_library_path_tmp ":${gccdir}"
151 # Locate libgomp. This is only required for parallel mode.
153 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
154 if {$libgompdir != ""} {
156 set libgompdir [file dirname $libgompdir]
157 append ld_library_path_tmp ":${libgompdir}"
158 verbose -log "libgomp support detected"
162 # Locate libstdc++ shared library. (ie libstdc++.so.)
164 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
165 if {$sharedlibdir != ""} {
166 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
168 verbose -log "shared library support detected"
171 v3track v3-sharedlib 3
173 set STATIC_LIBCXXFLAGS ""
174 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
175 if {$staticlibdir != ""} {
176 set staticlibdir [file dirname $staticlibdir]
177 # Some targets use libstdc++.a%s in their specs, so they need a
178 # -B option for uninstalled testing.
179 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
182 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
184 set compiler ${gccdir}/g++
185 set ld_library_path ${ld_library_path_tmp}
186 append ld_library_path ":${blddir}/src/.libs"
188 if { [is_remote host] == 0 && [which $compiler] != 0 } {
189 foreach i "[exec $compiler --print-multi-lib]" {
191 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
192 set mldir [string trimright $mldir "\;@"]
193 if { "$mldir" == "." } {
196 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
197 append ld_library_path ":${gccdir}/${mldir}"
202 set_ld_library_path_env_vars
203 if [info exists env(LD_LIBRARY_PATH)] {
204 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
207 set compiler [transform "g++"]
210 # Set the default timeout for v3 tests.
214 set cxx [transform "g++"]
215 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
218 set cc [transform "gcc"]
219 # Locate testsuite_hooks.h and other testsuite headers.
220 set includes "-I${srcdir}/util"
221 # Adapt the defaults for special circumstances.
222 if [is_remote host] {
223 # A remote host does not, in general, have access to the
224 # $srcdir so we copy the testsuite headers into the current
225 # directory, and then add that to the search path.
226 foreach src [glob "${srcdir}/util/*.h" \
227 "${srcdir}/util/*.cc" \
228 "${srcdir}/util/*.tcc" \
229 "${srcdir}/util/*.hpp" \
230 "${srcdir}/util/*/*.h" \
231 "${srcdir}/util/*/*.cc" \
232 "${srcdir}/util/*/*.tcc" \
233 "${srcdir}/util/*/*.hpp" \
234 "${srcdir}/util/*/*/*.h" \
235 "${srcdir}/util/*/*/*.cc" \
236 "${srcdir}/util/*/*/*.tcc" \
237 "${srcdir}/util/*/*/*.hpp" \
238 "${srcdir}/util/*/*/*/*.h" \
239 "${srcdir}/util/*/*/*/*.cc" \
240 "${srcdir}/util/*/*/*/*.tcc" \
241 "${srcdir}/util/*/*/*/*.hpp" \
242 "${srcdir}/util/*/*/*/*/*.h" \
243 "${srcdir}/util/*/*/*/*/*.cc" \
244 "${srcdir}/util/*/*/*/*/*.tcc" \
245 "${srcdir}/util/*/*/*/*/*.hpp" ] {
246 # Remove everything up to "util/..."
247 set dst [string range $src [string length "${srcdir}/"] end]
248 # Create the directory containing the file.
249 set dir [file dirname $dst]
250 remote_exec host "mkdir" [list "-p" "$dir"]
252 set result [remote_download host $src $dst]
253 if { $result == "" } {
254 verbose -log "Unable to download ${srcdir}/${src} to host."
258 set includes "-Iutil"
259 } elseif { [file exists $flags_file] } {
260 # If we find a testsuite_flags file, we're testing in the build dir.
261 set cxx [exec sh $flags_file --build-cxx]
262 set cxxflags [exec sh $flags_file --cxxflags]
263 set cxxpchflags [exec sh $flags_file --cxxpchflags]
264 set cxxldflags [exec sh $flags_file --cxxldflags]
265 set cc [exec sh $flags_file --build-cc]
266 set includes [exec sh $flags_file --build-includes]
269 append cxxflags [getenv CXXFLAGS]
272 # Always use MO files built by this test harness.
273 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
274 set ccflags "$cxxflags -DLOCALEDIR=\".\""
276 # If a PCH file is available, use it. We must delay performing
277 # this check until $cxx and such have been initialized because we
278 # perform a test compilation. (Ideally, gcc --print-file-name would
279 # list PCH files, but it does not.)
280 if { $cxxpchflags != "" } {
281 set src "config[pid].cc"
282 set f [open $src "w"]
283 puts $f "int main () {}"
286 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
287 # useful as then the requested variant of the pre-build PCH
288 # files could be tested to see if it works.
289 set lines [v3_target_compile $src "config[pid].o" object \
290 "additional_flags=-include additional_flags=bits/stdc++.h"]
291 if { $lines != "" } {
292 verbose -log "Requested PCH file: $cxxpchflags"
293 verbose -log "is not working, and will not be used."
298 v3track cxxpchflags 2
301 if ![info exists PCH_CXXFLAGS] then {
302 set PCH_CXXFLAGS $cxxpchflags
303 v3track PCH_CXXFLAGS 2
306 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
309 # Callback for cleanup routines.
310 proc libstdc++_exit { } {
313 if [info exists gluefile] {
314 file_on_build delete $gluefile;
319 # Callback from system dg-test.
320 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
321 # Set up the compiler flags, based on what we're going to do.
324 set compile_type "preprocess"
325 set output_file "[file rootname [file tail $prog]].i"
328 set compile_type "assembly"
329 set output_file "[file rootname [file tail $prog]].s"
332 set compile_type "object"
333 set output_file "[file rootname [file tail $prog]].o"
336 set compile_type "executable"
337 set output_file "./[file rootname [file tail $prog]].exe"
340 set compile_type "executable"
341 # FIXME: "./" is to cope with "." not being in $PATH.
342 # Should this be handled elsewhere?
344 set output_file "./[file rootname [file tail $prog]].exe"
345 # This is the only place where we care if an executable was
346 # created or not. If it was, dg.exp will try to run it.
347 catch { remote_file build delete $output_file }
350 perror "$do_what: not a valid dg-do keyword"
355 # Short-circut a bunch of complicated goo here for the special
356 # case of compiling a test file as a "C" file, not as C++. Why? So
357 # -nostdc++ doesn't trip us up. So all the extra object files
358 # don't trip us up. So automatically linking in libstdc++ doesn't
359 # happen. So CXXFLAGS don't error.
360 set select_compile "v3_target_compile"
362 if { $extra_tool_flags != "" } {
363 verbose -log "extra_tool_flags are:"
364 verbose -log $extra_tool_flags
365 if { [string first "-x c" $extra_tool_flags ] != -1 } {
366 verbose -log "compiling and executing as C, not C++"
367 set edit_tool_flags $extra_tool_flags
368 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
369 lappend options "additional_flags=$edit_tool_flags"
370 set select_compile "v3_target_compile_as_c"
372 lappend options "additional_flags=$extra_tool_flags"
376 # There is a libstdc++_compile made for us by default (via the tool-
377 # and-target file), but the defaults are lacking in goodness.
378 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
380 return [list $comp_output $output_file]
383 # Override the DejaGnu dg-test in order to clear flags after a test, as
384 # is done for compiler tests in gcc-dg.exp.
386 if { [info procs saved-dg-test] == [list] } {
387 rename dg-test saved-dg-test
389 proc dg-test { args } {
390 global additional_prunes
393 if { [ catch { eval saved-dg-test $args } errmsg ] } {
394 set saved_info $errorInfo
395 set additional_prunes ""
397 error $errmsg $saved_info
399 set additional_prunes ""
404 # True if the library supports wchar_t.
407 # True if the library supports threads.
410 # True if the library supports symbol versioning.
413 # Called from libstdc++-dg-test above. Calls back into system's
414 # target_compile to actually do the work.
415 proc v3_target_compile { source dest type options } {
422 global STATIC_LIBCXXFLAGS
424 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
425 lappend options "libs=${gluefile}"
426 lappend options "ldflags=${wrap_flags}"
430 set cxxlibglossflags [libgloss_link_flags]
431 set cxx_final [concat $cxx_final $cxxlibglossflags]
432 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
433 set cxx_final [concat $cxx_final $cxxflags]
434 set cxx_final [concat $cxx_final $includes]
436 # Flag setting based on type argument.
437 if { $type == "executable" } {
438 # Link the support objects into executables.
439 lappend options "additional_flags=./libtestc++.a $cxxldflags"
441 if { $type == "sharedlib" } {
442 # Don't link in anything.
443 set type "executable"
447 lappend options "compiler=$cxx_final"
448 lappend options "timeout=[timeout_value]"
450 return [target_compile $source $dest $type $options]
454 # Called from libstdc++-dg-test above, but only for "C" compilation.
455 # Calls back into system's target_compile to actually do the work.
456 proc v3_target_compile_as_c { source dest type options } {
464 global STATIC_LIBCXXFLAGS
466 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
467 lappend options "libs=${gluefile}"
468 lappend options "ldflags=${wrap_flags}"
471 set tname [target_info name]
473 set cxxlibglossflags [libgloss_link_flags]
474 set cc_final [concat $cc_final $cxxlibglossflags]
475 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
476 set cc_final [concat $cc_final $cxxflags]
477 set cc_final [concat $cc_final $includes]
478 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
480 # This is needed for "C" tests, as this type of test may need the
481 # C++ includes. And if we're not testing in the build directory,
482 # the includes variable is not likely to include the necessary
484 if { ![file exists $flags_file] } {
485 # ??? We need a --print-include-dirs option to GCC, so that
486 # we can avoid these hacks. The heuristics here will not
487 # work with non-standard --with-includedir= options.
488 set version [remote_exec host ${cc} -dumpversion]
489 # Remove the trailing newline from the output.
490 set version [string trimright [lindex $version 1]]
491 set machine [remote_exec host ${cc} -dumpmachine]
492 set machine [string trimright [lindex $machine 1]]
493 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
494 set comp_base_dir [lindex $comp_base_dir 1]
495 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
496 # For a cross compiler, the header files will be located in a
497 # machine-specific subdirectory.
498 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
499 set crosstarget "${crossbase}/${machine}"
500 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
501 # For a native compiler, the header files will be located at
503 set includesbase "${comp_base_dir}/include/c++/${version}"
504 set includestarget "${includesbase}/${machine}"
505 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
507 set libdir "-L${comp_base_dir}/lib"
509 set libdir "-L${blddir}/libsupc++/.libs"
510 set libdir [concat $libdir "-L${blddir}/src/.libs"]
513 set cc_final [concat $cc_final "$libdir"]
515 lappend options "compiler=$cc_final"
516 lappend options "timeout=[timeout_value]"
518 return [target_compile $source $dest $type $options]
521 # Build the support objects linked in with the libstdc++ tests. In
522 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
523 proc v3-build_support { } {
531 # Figure out whether or not the library supports certain features.
537 set config_src "config.cc"
538 set config_out "config.ii"
539 set f [open $config_src "w"]
540 puts $f "#include <bits/c++config.h>"
541 puts $f "#include <bits/gthr.h>"
543 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
544 set file [open $config_out r]
545 set preprocessed [read $file]
547 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
548 verbose -log "wchar_t support detected"
551 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
552 verbose -log "symbol versioning support detected"
555 if { [string first "__GTHREADS" $preprocessed] != -1 } {
556 verbose -log "thread support detected"
560 # Try to build the MO files that are used by some of the locale
561 # tests. If we can't build them, that's OK; it just means that
562 # those tests will fail.
563 foreach lang [list "fr" "de"] {
565 file mkdir "$lang/LC_MESSAGES"
566 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
567 if [is_remote host] {
568 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
569 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
574 # Build the support objects.
575 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
576 testsuite_character.cc testsuite_hooks.cc \
577 io/verified_cmd_line_input.cc \
578 io/prog_bar.cc performance/time/elapsed_timer.cc ]
579 foreach f $source_files {
580 set obj [file rootname $f].o
581 set object_file [file tail $obj]
582 # Compile with "-w" so that warnings issued by the compiler
583 # do not prevent compilation.
584 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
585 [list "incdir=$srcdir" "additional_flags=-w"]]
587 error "could not compile $f"
589 append libtest_objs "$object_file "
592 # Collect into libtestc++.a
593 # Delete libtestc++.a first. Mixed 32 and 64-bit archives cannot be
595 # Use same procedure as gcc-dg.exp (remove-build-file).
596 if [is_remote host] {
597 # Ensure the host knows the file is gone by deleting there
599 remote_file host delete "./libtestc++.a"
601 remote_file build delete "./libtestc++.a"
602 if [info exists env(AR)] {
605 set ar [transform "ar"]
607 set arargs "-rc ./libtestc++.a ${libtest_objs}"
608 verbose -log "$ar $arargs"
609 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
610 verbose "link result is $result"
611 if { $result == 0 } {
612 if [info exists env(RANLIB)] {
613 set ranlib $env(RANLIB)
615 set ranlib [transform "ranlib"]
617 set ranlibargs "./libtestc++.a"
618 verbose -log "$ranlib $ranlibargs"
619 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
620 if { $result != 0 } {
621 error "could not link libtestc++.a"
625 # Build any shared objects needed for regression testing.
626 if { ${v3-sharedlib} == 1 } {
627 set source_files [list testsuite_shared.cc]
628 foreach f $source_files {
629 set object_file [file rootname $f].so
630 # Compile with "-w" so that warnings issued by the compiler
631 # do not prevent compilation.
632 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
633 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
635 error "could not compile $f"
641 proc check_v3_target_fileio { } {
642 global et_fileio_saved
643 global et_fileio_target_name
647 if { ![info exists et_fileio_target_name] } {
648 set et_fileio_target_name ""
651 # If the target has changed since we set the cached value, clear it.
652 set current_target [current_target_name]
653 if { $current_target != $et_fileio_target_name } {
654 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
655 set et_fileio_target_name $current_target
656 if [info exists et_fileio_saved] {
657 verbose "check_v3_target_fileio: removing cached result" 2
658 unset et_fileio_saved
662 if [info exists et_fileio_saved] {
663 verbose "check_v3_target_fileio: using cached result" 2
665 set et_fileio_saved 0
667 # Set up, compile, and execute a C++ test program that tries to use
669 set src fileio[pid].cc
670 set exe fileio[pid].x
671 set testfile "cin_unget-1.txt"
672 v3-copy-files "$srcdir/data/$testfile"
674 set f [open $src "w"]
675 puts $f "#include <sys/types.h>"
676 puts $f "#include <sys/stat.h>"
677 puts $f "#include <fcntl.h>"
678 puts $f "#include <unistd.h>"
679 puts $f "#include <errno.h>"
680 puts $f "#include <string.h>"
681 puts $f "using namespace std;"
682 puts $f "int main ()"
684 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
685 puts $f " int ret = 0;"
686 puts $f " char buf\[10\];"
687 puts $f " if (fd == -1)"
691 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
693 puts $f " errno = 0;"
694 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
695 puts $f " || read (fd, buf, 4) != 4"
696 puts $f " || memcmp (buf, \"1234\", 4) != 0"
697 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
698 puts $f " || read (fd, buf, 2) != 2"
699 puts $f " || memcmp (buf, \"34\", 2) != 0)"
701 puts $f " close (fd);"
703 puts $f " return ret;"
707 set lines [v3_target_compile $src $exe executable ""]
710 if [string match "" $lines] {
711 # No error message, compilation succeeded.
712 set result [${tool}_load "./$exe" "" ""]
713 set status [lindex $result 0]
714 remote_file build delete $exe
716 verbose "check_v3_target_fileio: status is <$status>" 2
718 if { $status == "pass" } {
719 set et_fileio_saved 1
722 verbose "check_v3_target_fileio: compilation failed" 2
725 return $et_fileio_saved
728 # Eventually we want C90/C99 determining and switching from this.
729 proc check_v3_target_c_std { } {
730 global et_c_std_saved
731 global et_c_std_target_name
734 if { ![info exists et_c_std_target_name] } {
735 set et_c_std_target_name ""
738 # If the target has changed since we set the cached value, clear it.
739 set current_target [current_target_name]
740 if { $current_target != $et_c_std_target_name } {
741 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
742 set et_c_std_target_name $current_target
743 if [info exists et_c_std_saved] {
744 verbose "check_v3_target_c_std: removing cached result" 2
749 if [info exists et_c_std_saved] {
750 verbose "check_v3_target_c_std: using cached result" 2
754 # Set up, compile, and execute a C++ test program that tries to use
756 # For math bits, could use check_effective_target_c99_math.
757 set src fileio[pid].cc
758 set exe fileio[pid].x
760 set f [open $src "w"]
761 puts $f "#include <tr1/cmath>"
762 puts $f "#include <cstdlib>"
763 puts $f "int main ()"
765 puts $f " float f = 45.55;"
766 puts $f " int i = std::tr1::isnan(f);"
768 puts $f " using std::wctomb;"
773 set lines [v3_target_compile $src $exe executable ""]
776 if [string match "" $lines] {
777 # No error message, compilation succeeded.
778 set result [${tool}_load "./$exe" "" ""]
779 set status [lindex $result 0]
780 remote_file build delete $exe
782 verbose "check_v3_target_c_std: status is <$status>" 2
784 if { $status == "pass" } {
788 verbose "check_v3_target_c_std: compilation failed" 2
791 return $et_c_std_saved
794 proc check_v3_target_sharedlib { } {
796 return ${v3-sharedlib}
799 proc check_v3_target_time { } {
801 global et_time_target_name
804 if { ![info exists et_time_target_name] } {
805 set et_time_target_name ""
808 # If the target has changed since we set the cached value, clear it.
809 set current_target [current_target_name]
810 if { $current_target != $et_time_target_name } {
811 verbose "check_v3_target_time: `$et_time_target_name'" 2
812 set et_time_target_name $current_target
813 if [info exists et_time_saved] {
814 verbose "check_v3_target_time: removing cached result" 2
819 if [info exists et_time_saved] {
820 verbose "check_v3_target_time: using cached result" 2
824 # Set up and compile a C++ test program that tries to use
828 set f [open $src "w"]
829 puts $f "#include <time.h>"
830 puts $f "using namespace std;"
831 puts $f "int main ()"
837 set lines [v3_target_compile $src /dev/null executable ""]
840 if [string match "" $lines] {
841 # No error message, compilation succeeded.
842 verbose "check_v3_target_time: compilation succeeded" 2
845 verbose "check_v3_target_time: compilation failed" 2
848 return $et_time_saved
851 proc check_v3_target_namedlocale { args } {
852 global et_namedlocale
857 # Set up, compile, and execute a C++ test program that tries to use
858 # the required named locale.
859 set exe nlocale[pid].x
861 if ![file exists ./$exe] {
862 set src nlocale[pid].cc
864 set f [open $src "w"]
865 puts $f "#include <locale>"
866 puts $f "#include <cstdio>"
867 puts $f "using namespace std;"
868 puts $f "int main (int argc, char** argv)"
872 puts $f " locale(*(argv + 1));"
875 puts $f " catch(...)"
877 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
883 set lines [v3_target_compile $src $exe executable ""]
886 if ![string match "" $lines] {
887 verbose "check_v3_target_namedlocale: compilation failed" 2
888 return $et_namedlocale
890 # else No error message, compilation succeeded.
893 set result [${tool}_load "./$exe" "$args" ""]
894 set status [lindex $result 0]
896 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
898 if { $status == "pass" } {
901 return $et_namedlocale
904 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 preprocess a C++ test program that depends
929 # on debug mode activated.
930 set src debug_mode[pid].cc
932 set f [open $src "w"]
933 puts $f "#ifndef _GLIBCXX_DEBUG"
934 puts $f "# error No debug mode"
938 set lines [v3_target_compile $src /dev/null preprocess ""]
941 if [string match "" $lines] {
942 # No error message, preprocessing succeeded.
946 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
947 return $et_debug_mode
950 proc check_v3_target_profile_mode { } {
951 global et_profile_mode
954 if { ![info exists et_profile_mode_target_name] } {
955 set et_profile_mode_target_name ""
958 # If the target has changed since we set the cached value, clear it.
959 set current_target [current_target_name]
960 if { $current_target != $et_profile_mode_target_name } {
961 verbose "check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
962 set et_profile_mode_target_name $current_target
963 if [info exists et_profile_mode] {
964 verbose "check_v3_target_profile_mode: removing cached result" 2
965 unset et_profile_mode
969 if [info exists et_profile_mode] {
970 verbose "check_v3_target_profile_mode: using cached result" 2
972 set et_profile_mode 0
974 # Set up and preprocess a C++ test program that depends
975 # on profile mode activated.
976 set src profile_mode[pid].cc
978 set f [open $src "w"]
979 puts $f "#ifndef _GLIBCXX_PROFILE"
980 puts $f "# error No profile mode"
984 set lines [v3_target_compile $src /dev/null preprocess ""]
987 if [string match "" $lines] {
988 # No error message, preprocessing succeeded.
989 set et_profile_mode 1
992 verbose "check_v3_target_profile_mode: $et_profile_mode" 2
993 return $et_profile_mode
996 proc check_v3_target_normal_mode { } {
997 global et_normal_mode
1000 if { ![info exists et_normal_mode_target_name] } {
1001 set et_normal_mode_target_name ""
1004 # If the target has changed since we set the cached value, clear it.
1005 set current_target [current_target_name]
1006 if { $current_target != $et_normal_mode_target_name } {
1007 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1008 set et_normal_mode_target_name $current_target
1009 if [info exists et_normal_mode] {
1010 verbose "check_v3_target_normal_mode: removing cached result" 2
1011 unset et_normal_mode
1015 if [info exists et_normal_mode] {
1016 verbose "check_v3_target_normal_mode: using cached result" 2
1018 set et_normal_mode 0
1020 # Set up and compile a C++ test program that depends
1021 # on normal mode activated.
1022 set src normal_mode[pid].cc
1024 set f [open $src "w"]
1025 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1026 puts $f "# error No normal mode"
1030 set lines [v3_target_compile $src /dev/null preprocess ""]
1033 if [string match "" $lines] {
1034 # No error message, compilation succeeded.
1035 set et_normal_mode 1
1038 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
1039 return $et_normal_mode
1042 proc check_v3_target_parallel_mode { } {
1045 global et_parallel_mode
1049 if { ![info exists et_parallel_mode_target_name] } {
1050 set et_parallel_mode_target_name ""
1053 # If the target has changed since we set the cached value, clear it.
1054 set current_target [current_target_name]
1055 if { $current_target != $et_parallel_mode_target_name } {
1056 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1057 set et_parallel_mode_target_name $current_target
1058 if [info exists et_parallel_mode] {
1059 verbose "check_v3_target_parallel_mode: removing cached result" 2
1060 unset et_parallel_mode
1064 if [info exists et_parallel_mode] {
1065 verbose "check_v3_target_parallel_mode: using cached result" 2
1067 set et_parallel_mode 0
1069 # If 'make check-parallel' is running the test succeeds.
1070 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1071 set et_parallel_mode 1
1074 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1075 return $et_parallel_mode
1078 proc check_v3_target_cstdint { } {
1080 global DEFAULT_CXXFLAGS
1085 if { ![info exists et_cstdint_target_name] } {
1086 set et_cstdint_target_name ""
1089 # If the target has changed since we set the cached value, clear it.
1090 set current_target [current_target_name]
1091 if { $current_target != $et_cstdint_target_name } {
1092 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1093 set et_cstdint_target_name $current_target
1094 if [info exists et_cstdint] {
1095 verbose "check_v3_target_cstdint: removing cached result" 2
1100 if [info exists et_cstdint] {
1101 verbose "check_v3_target_cstdint: using cached result" 2
1105 # Set up and preprocess a C++0x test program that depends
1106 # on the C99 stdint facilities to be available.
1107 set src cstdint[pid].cc
1109 set f [open $src "w"]
1110 puts $f "#include <tr1/cstdint>"
1111 puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1112 puts $f "# error No C99 stdint"
1116 set cxxflags_saved $cxxflags
1117 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1119 set lines [v3_target_compile $src /dev/null preprocess ""]
1120 set cxxflags $cxxflags_saved
1123 if [string match "" $lines] {
1124 # No error message, preprocess succeeded.
1127 verbose "check_v3_target_cstdint: compilation failed" 2
1130 verbose "check_v3_target_cstdint: $et_cstdint" 2
1134 proc check_v3_target_cmath { } {
1136 global DEFAULT_CXXFLAGS
1141 if { ![info exists et_c99_math_target_name] } {
1142 set et_c99_math_target_name ""
1145 # If the target has changed since we set the cached value, clear it.
1146 set current_target [current_target_name]
1147 if { $current_target != $et_c99_math_target_name } {
1148 verbose "check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1149 set et_c99_math_target_name $current_target
1150 if [info exists et_c99_math] {
1151 verbose "check_v3_target_c99_math: removing cached result" 2
1156 if [info exists et_c99_math] {
1157 verbose "check_v3_target_c99_math: using cached result" 2
1161 # Set up and preprocess a C++0x test program that depends
1162 # on the C99 math facilities to be available.
1163 set src c99_math[pid].cc
1165 set f [open $src "w"]
1166 puts $f "#include <tr1/cmath>"
1167 puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1168 puts $f "# error No C99 math"
1172 set cxxflags_saved $cxxflags
1173 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1175 set lines [v3_target_compile $src /dev/null preprocess ""]
1176 set cxxflags $cxxflags_saved
1179 if [string match "" $lines] {
1180 # No error message, preprocess succeeded.
1183 verbose "check_v3_target_c99_math: compilation failed" 2
1186 verbose "check_v3_target_c99_math: $et_c99_math" 2
1190 proc check_v3_target_atomic_builtins { } {
1192 global DEFAULT_CXXFLAGS
1193 global et_atomic_builtins
1197 if { ![info exists et_atomic_builtins_target_name] } {
1198 set et_atomic_builtins_target_name ""
1201 # If the target has changed since we set the cached value, clear it.
1202 set current_target [current_target_name]
1203 if { $current_target != $et_atomic_builtins_target_name } {
1204 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1205 set et_atomic_builtins_target_name $current_target
1206 if [info exists et_atomic_builtins] {
1207 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1208 unset et_atomic_builtins
1212 if [info exists et_atomic_builtins] {
1213 verbose "check_v3_target_atomic_builtins: using cached result" 2
1215 set et_atomic_builtins 0
1217 # Set up and preprocess a C++0x test program that depends
1218 # on the atomic builtin facilities to be available.
1219 set src atomic_builtins[pid].cc
1221 set f [open $src "w"]
1222 puts $f "#include <bits/c++config.h>"
1223 puts $f "#ifndef _GLIBCXX_ATOMIC_BUILTINS_4"
1224 puts $f "# error No atomic builtins"
1228 set cxxflags_saved $cxxflags
1229 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1231 set lines [v3_target_compile $src /dev/null preprocess ""]
1232 set cxxflags $cxxflags_saved
1235 if [string match "" $lines] {
1236 # No error message, preprocess succeeded.
1237 set et_atomic_builtins 1
1239 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1242 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1243 return $et_atomic_builtins
1246 proc check_v3_target_gthreads { } {
1248 global DEFAULT_CXXFLAGS
1253 if { ![info exists et_gthreads_target_name] } {
1254 set et_gthreads_target_name ""
1257 # If the target has changed since we set the cached value, clear it.
1258 set current_target [current_target_name]
1259 if { $current_target != $et_gthreads_target_name } {
1260 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1261 set et_gthreads_target_name $current_target
1262 if [info exists et_gthreads] {
1263 verbose "check_v3_target_gthreads: removing cached result" 2
1268 if [info exists et_gthreads] {
1269 verbose "check_v3_target_gthreads: using cached result" 2
1273 # Set up and preprocess a C++0x test program that depends
1274 # on the gthreads facilities to be available.
1275 set src gthreads[pid].cc
1277 set f [open $src "w"]
1278 puts $f "#include <bits/c++config.h>"
1279 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1280 puts $f "# error No gthread"
1284 set cxxflags_saved $cxxflags
1285 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1287 set lines [v3_target_compile $src /dev/null preprocess ""]
1288 set cxxflags $cxxflags_saved
1291 if [string match "" $lines] {
1292 # No error message, preprocessing succeeded.
1295 verbose "check_v3_target_gthreads: compilation failed" 2
1298 verbose "check_v3_target_gthreads: $et_gthreads" 2
1302 proc check_v3_target_gthreads_timed { } {
1304 global DEFAULT_CXXFLAGS
1305 global et_gthreads_timed
1309 if { ![info exists et_gthreads_timed_target_name] } {
1310 set et_gthreads_timed_target_name ""
1313 # If the target has changed since we set the cached value, clear it.
1314 set current_target [current_target_name]
1315 if { $current_target != $et_gthreads_timed_target_name } {
1316 verbose "check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1317 set et_gthreads_timed_target_name $current_target
1318 if [info exists et_gthreads_timed] {
1319 verbose "check_v3_target_gthreads_timed: removing cached result" 2
1320 unset et_gthreads_timed
1324 if [info exists et_gthreads_timed] {
1325 verbose "check_v3_target_gthreads_timed: using cached result" 2
1327 set et_gthreads_timed 0
1329 # Set up and preprocess a C++0x test program that depends
1330 # on the gthreads timed mutex facilities to be available.
1331 set src gthreads_timed[pid].cc
1333 set f [open $src "w"]
1334 puts $f "#include <bits/c++config.h>"
1335 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1336 puts $f "# error No gthread"
1338 puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1339 puts $f "# error No gthread timed mutexes"
1343 set cxxflags_saved $cxxflags
1344 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1346 set lines [v3_target_compile $src /dev/null preprocess ""]
1347 set cxxflags $cxxflags_saved
1350 if [string match "" $lines] {
1351 # No error message, preprocessing succeeded.
1352 set et_gthreads_timed 1
1354 verbose "check_v3_target_gthreads_timed: compilation failed" 2
1357 verbose "check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1358 return $et_gthreads_timed
1362 proc check_v3_target_nanosleep { } {
1364 global DEFAULT_CXXFLAGS
1369 if { ![info exists et_nanosleep_target_name] } {
1370 set et_nanosleep_target_name ""
1373 # If the target has changed since we set the cached value, clear it.
1374 set current_target [current_target_name]
1375 if { $current_target != $et_nanosleep_target_name } {
1376 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1377 set et_nanosleep_target_name $current_target
1378 if [info exists et_nanosleep] {
1379 verbose "check_v3_target_nanosleep: removing cached result" 2
1384 if [info exists et_nanosleep] {
1385 verbose "check_v3_target_nanosleep: using cached result" 2
1389 # Set up and preprocess a C++0x test program that depends
1390 # on the nanosleep facilities to be available.
1391 set src nanosleep[pid].cc
1393 set f [open $src "w"]
1394 puts $f "#include <bits/c++config.h>"
1395 puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP"
1396 puts $f "# error No nanosleep"
1400 set cxxflags_saved $cxxflags
1401 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1403 set lines [v3_target_compile $src /dev/null preprocess ""]
1404 set cxxflags $cxxflags_saved
1407 if [string match "" $lines] {
1408 # No error message, preprocessing succeeded.
1411 verbose "check_v3_target_nanosleep: compilation failed" 2
1414 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1415 return $et_nanosleep
1418 proc check_v3_target_sched_yield { } {
1420 global DEFAULT_CXXFLAGS
1421 global et_sched_yield
1425 if { ![info exists et_sched_yield_target_name] } {
1426 set et_sched_yield_target_name ""
1429 # If the target has changed since we set the cached value, clear it.
1430 set current_target [current_target_name]
1431 if { $current_target != $et_sched_yield_target_name } {
1432 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1433 set et_sched_yield_target_name $current_target
1434 if [info exists et_sched_yield] {
1435 verbose "check_v3_target_sched_yield: removing cached result" 2
1436 unset et_sched_yield
1440 if [info exists et_sched_yield] {
1441 verbose "check_v3_target_sched_yield: using cached result" 2
1443 set et_sched_yield 0
1445 # Set up and preprocess a C++0x test program that depends
1446 # on the sched_yield facility to be available.
1447 set src sched_yield[pid].cc
1449 set f [open $src "w"]
1450 puts $f "#include <bits/c++config.h>"
1451 puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD"
1452 puts $f "# error No sched yield"
1456 set cxxflags_saved $cxxflags
1457 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1459 set lines [v3_target_compile $src /dev/null preprocess ""]
1460 set cxxflags $cxxflags_saved
1463 if [string match "" $lines] {
1464 # No error message, preprocessing succeeded.
1465 set et_sched_yield 1
1467 verbose "check_v3_target_sched_yield: compilation failed" 2
1470 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1471 return $et_sched_yield
1474 proc check_v3_target_string_conversions { } {
1476 global DEFAULT_CXXFLAGS
1477 global et_string_conversions
1481 if { ![info exists et_string_conversions_target_name] } {
1482 set et_string_conversions_target_name ""
1485 # If the target has changed since we set the cached value, clear it.
1486 set current_target [current_target_name]
1487 if { $current_target != $et_string_conversions_target_name } {
1488 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1489 set et_string_conversions_target_name $current_target
1490 if [info exists et_string_conversions] {
1491 verbose "check_v3_target_string_conversions: removing cached result" 2
1492 unset et_string_conversions
1496 if [info exists et_string_conversions] {
1497 verbose "check_v3_target_string_conversions: using cached result" 2
1499 set et_string_conversions 0
1501 # Set up and preprocess a C++0x test program that depends
1502 # on the string_conversions facilities to be available.
1503 set src string_conversions[pid].cc
1505 set f [open $src "w"]
1506 puts $f "#include <bits/c++config.h>"
1507 puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1508 puts $f "# error No string conversions"
1512 set cxxflags_saved $cxxflags
1513 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1515 set lines [v3_target_compile $src /dev/null preprocess ""]
1516 set cxxflags $cxxflags_saved
1519 if [string match "" $lines] {
1520 # No error message, preprocessing succeeded.
1521 set et_string_conversions 1
1523 verbose "check_v3_target_string_conversions: compilation failed" 2
1526 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1527 return $et_string_conversions
1530 proc check_v3_target_swprintf { } {
1532 global DEFAULT_CXXFLAGS
1537 if { ![info exists et_swprintf_target_name] } {
1538 set et_swprintf_target_name ""
1541 # If the target has changed since we set the cached value, clear it.
1542 set current_target [current_target_name]
1543 if { $current_target != $et_swprintf_target_name } {
1544 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1545 set et_swprintf_target_name $current_target
1546 if [info exists et_swprintf] {
1547 verbose "check_v3_target_swprintf: removing cached result" 2
1552 if [info exists et_swprintf] {
1553 verbose "check_v3_target_swprintf: using cached result" 2
1557 # Set up and preprocess a C++0x test program that depends
1558 # on a standard swprintf function to be available.
1559 set src swprintf[pid].cc
1561 set f [open $src "w"]
1562 puts $f "#include <bits/c++config.h>"
1563 puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1564 puts $f "# error No swprintf"
1568 set cxxflags_saved $cxxflags
1569 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1571 set lines [v3_target_compile $src /dev/null preprocess ""]
1572 set cxxflags $cxxflags_saved
1575 if [string match "" $lines] {
1576 # No error message, preprocessing succeeded.
1579 verbose "check_v3_target_swprintf: compilation failed" 2
1582 verbose "check_v3_target_swprintf: $et_swprintf" 2
1586 proc check_v3_target_binary_io { } {
1588 global DEFAULT_CXXFLAGS
1593 if { ![info exists et_binary_io_target_name] } {
1594 set et_binary_io_target_name ""
1597 # If the target has changed since we set the cached value, clear it.
1598 set current_target [current_target_name]
1599 if { $current_target != $et_binary_io_target_name } {
1600 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1601 set et_binary_io_target_name $current_target
1602 if [info exists et_binary_io] {
1603 verbose "check_v3_target_binary_io: removing cached result" 2
1608 if [info exists et_binary_io] {
1609 verbose "check_v3_target_binary_io: using cached result" 2
1613 # Set up and preprocess a C++0x test program that depends
1614 # on text and binary I/O being the same.
1615 set src binary_io[pid].cc
1617 set f [open $src "w"]
1618 puts $f "#include <bits/c++config.h>"
1619 puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1620 puts $f "# error No binary io"
1624 set cxxflags_saved $cxxflags
1625 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1627 set lines [v3_target_compile $src /dev/null preprocess ""]
1628 set cxxflags $cxxflags_saved
1631 if [string match "" $lines] {
1632 # No error message, preprocessing succeeded.
1635 verbose "check_v3_target_binary_io: compilation failed" 2
1638 verbose "check_v3_target_binary_io: $et_binary_io" 2
1639 return $et_binary_io
1642 proc check_v3_target_nprocs { } {
1644 global DEFAULT_CXXFLAGS
1649 if { ![info exists et_nprocs_target_name] } {
1650 set et_nprocs_target_name ""
1653 # If the target has changed since we set the cached value, clear it.
1654 set current_target [current_target_name]
1655 if { $current_target != $et_nprocs_target_name } {
1656 verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1657 set et_nprocs_target_name $current_target
1658 if [info exists et_nprocs] {
1659 verbose "check_v3_target_nprocs: removing cached result" 2
1664 if [info exists et_nprocs] {
1665 verbose "check_v3_target_nprocs: using cached result" 2
1669 # Set up and preprocess a C++0x test program that depends
1670 # on either get_nprocs or sysconf to be available.
1671 set src nprocs[pid].cc
1673 set f [open $src "w"]
1674 puts $f "#include <bits/c++config.h>"
1675 puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
1676 puts $f "#elif defined(_GLIBCXX_USE_SYSCONF)"
1677 puts $f "# include <unistd.h>"
1678 puts $f "# if !defined(_SC_NPROCESSORS_ONLN)"
1679 puts $f "# error No sysconf option"
1682 puts $f "# error No get_nprocs or sysconf"
1686 set cxxflags_saved $cxxflags
1687 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1689 set lines [v3_target_compile $src /dev/null preprocess ""]
1690 set cxxflags $cxxflags_saved
1693 if [string match "" $lines] {
1694 # No error message, preprocess succeeded.
1697 verbose "check_v3_target_nprocs: compilation failed" 2
1700 verbose "check_v3_target_nprocs: $et_nprocs" 2
1705 set additional_prunes ""