1 # libstdc
++ "tool init file" for DejaGNU
3 # Copyright
(C
) 2001-2017 Free Software Foundation
, Inc.
5 # This
program is free software
; you can redistribute it and
/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # This
program is distributed in the hope that it will be useful
,
11 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this
program; see the file COPYING3.
If not see
17 #
<http
://www.gnu.org
/licenses
/>.
20 #
Define callbacks and
load other libraries. This file is loaded relatively
21 # early
, and before
any other file we write ourselves.
"load_lib" will
22 # find anything in the DejaGNU installation tree
, or in our lib directory.
23 #
"load_gcc_lib" will search the core compiler's .exp collection instead.
25 # The naming rule is that dg.exp looks
for "tool-" and runtest.exp looks
26 #
for "tool_" when finding callbacks. Utility routines we define for
27 # our callbacks begin with
"v3-".
29 # libstdc
++_
* callbacks we don
't define, but could:
30 # ..._option_help prints additional --help output
31 # ..._option_proc (--foo) process our own options
32 # ..._init (normal.exp) called once per test file
33 # ..._finish bracketing function for libstdc++_init
34 # ...-dg-prune removing output text, see top of system dg.exp
36 # Useful hook: if ${hostname}_init exists, it will be called, almost
37 # the last thing before testing begins. This can be defined in, e.g.,
38 # ~/.dejagnurc or $DEJAGNU.
40 proc load_gcc_lib { filename } {
41 global srcdir loaded_libs
43 load_file $srcdir/../../gcc/testsuite/lib/$filename
44 set loaded_libs($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
60 load_gcc_lib target-utils.exp
62 # Useful for debugging. Pass the name of a variable and the verbosity
63 # threshold (number of -v's
on the command line
).
64 proc v3track
{ var n
} {
66 verbose
"++ $var is $val" $n
69 # Copy file to the target.
70 proc v3
-copy
-file
{src dst
} {
71 if { [catch
{ set symlink
[file readlink $src
] } x
] } then {
72 remote_download target $src $dst
74 if { [regexp
"^/" "$symlink"] } then {
75 remote_download target $symlink $dst
77 set dirname
[file dirname $f
]
78 remote_download target $dirname
/$symlink $dst
83 # Called by v3
-init below.
"Static" to this file.
84 proc v3
-copy
-files
{srcfiles
} {
86 v3
-copy
-file $f
[file tail $f
]
90 # Called once
, during runtest.exp setup.
91 proc libstdc
++_init
{ testfile
} {
93 global v3
-sharedlib v3
-libgomp
94 global srcdir blddir objdir tool_root_dir
95 global cc cxx cxxflags cxxpchflags cxxldflags cxxvtvflags
97 global gluefile wrap_flags
98 global ld_library_path
102 global DEFAULT_CXXFLAGS
103 global STATIC_LIBCXXFLAGS
105 # We
set LC_ALL and LANG to C so that we
get the same error
106 # messages as expected.
110 # LANGUAGE changes the behavior of GNU gettext
(3) and causes
111 # std
::messages tests to fail.
112 array unset env LANGUAGE
114 # Many hosts now default to a non
-ASCII C locale
, however
, so
115 # they can
set a
charset encoding here
if they need.
116 if { [ishost
"*-*-cygwin*"] } {
117 setenv LC_ALL C.ASCII
121 set blddir
[lookfor_file
[get_multilibs
] libstdc
++-v3
]
122 set flags_file
"${blddir}/scripts/testsuite_flags"
123 set shlib_ext
[get_shlib_extension
]
126 #
If a test doesn
't have special options, use DEFAULT_CXXFLAGS.
127 # Use this variable if the behavior
128 # 1) only applies to libstdc++ testing
129 # 2) might need to be negated
130 # In particular, some tests have to be run without precompiled
131 # headers, or without assertions.
133 if ![info exists DEFAULT_CXXFLAGS] then {
134 set DEFAULT_CXXFLAGS ""
135 # Host specific goo here.
136 if { [string match "powerpc-*-darwin*" $target_triplet] } {
137 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
139 if { [string match "powerpc-ibm-aix*" $target_triplet] } {
140 append DEFAULT_CXXFLAGS " -Wl,-bmaxdata:0x20000000"
143 v3track DEFAULT_CXXFLAGS 2
145 # By default, we assume we want to run program images.
146 global dg-do-what-default
147 set dg-do-what-default run
149 # Copy any required data files.
150 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
151 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
153 set ld_library_path_tmp ""
155 # Locate libgcc.a so we don't need to account
for different
values of
156 # SHLIB_EXT
on different platforms
157 set gccdir
[lookfor_file $tool_root_dir gcc
/libgcc.a
]
159 set gccdir
[file dirname $gccdir
]
160 append ld_library_path_tmp
":${gccdir}"
164 # Locate libgomp. This is only required
for parallel
mode.
166 set libgompdir
[lookfor_file $blddir
/..
/libgomp .libs
/libgomp.$shlib_ext
]
167 if {$libgompdir
!= ""} {
169 set libgompdir
[file dirname $libgompdir
]
170 append ld_library_path_tmp
":${libgompdir}"
171 verbose
-log "libgomp support detected"
175 # Locate libvtv. This is only required
for --enable
-vtable
-verify.
177 set libvtvdir
[lookfor_file $blddir
/..
/libvtv .libs
/libvtv.$shlib_ext
]
178 if {$libvtvdir
!= ""} {
180 set libvtvdir
[file dirname $libvtvdir
]
181 append ld_library_path_tmp
":${libvtvdir}"
182 verbose
-log "libvtv support detected"
186 # Locate libstdc
++ shared library.
(ie libstdc
++.so.
)
188 set sharedlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.$shlib_ext
]
189 if {$sharedlibdir
!= ""} {
190 if { ([string match
"*-*-gnu*" $target_triplet]
191 ||
[string match
"*-*-linux*" $target_triplet]
192 ||
[string match
"*-*-solaris*" $target_triplet])
193 && [isnative
] } then {
195 verbose
-log "shared library support detected"
198 v3track v3
-sharedlib
3
200 set STATIC_LIBCXXFLAGS
""
201 set staticlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.a
]
202 if {$staticlibdir
!= ""} {
203 set staticlibdir
[file dirname $staticlibdir
]
204 # Some targets use libstdc
++.a
%s in their specs
, so they need a
205 #
-B option
for uninstalled testing.
206 set STATIC_LIBCXXFLAGS
" -B${staticlibdir} "
209 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
211 set compiler $
{gccdir
}/xg
++
212 set ld_library_path $
{ld_library_path_tmp
}
213 append ld_library_path
":${blddir}/src/.libs"
215 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
216 foreach i
"[exec $compiler --print-multi-lib]" {
218 regexp
-- "\[a-z0-9=_/\.-\]*;" $i mldir
219 set mldir
[string trimright $mldir
"\;@"]
220 if { "$mldir" == "." } {
223 if { [llength
[glob
-nocomplain $
{gccdir
}/$
{mldir
}/libgcc_s
*.so.
*]] >= 1 } {
224 append ld_library_path
":${gccdir}/${mldir}"
229 set_ld_library_path_env_vars
230 if [info exists env
(LD_LIBRARY_PATH
)] {
231 verbose
-log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
234 set compiler
[transform
"g++"]
237 #
Set the default timeout
for v3 tests.
241 set cxx
[transform
"g++"]
242 set cxxflags
"-fmessage-length=0"
246 set cc
[transform
"gcc"]
247 # Locate testsuite_hooks.h and other testsuite headers.
248 set includes
"-I${srcdir}/util"
249 # Adapt the defaults
for special circumstances.
250 if [is_remote host
] {
251 # A remote host does not
, in general
, have access to the
252 # $srcdir so we copy the testsuite headers into the current
253 # directory
, and
then add that to the search path.
254 foreach src
[glob
"${srcdir}/util/*.h" \
255 "${srcdir}/util/*.cc" \
256 "${srcdir}/util/*.tcc" \
257 "${srcdir}/util/*.hpp" \
258 "${srcdir}/util/*/*.h" \
259 "${srcdir}/util/*/*.cc" \
260 "${srcdir}/util/*/*.tcc" \
261 "${srcdir}/util/*/*.hpp" \
262 "${srcdir}/util/*/*/*.h" \
263 "${srcdir}/util/*/*/*.cc" \
264 "${srcdir}/util/*/*/*.tcc" \
265 "${srcdir}/util/*/*/*.hpp" \
266 "${srcdir}/util/*/*/*/*.h" \
267 "${srcdir}/util/*/*/*/*.cc" \
268 "${srcdir}/util/*/*/*/*.tcc" \
269 "${srcdir}/util/*/*/*/*.hpp" \
270 "${srcdir}/util/*/*/*/*/*.h" \
271 "${srcdir}/util/*/*/*/*/*.cc" \
272 "${srcdir}/util/*/*/*/*/*.tcc" \
273 "${srcdir}/util/*/*/*/*/*.hpp" ] {
274 # Remove everything up to
"util/..."
275 set dst
[string range $src
[string length
"${srcdir}/"] end]
276 # Create the directory containing the file.
277 set dir [file dirname $dst
]
278 remote_exec host
"mkdir" [list "-p" "$dir"]
280 set result
[remote_download host $src $dst
]
281 if { $result
== "" } {
282 verbose
-log "Unable to download ${srcdir}/${src} to host."
286 set includes
"-Iutil"
287 } elseif
{ [file
exists $flags_file
] } {
288 #
If we find a testsuite_flags file
, we
're testing in the build dir.
289 set cxx [exec sh $flags_file --build-cxx]
290 set cxxflags [exec sh $flags_file --cxxflags]
291 set cxxpchflags [exec sh $flags_file --cxxpchflags]
292 set cxxvtvflags [exec sh $flags_file --cxxvtvflags]
293 set cxxldflags [exec sh $flags_file --cxxldflags]
294 set cc [exec sh $flags_file --build-cc]
295 set includes [exec sh $flags_file --build-includes]
298 append cxxflags [getenv CXXFLAGS]
300 if ![regexp ".*-O" $cxxflags] {
301 append cxxflags " -g -O2"
306 # Should be as good as -fdiagnostics-color=never, but more compatible
308 # Always use MO files built by this test harness.
309 set ccflags "$cxxflags -DLOCALEDIR=\".\""
310 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
312 # If a PCH file is available, use it. We must delay performing
313 # this check until $cxx and such have been initialized because we
314 # perform a test compilation. (Ideally, gcc --print-file-name would
315 # list PCH files, but it does not.)
316 if { $cxxpchflags != "" } {
317 set src "config[pid].cc"
318 set f [open $src "w"]
319 puts $f "int main () {}"
322 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
323 # useful as then the requested variant of the pre-build PCH
324 # files could be tested to see if it works.
325 set lines [v3_target_compile $src "config[pid].o" object \
326 "additional_flags=-include additional_flags=bits/stdc++.h"]
327 if { $lines != "" } {
328 verbose -log "Requested PCH file: $cxxpchflags"
329 verbose -log "is not working, and will not be used."
334 v3track cxxpchflags 2
337 if ![info exists PCH_CXXFLAGS] then {
338 set PCH_CXXFLAGS $cxxpchflags
339 v3track PCH_CXXFLAGS 2
342 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
345 # Callback for cleanup routines.
346 proc libstdc++_exit { } {
349 if [info exists gluefile] {
350 file_on_build delete $gluefile;
355 # Callback from system dg-test.
356 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
357 # Set up the compiler flags, based on what we're going to
do.
360 set compile_type
"preprocess"
361 set output_file
"[file rootname [file tail $prog]].i"
364 set compile_type
"assembly"
365 set output_file
"[file rootname [file tail $prog]].s"
368 set compile_type
"object"
369 set output_file
"[file rootname [file tail $prog]].o"
372 set compile_type
"executable"
373 set output_file
"./[file rootname [file tail $prog]].exe"
376 set compile_type
"executable"
377 # FIXME
: "./" is to cope with "." not being in $PATH.
378 # Should this be handled elsewhere?
380 set output_file
"./[file rootname [file tail $prog]].exe"
381 # This is the only place where we care
if an executable was
382 # created or not.
If it was
, dg.exp will try to run it.
383 catch
{ remote_file build
delete $output_file
}
386 perror
"$do_what: not a valid dg-do keyword"
391 # Short
-circut a bunch of complicated goo here
for the special
392 # case of compiling a test file as a
"C" file, not as C++. Why? So
393 #
-nostdc
++ doesn
't trip us up. So all the extra object files
394 # don't trip us up. So automatically linking in libstdc
++ doesn
't
395 # happen. So CXXFLAGS don't error.
396 set select_compile
"v3_target_compile"
398 if { $extra_tool_flags
!= "" } {
399 verbose
-log "extra_tool_flags are:"
400 verbose
-log $extra_tool_flags
401 if { [string first
"-x c" $extra_tool_flags ] != -1 } {
402 verbose
-log "compiling and executing as C, not C++"
403 set edit_tool_flags $extra_tool_flags
404 regsub
-all
".x c" $edit_tool_flags "" edit_tool_flags
405 lappend options
"additional_flags=$edit_tool_flags"
406 set select_compile
"v3_target_compile_as_c"
408 lappend options
"additional_flags=$extra_tool_flags"
412 # There is a libstdc
++_compile made
for us by default
(via the tool
-
413 # and
-target file
), but the defaults are lacking in goodness.
414 set comp_output
[$select_compile
"$prog" "$output_file" "$compile_type" $options];
416 set unsupported_message
[libstdc
++_check_unsupported_p $comp_output
]
417 if { $unsupported_message
!= "" } {
418 set comp_output
"::unsupported::$unsupported_message"
421 return [list $comp_output $output_file
]
424 # Override the DejaGnu dg
-test in order to clear flags after a test
, as
425 # is done
for compiler tests in gcc
-dg.exp.
427 if { [info procs saved
-dg
-test
] == [list
] } {
428 rename dg
-test saved
-dg
-test
430 proc dg
-test
{ args } {
431 global additional_prunes
433 global testname_with_flags
435 if { [ catch
{ eval saved
-dg
-test $
args } errmsg
] } {
436 set saved_info $errorInfo
437 set additional_prunes
""
438 if [info exists testname_with_flags
] {
439 unset testname_with_flags
442 error $errmsg $saved_info
444 set additional_prunes
""
446 if [info exists testname_with_flags
] {
447 unset testname_with_flags
452 # True
if the library supports wchar_t.
455 # True
if the library supports threads.
458 # True
if the library supports symbol versioning.
461 # Called from libstdc
++-dg
-test above. Calls
back into
system's
462 # target_compile to actually do the work.
463 proc v3_target_compile { source dest type options } {
471 global STATIC_LIBCXXFLAGS
474 lappend options "additional_flags=-fno-diagnostics-show-caret -fdiagnostics-color=never"
476 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
477 lappend options "libs=${gluefile}"
478 lappend options "ldflags=${wrap_flags}"
482 set cxxlibglossflags [libgloss_link_flags]
483 set cxx_final [concat $cxx_final $cxxlibglossflags]
484 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
485 set cxx_final [concat $cxx_final $cxxflags]
486 set cxx_final [concat $cxx_final $cxxvtvflags]
487 set cxx_final [concat $cxx_final $includes]
489 # Flag setting based on type argument.
490 if { $type == "executable" } {
491 # Link the support objects into executables.
492 lappend options "additional_flags=./libtestc++.a $cxxldflags"
494 if { $type == "sharedlib" } {
495 # Don't link in anything.
496 set type
"executable"
500 lappend options
"compiler=$cxx_final"
501 lappend options
"timeout=[timeout_value]"
503 set comp_output
[target_compile $source $dest $type $options
]
509 # Called from libstdc
++-dg
-test above
, but only
for "C" compilation.
510 # Calls
back into
system's target_compile to actually do the work.
511 proc v3_target_compile_as_c { source dest type options } {
519 global STATIC_LIBCXXFLAGS
522 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
523 lappend options "libs=${gluefile}"
524 lappend options "ldflags=${wrap_flags}"
527 set tname [target_info name]
529 set cxxlibglossflags [libgloss_link_flags]
530 set cc_final [concat $cc_final $cxxlibglossflags]
531 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
532 set cc_final [concat $cc_final $cxxflags]
533 set cc_final [concat $cc_final $includes]
534 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
536 # This is needed for "C" tests, as this type of test may need the
537 # C++ includes. And if we're not testing in the build directory
,
538 # the includes
variable is not likely to
include the necessary
540 if { ![file
exists $flags_file
] } {
541 # ??? We need a
--print
-include-dirs option to GCC
, so that
542 # we can avoid these hacks. The heuristics here will not
543 # work with non
-standard
--with
-includedir
= options.
544 set version
[remote_exec host $
{cc
} -dumpversion
]
545 # Remove the trailing newline from the output.
546 set version
[string trimright
[lindex $version
1]]
547 set machine
[remote_exec host $
{cc
} -dumpmachine
]
548 set machine
[string trimright
[lindex $machine
1]]
549 set comp_base_dir
[remote_exec host $
{cc
} --print
-prog
-name=cc1
]
550 set comp_base_dir
[lindex $comp_base_dir
1]
551 set comp_base_dir
[file dirname
[file dirname
[file dirname
[file dirname
[file dirname $comp_base_dir
]]]]]
552 #
For a cross compiler
, the header files will be located in a
553 # machine
-specific subdirectory.
554 set crossbase
"${comp_base_dir}/${machine}/include/c++/${version}"
555 set crosstarget
"${crossbase}/${machine}"
556 set cc_final
[concat $cc_final
"-I$crossbase -I$crosstarget"]
557 #
For a native compiler
, the header files will be located at
559 set includesbase
"${comp_base_dir}/include/c++/${version}"
560 set includestarget
"${includesbase}/${machine}"
561 set cc_final
[concat $cc_final
"-I$includesbase -I$includestarget"]
563 set libdir
"-L${comp_base_dir}/lib"
565 set libdir
"-L${blddir}/libsupc++/.libs"
566 set libdir
[concat $libdir
"-L${blddir}/src/.libs"]
569 set cc_final
[concat $cc_final
"$libdir"]
571 lappend options
"compiler=$cc_final"
572 lappend options
"timeout=[timeout_value]"
574 set comp_output
[target_compile $source $dest $type $options
]
579 # Build the support objects linked in with the libstdc
++ tests. In
580 # addition
, set v3
-wchar_t
, v3
-threads
, and v3
-symver appropriately.
581 proc v3
-build_support
{ } {
589 # Figure out whether or not the library supports certain features.
595 set config_src
"config.cc"
596 set config_out
"config.ii"
597 set f
[open $config_src
"w"]
598 puts $f
"#include <bits/c++config.h>"
599 puts $f
"#include <bits/gthr.h>"
601 v3_target_compile $config_src $config_out preprocess
"additional_flags=-dN"
602 set file
[open $config_out r
]
603 set preprocessed
[read $file
]
605 if { [string first
"_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
606 verbose
-log "wchar_t support detected"
609 if { [string first
"_GLIBCXX_SYMVER" $preprocessed] != -1 } {
610 verbose
-log "symbol versioning support detected"
613 if { [string first
"__GTHREADS" $preprocessed] != -1 } {
614 verbose
-log "thread support detected"
618 # Try to build the MO files that are used by some of the locale
619 # tests.
If we can
't build them, that's OK
; it just means that
620 # those tests will fail.
621 foreach lang
[list
"fr" "de"] {
623 file
mkdir "$lang/LC_MESSAGES"
624 remote_exec
"build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
625 if [is_remote host
] {
626 remote_exec
"host" "mkdir" "-p $lang/LC_MESSAGES"
627 remote_download
"host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
632 # Build the support objects.
633 set source_files
[list testsuite_abi.cc testsuite_allocator.cc \
634 testsuite_character.cc testsuite_hooks.cc \
635 io
/verified_cmd_line_input.cc \
636 io
/prog_bar.cc performance
/time
/elapsed_timer.cc
]
637 foreach f $source_files
{
638 set obj [file rootname $f
].o
639 set object_file
[file tail $
obj]
640 #
Compile with
"-w" so that warnings issued by the compiler
641 #
do not prevent compilation.
642 # Disable LTO so that ar
/ranlib don
't need the LTO plugin.
643 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
644 [list "incdir=$srcdir" "additional_flags=-w -fno-lto"]]
646 error "could not compile $f"
648 append libtest_objs "$object_file "
651 # Collect into libtestc++.a
652 if [info exists env(AR)] {
655 set ar [transform "ar"]
657 set arargs "-rc ./libtestc++.a ${libtest_objs}"
658 verbose -log "$ar $arargs"
659 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
660 verbose "link result is $result"
661 if { $result == 0 } {
662 if [info exists env(RANLIB)] {
663 set ranlib $env(RANLIB)
665 set ranlib [transform "ranlib"]
667 set ranlibargs "./libtestc++.a"
668 verbose -log "$ranlib $ranlibargs"
669 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
670 if { $result != 0 } {
671 error "could not link libtestc++.a"
675 # Build any shared objects needed for regression testing.
676 if { ${v3-sharedlib} == 1 } {
677 set source_files [list testsuite_shared.cc]
678 foreach f $source_files {
679 set object_file [file rootname $f].so
680 # Compile with "-w" so that warnings issued by the compiler
681 # do not prevent compilation.
682 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
683 [list "incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC -std=gnu++98"]]
685 error "could not compile $f"
691 proc check_v3_target_fileio { } {
692 global et_fileio_saved
693 global et_fileio_target_name
697 if { ![info exists et_fileio_target_name] } {
698 set et_fileio_target_name ""
701 # If the target has changed since we set the cached value, clear it.
702 set current_target [current_target_name]
703 if { $current_target != $et_fileio_target_name } {
704 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
705 set et_fileio_target_name $current_target
706 if [info exists et_fileio_saved
] {
707 verbose
"check_v3_target_fileio: removing cached result" 2
708 unset et_fileio_saved
712 if [info exists et_fileio_saved
] {
713 verbose
"check_v3_target_fileio: using cached result" 2
715 set et_fileio_saved
0
717 #
Set up
, compile, and
execute a C
++ test
program that tries to use
719 set src fileio
[pid
].cc
720 set exe fileio
[pid
].x
721 set testfile
"cin_unget-1.[pid].txt"
722 v3
-copy
-file
"$srcdir/data/cin_unget-1.txt" "$testfile"
724 set f
[open $src
"w"]
725 puts $f
"#include <sys/types.h>"
726 puts $f
"#include <sys/stat.h>"
727 puts $f
"#include <fcntl.h>"
728 puts $f
"#include <unistd.h>"
729 puts $f
"#include <errno.h>"
730 puts $f
"#include <string.h>"
731 puts $f
"using namespace std;"
732 puts $f
"int main ()"
734 puts $f
" int fd = open (\"$testfile\", O_RDONLY);"
735 puts $f
" int ret = 0;"
736 puts $f
" char buf\[10\];"
737 puts $f
" if (fd == -1)"
741 puts $f
" if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
743 puts $f
" errno = 0;"
744 puts $f
" if (lseek (fd, 0, SEEK_CUR) != 0"
745 puts $f
" || read (fd, buf, 4) != 4"
746 puts $f
" || memcmp (buf, \"1234\", 4) != 0"
747 puts $f
" || lseek (fd, -2, SEEK_CUR) != 2"
748 puts $f
" || read (fd, buf, 2) != 2"
749 puts $f
" || memcmp (buf, \"34\", 2) != 0)"
751 puts $f
" close (fd);"
753 puts $f
" return ret;"
757 set lines
[v3_target_compile $src $exe executable
""]
760 if [string match
"" $lines] {
761 # No error message
, compilation succeeded.
762 set result
[$
{tool
}_load
"./$exe" "" ""]
763 set status [lindex $result
0]
764 remote_file build
delete $exe
766 verbose
"check_v3_target_fileio: status is <$status>" 2
768 if { $
status == "pass" } {
769 set et_fileio_saved
1
772 verbose
"check_v3_target_fileio: compilation failed" 2
775 return $et_fileio_saved
778 # Eventually we want C90
/C99 determining and switching from this.
779 proc check_v3_target_c_std
{ } {
780 global et_c_std_saved
781 global et_c_std_target_name
784 if { ![info exists et_c_std_target_name
] } {
785 set et_c_std_target_name
""
788 #
If the target has changed since we
set the cached value
, clear it.
789 set current_target
[current_target_name
]
790 if { $current_target
!= $et_c_std_target_name
} {
791 verbose
"check_v3_target_c_std: `$et_c_std_target_name'" 2
792 set et_c_std_target_name $current_target
793 if [info exists et_c_std_saved
] {
794 verbose
"check_v3_target_c_std: removing cached result" 2
799 if [info exists et_c_std_saved
] {
800 verbose
"check_v3_target_c_std: using cached result" 2
804 #
Set up
, compile, and
execute a C
++ test
program that tries to use
806 #
For math bits
, could use check_effective_target_c99_math.
807 set src fileio
[pid
].cc
808 set exe fileio
[pid
].x
810 set f
[open $src
"w"]
811 puts $f
"#include <tr1/cmath>"
812 puts $f
"#include <cstdlib>"
813 puts $f
"int main ()"
815 puts $f
" float f = 45.55;"
816 puts $f
" int i = std::tr1::isnan(f);"
818 puts $f
" using std::wctomb;"
823 set lines
[v3_target_compile $src $exe executable
""]
826 if [string match
"" $lines] {
827 # No error message
, compilation succeeded.
828 set result
[$
{tool
}_load
"./$exe" "" ""]
829 set status [lindex $result
0]
830 remote_file build
delete $exe
832 verbose
"check_v3_target_c_std: status is <$status>" 2
834 if { $
status == "pass" } {
838 verbose
"check_v3_target_c_std: compilation failed" 2
841 return $et_c_std_saved
844 proc check_v3_target_sharedlib
{ } {
846 return $
{v3
-sharedlib
}
849 proc check_v3_target_time
{ } {
851 global et_time_target_name
854 if { ![info exists et_time_target_name
] } {
855 set et_time_target_name
""
858 #
If the target has changed since we
set the cached value
, clear it.
859 set current_target
[current_target_name
]
860 if { $current_target
!= $et_time_target_name
} {
861 verbose
"check_v3_target_time: `$et_time_target_name'" 2
862 set et_time_target_name $current_target
863 if [info exists et_time_saved
] {
864 verbose
"check_v3_target_time: removing cached result" 2
869 if [info exists et_time_saved
] {
870 verbose
"check_v3_target_time: using cached result" 2
874 #
Set up and
compile a C
++ test
program that tries to use
878 set f
[open $src
"w"]
879 puts $f
"#include <time.h>"
880 puts $f
"using namespace std;"
881 puts $f
"int main ()"
887 set lines
[v3_target_compile $src
/dev
/null executable
""]
890 if [string match
"" $lines] {
891 # No error message
, compilation succeeded.
892 verbose
"check_v3_target_time: compilation succeeded" 2
895 verbose
"check_v3_target_time: compilation failed" 2
898 return $et_time_saved
901 proc check_v3_target_namedlocale
{ args } {
902 global et_namedlocale
907 #
Set up
, compile, and
execute a C
++ test
program that tries to use
908 # the required named locale.
909 set exe nlocale
[pid
].x
911 if ![file
exists .
/$exe
] {
912 set src nlocale
[pid
].cc
914 set f
[open $src
"w"]
915 puts $f
"#include <locale>"
916 puts $f
"#include <cstdio>"
917 puts $f
"#include <cstring>"
918 puts $f
"using namespace std;"
919 puts $f
"char *transform_locale(const char *name)"
921 puts $f
" char *result = new char\[50\];"
922 puts $f
" strcpy(result, name);"
923 puts $f
"#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
924 puts $f
" /* fall-through */"
926 puts $f
" if (strstr(result, \"ISO8859-15\")) {"
927 puts $f
" strcat(result, \"@euro\");"
930 puts $f
" return result;"
932 puts $f
"int main (int argc, char** argv)"
934 puts $f
" if (argc < 2)"
936 puts $f
" printf(\"locale support test not supported\\n\");"
939 puts $f
" const char *namedloc = transform_locale(*(argv + 1));"
942 puts $f
" locale((const char*)namedloc);"
943 puts $f
" delete\[\] namedloc;"
946 puts $f
" catch(...)"
948 puts $f
" printf(\"locale '%s' not supported\\n\", namedloc);"
949 puts $f
" delete\[\] namedloc;"
955 set lines
[v3_target_compile $src $exe executable
""]
958 if ![string match
"" $lines] {
959 verbose
"check_v3_target_namedlocale: compilation failed" 2
960 return $et_namedlocale
962 #
else No error message
, compilation succeeded.
965 set result
[$
{tool
}_load
"./$exe" "$args" ""]
966 set status [lindex $result
0]
968 verbose
"check_v3_target_namedlocale <$args>: status is <$status>" 2
970 if { $
status == "pass" } {
973 return $et_namedlocale
976 proc check_v3_target_debug_mode
{ } {
980 if { ![info exists et_debug_mode_target_name
] } {
981 set et_debug_mode_target_name
""
984 #
If the target has changed since we
set the cached value
, clear it.
985 set current_target
[current_target_name
]
986 if { $current_target
!= $et_debug_mode_target_name
} {
987 verbose
"check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
988 set et_debug_mode_target_name $current_target
989 if [info exists et_debug_mode
] {
990 verbose
"check_v3_target_debug_mode: removing cached result" 2
995 if [info exists et_debug_mode
] {
996 verbose
"check_v3_target_debug_mode: using cached result" 2
1000 #
Set up and preprocess a C
++ test
program that depends
1001 #
on debug
mode activated.
1002 set src debug_mode
[pid
].cc
1004 set f
[open $src
"w"]
1005 puts $f
"#ifndef _GLIBCXX_DEBUG"
1006 puts $f
"# error No debug mode"
1010 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1013 if [string match
"" $lines] {
1014 # No error message
, preprocessing succeeded.
1018 verbose
"check_v3_target_debug_mode: $et_debug_mode" 2
1019 return $et_debug_mode
1022 proc check_v3_target_profile_mode
{ } {
1023 global et_profile_mode
1026 if { ![info exists et_profile_mode_target_name
] } {
1027 set et_profile_mode_target_name
""
1030 #
If the target has changed since we
set the cached value
, clear it.
1031 set current_target
[current_target_name
]
1032 if { $current_target
!= $et_profile_mode_target_name
} {
1033 verbose
"check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
1034 set et_profile_mode_target_name $current_target
1035 if [info exists et_profile_mode
] {
1036 verbose
"check_v3_target_profile_mode: removing cached result" 2
1037 unset et_profile_mode
1041 if [info exists et_profile_mode
] {
1042 verbose
"check_v3_target_profile_mode: using cached result" 2
1044 set et_profile_mode
0
1046 #
Set up and preprocess a C
++ test
program that depends
1047 #
on profile
mode activated.
1048 set src profile_mode
[pid
].cc
1050 set f
[open $src
"w"]
1051 puts $f
"#ifndef _GLIBCXX_PROFILE"
1052 puts $f
"# error No profile mode"
1056 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1059 if [string match
"" $lines] {
1060 # No error message
, preprocessing succeeded.
1061 set et_profile_mode
1
1064 verbose
"check_v3_target_profile_mode: $et_profile_mode" 2
1065 return $et_profile_mode
1068 proc check_v3_target_normal_mode
{ } {
1069 global et_normal_mode
1072 if { ![info exists et_normal_mode_target_name
] } {
1073 set et_normal_mode_target_name
""
1076 #
If the target has changed since we
set the cached value
, clear it.
1077 set current_target
[current_target_name
]
1078 if { $current_target
!= $et_normal_mode_target_name
} {
1079 verbose
"check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1080 set et_normal_mode_target_name $current_target
1081 if [info exists et_normal_mode
] {
1082 verbose
"check_v3_target_normal_mode: removing cached result" 2
1083 unset et_normal_mode
1087 if [info exists et_normal_mode
] {
1088 verbose
"check_v3_target_normal_mode: using cached result" 2
1090 set et_normal_mode
0
1092 #
Set up and
compile a C
++ test
program that depends
1093 #
on normal mode activated.
1094 set src normal_mode
[pid
].cc
1096 set f
[open $src
"w"]
1097 puts $f
"#include <bits/c++config.h>"
1098 puts $f
"#if defined(_GLIBCXX_DEBUG) || \\"
1099 puts $f
" defined(_GLIBCXX_PROFILE) || \\"
1100 puts $f
" defined(_GLIBCXX_PARALLEL)"
1101 puts $f
"# error No normal mode"
1105 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1108 if [string match
"" $lines] {
1109 # No error message
, compilation succeeded.
1110 set et_normal_mode
1
1113 verbose
"check_v3_target_normal_mode: $et_normal_mode" 2
1114 return $et_normal_mode
1117 proc check_v3_target_normal_namespace
{ } {
1118 global et_normal_namespace
1121 if { ![info exists et_normal_namespace_target_name
] } {
1122 set et_normal_namespace_target_name
""
1125 #
If the target has changed since we
set the cached value
, clear it.
1126 set current_target
[current_target_name
]
1127 if { $current_target
!= $et_normal_namespace_target_name
} {
1128 verbose
"check_v3_target_normal_namespace: `$et_normal_namespace_target_name'" 2
1129 set et_normal_namespace_target_name $current_target
1130 if [info exists et_normal_namespace
] {
1131 verbose
"check_v3_target_normal_namespace: removing cached result" 2
1132 unset et_normal_namespace
1136 if [info exists et_normal_namespace
] {
1137 verbose
"check_v3_target_normal_namespace: using cached result" 2
1139 set et_normal_namespace
0
1141 #
Set up and
compile a C
++ test
program that depends
1142 #
on normal std namespace.
1143 set src normal_namespace
[pid
].cc
1145 set f
[open $src
"w"]
1146 puts $f
"#include <bits/c++config.h>"
1147 puts $f
"#if _GLIBCXX_INLINE_VERSION"
1148 puts $f
"# error No normal namespace"
1152 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1155 if [string match
"" $lines] {
1156 # No error message
, compilation succeeded.
1157 set et_normal_namespace
1
1160 verbose
"check_v3_target_normal_namespace: $et_normal_namespace" 2
1161 return $et_normal_namespace
1164 proc check_v3_target_parallel_mode
{ } {
1167 global et_parallel_mode
1171 if { ![info exists et_parallel_mode_target_name
] } {
1172 set et_parallel_mode_target_name
""
1175 #
If the target has changed since we
set the cached value
, clear it.
1176 set current_target
[current_target_name
]
1177 if { $current_target
!= $et_parallel_mode_target_name
} {
1178 verbose
"check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1179 set et_parallel_mode_target_name $current_target
1180 if [info exists et_parallel_mode
] {
1181 verbose
"check_v3_target_parallel_mode: removing cached result" 2
1182 unset et_parallel_mode
1186 if [info exists et_parallel_mode
] {
1187 verbose
"check_v3_target_parallel_mode: using cached result" 2
1189 set et_parallel_mode
0
1191 #
If 'make check-parallel' is running the test succeeds.
1192 if { $
{v3
-libgomp
} == 1 && [regexp
"libgomp" $cxxflags] } {
1193 set et_parallel_mode
1
1196 verbose
"check_v3_target_parallel_mode: $et_parallel_mode" 2
1197 return $et_parallel_mode
1200 proc check_v3_target_cstdint
{ } {
1202 global DEFAULT_CXXFLAGS
1207 if { ![info exists et_cstdint_target_name
] } {
1208 set et_cstdint_target_name
""
1211 #
If the target has changed since we
set the cached value
, clear it.
1212 set current_target
[current_target_name
]
1213 if { $current_target
!= $et_cstdint_target_name
} {
1214 verbose
"check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1215 set et_cstdint_target_name $current_target
1216 if [info exists et_cstdint
] {
1217 verbose
"check_v3_target_cstdint: removing cached result" 2
1222 if [info exists et_cstdint
] {
1223 verbose
"check_v3_target_cstdint: using cached result" 2
1227 #
Set up and preprocess a C
++0x test
program that depends
1228 #
on the C99 stdint facilities to be available.
1229 set src cstdint
[pid
].cc
1231 set f
[open $src
"w"]
1232 puts $f
"#include <tr1/cstdint>"
1233 puts $f
"#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1234 puts $f
"# error No C99 stdint"
1238 set cxxflags_saved $cxxflags
1239 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1241 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1242 set cxxflags $cxxflags_saved
1245 if [string match
"" $lines] {
1246 # No error message
, preprocess succeeded.
1249 verbose
"check_v3_target_cstdint: compilation failed" 2
1252 verbose
"check_v3_target_cstdint: $et_cstdint" 2
1256 proc check_v3_target_cmath
{ } {
1258 global DEFAULT_CXXFLAGS
1263 if { ![info exists et_c99_math_target_name
] } {
1264 set et_c99_math_target_name
""
1267 #
If the target has changed since we
set the cached value
, clear it.
1268 set current_target
[current_target_name
]
1269 if { $current_target
!= $et_c99_math_target_name
} {
1270 verbose
"check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1271 set et_c99_math_target_name $current_target
1272 if [info exists et_c99_math
] {
1273 verbose
"check_v3_target_c99_math: removing cached result" 2
1278 if [info exists et_c99_math
] {
1279 verbose
"check_v3_target_c99_math: using cached result" 2
1283 #
Set up and preprocess a C
++0x test
program that depends
1284 #
on the C99 math facilities to be available.
1285 set src c99_math
[pid
].cc
1287 set f
[open $src
"w"]
1288 puts $f
"#include <tr1/cmath>"
1289 puts $f
"#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1290 puts $f
"# error No C99 math"
1294 set cxxflags_saved $cxxflags
1295 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1297 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1298 set cxxflags $cxxflags_saved
1301 if [string match
"" $lines] {
1302 # No error message
, preprocess succeeded.
1305 verbose
"check_v3_target_c99_math: compilation failed" 2
1308 verbose
"check_v3_target_c99_math: $et_c99_math" 2
1312 proc check_v3_target_thread_fence
{ } {
1314 global DEFAULT_CXXFLAGS
1315 global et_thread_fence
1319 if { ![info exists et_thread_fence_target_name
] } {
1320 set et_thread_fence_target_name
""
1323 #
If the target has changed since we
set the cached value
, clear it.
1324 set current_target
[current_target_name
]
1325 if { $current_target
!= $et_thread_fence_target_name
} {
1326 verbose
"check_v3_target_thread_fence: `$et_thread_fence_target_name'" 2
1327 set et_thread_fence_target_name $current_target
1328 if [info exists et_thread_fence
] {
1329 verbose
"check_v3_target_thread_fence: removing cached result" 2
1330 unset et_thread_fence
1334 if [info exists et_thread_fence
] {
1335 verbose
"check_v3_target_thread_fence: using cached result" 2
1337 set et_thread_fence
0
1339 #
Set up and preprocess a C
++11 test
program that depends
1340 #
on the thread fence to be available.
1341 set src thread_fence
[pid
].cc
1343 set f
[open $src
"w"]
1344 puts $f
"int main() {"
1345 puts $f
"__atomic_thread_fence (__ATOMIC_SEQ_CST);"
1350 set cxxflags_saved $cxxflags
1351 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1353 set lines
[v3_target_compile $src
/dev
/null executable
""]
1354 set cxxflags $cxxflags_saved
1357 if [string match
"" $lines] {
1358 # No error message
, linking succeeded.
1359 set et_thread_fence
1
1361 verbose
"check_v3_target_thread_fence: compilation failed" 2
1364 verbose
"check_v3_target_thread_fence: $et_thread_fence" 2
1365 return $et_thread_fence
1368 proc check_v3_target_atomic_builtins
{ } {
1370 global DEFAULT_CXXFLAGS
1371 global et_atomic_builtins
1375 if { ![info exists et_atomic_builtins_target_name
] } {
1376 set et_atomic_builtins_target_name
""
1379 #
If the target has changed since we
set the cached value
, clear it.
1380 set current_target
[current_target_name
]
1381 if { $current_target
!= $et_atomic_builtins_target_name
} {
1382 verbose
"check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1383 set et_atomic_builtins_target_name $current_target
1384 if [info exists et_atomic_builtins
] {
1385 verbose
"check_v3_target_atomic_builtins: removing cached result" 2
1386 unset et_atomic_builtins
1390 if [info exists et_atomic_builtins
] {
1391 verbose
"check_v3_target_atomic_builtins: using cached result" 2
1393 set et_atomic_builtins
0
1395 #
Set up and preprocess a C
++11 test
program that depends
1396 #
on the atomic builtin facilities to be available.
1397 set src atomic_builtins
[pid
].cc
1399 set f
[open $src
"w"]
1400 puts $f
"#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1401 puts $f
"# error No atomic bool"
1403 puts $f
"#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1404 puts $f
"# error No atomic int"
1408 set cxxflags_saved $cxxflags
1409 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1411 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1412 set cxxflags $cxxflags_saved
1415 if [string match
"" $lines] {
1416 # No error message
, preprocess succeeded.
1417 set et_atomic_builtins
1
1419 verbose
"check_v3_target_atomic_builtins: compilation failed" 2
1422 verbose
"check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1423 return $et_atomic_builtins
1426 proc check_v3_target_gthreads
{ } {
1428 global DEFAULT_CXXFLAGS
1433 if { ![info exists et_gthreads_target_name
] } {
1434 set et_gthreads_target_name
""
1437 #
If the target has changed since we
set the cached value
, clear it.
1438 set current_target
[current_target_name
]
1439 if { $current_target
!= $et_gthreads_target_name
} {
1440 verbose
"check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1441 set et_gthreads_target_name $current_target
1442 if [info exists et_gthreads
] {
1443 verbose
"check_v3_target_gthreads: removing cached result" 2
1448 if [info exists et_gthreads
] {
1449 verbose
"check_v3_target_gthreads: using cached result" 2
1453 #
Set up and preprocess a C
++0x test
program that depends
1454 #
on the gthreads facilities to be available.
1455 set src gthreads
[pid
].cc
1457 set f
[open $src
"w"]
1458 puts $f
"#include <bits/c++config.h>"
1459 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1460 puts $f
"# error No gthread"
1464 set cxxflags_saved $cxxflags
1465 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1467 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1468 set cxxflags $cxxflags_saved
1471 if [string match
"" $lines] {
1472 # No error message
, preprocessing succeeded.
1475 verbose
"check_v3_target_gthreads: compilation failed" 2
1478 verbose
"check_v3_target_gthreads: $et_gthreads" 2
1482 proc check_v3_target_gthreads_timed
{ } {
1484 global DEFAULT_CXXFLAGS
1485 global et_gthreads_timed
1489 if { ![info exists et_gthreads_timed_target_name
] } {
1490 set et_gthreads_timed_target_name
""
1493 #
If the target has changed since we
set the cached value
, clear it.
1494 set current_target
[current_target_name
]
1495 if { $current_target
!= $et_gthreads_timed_target_name
} {
1496 verbose
"check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1497 set et_gthreads_timed_target_name $current_target
1498 if [info exists et_gthreads_timed
] {
1499 verbose
"check_v3_target_gthreads_timed: removing cached result" 2
1500 unset et_gthreads_timed
1504 if [info exists et_gthreads_timed
] {
1505 verbose
"check_v3_target_gthreads_timed: using cached result" 2
1507 set et_gthreads_timed
0
1509 #
Set up and preprocess a C
++0x test
program that depends
1510 #
on the gthreads timed mutex facilities to be available.
1511 set src gthreads_timed
[pid
].cc
1513 set f
[open $src
"w"]
1514 puts $f
"#include <bits/c++config.h>"
1515 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1516 puts $f
"# error No gthread"
1518 puts $f
"#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1519 puts $f
"# error No gthread timed mutexes"
1523 set cxxflags_saved $cxxflags
1524 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1526 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1527 set cxxflags $cxxflags_saved
1530 if [string match
"" $lines] {
1531 # No error message
, preprocessing succeeded.
1532 set et_gthreads_timed
1
1534 verbose
"check_v3_target_gthreads_timed: compilation failed" 2
1537 verbose
"check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1538 return $et_gthreads_timed
1542 proc check_v3_target_sleep
{ } {
1544 global DEFAULT_CXXFLAGS
1549 if { ![info exists et_sleep_target_name
] } {
1550 set et_sleep_target_name
""
1553 #
If the target has changed since we
set the cached value
, clear it.
1554 set current_target
[current_target_name
]
1555 if { $current_target
!= $et_sleep_target_name
} {
1556 verbose
"check_v3_target_sleep: `$et_sleep_target_name'" 2
1557 set et_sleep_target_name $current_target
1558 if [info exists et_sleep
] {
1559 verbose
"check_v3_target_sleep: removing cached result" 2
1564 if [info exists et_sleep
] {
1565 verbose
"check_v3_target_sleep: using cached result" 2
1569 #
Set up and preprocess a C
++11 test
program that depends
1570 #
on the
sleep facilities to be available.
1571 set src
sleep[pid
].cc
1573 set f
[open $src
"w"]
1574 puts $f
"#include <bits/c++config.h>"
1575 puts $f
"#ifndef _GLIBCXX_USE_NANOSLEEP"
1576 puts $f
"# ifndef _GLIBCXX_HAVE_SLEEP"
1577 puts $f
"# error No nanosleep or sleep"
1582 set cxxflags_saved $cxxflags
1583 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1585 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1586 set cxxflags $cxxflags_saved
1589 if [string match
"" $lines] {
1590 # No error message
, preprocessing succeeded.
1593 verbose
"check_v3_target_sleep: compilation failed" 2
1596 verbose
"check_v3_target_sleep: $et_sleep" 2
1600 proc check_v3_target_sched_yield
{ } {
1602 global DEFAULT_CXXFLAGS
1603 global et_sched_yield
1607 if { ![info exists et_sched_yield_target_name
] } {
1608 set et_sched_yield_target_name
""
1611 #
If the target has changed since we
set the cached value
, clear it.
1612 set current_target
[current_target_name
]
1613 if { $current_target
!= $et_sched_yield_target_name
} {
1614 verbose
"check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1615 set et_sched_yield_target_name $current_target
1616 if [info exists et_sched_yield
] {
1617 verbose
"check_v3_target_sched_yield: removing cached result" 2
1618 unset et_sched_yield
1622 if [info exists et_sched_yield
] {
1623 verbose
"check_v3_target_sched_yield: using cached result" 2
1625 set et_sched_yield
0
1627 #
Set up and preprocess a C
++0x test
program that depends
1628 #
on the sched_yield facility to be available.
1629 set src sched_yield
[pid
].cc
1631 set f
[open $src
"w"]
1632 puts $f
"#include <bits/c++config.h>"
1633 puts $f
"#ifndef _GLIBCXX_USE_SCHED_YIELD"
1634 puts $f
"# error No sched yield"
1638 set cxxflags_saved $cxxflags
1639 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1641 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1642 set cxxflags $cxxflags_saved
1645 if [string match
"" $lines] {
1646 # No error message
, preprocessing succeeded.
1647 set et_sched_yield
1
1649 verbose
"check_v3_target_sched_yield: compilation failed" 2
1652 verbose
"check_v3_target_sched_yield: $et_sched_yield" 2
1653 return $et_sched_yield
1656 proc check_v3_target_string_conversions
{ } {
1658 global DEFAULT_CXXFLAGS
1659 global et_string_conversions
1663 if { ![info exists et_string_conversions_target_name
] } {
1664 set et_string_conversions_target_name
""
1667 #
If the target has changed since we
set the cached value
, clear it.
1668 set current_target
[current_target_name
]
1669 if { $current_target
!= $et_string_conversions_target_name
} {
1670 verbose
"check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1671 set et_string_conversions_target_name $current_target
1672 if [info exists et_string_conversions
] {
1673 verbose
"check_v3_target_string_conversions: removing cached result" 2
1674 unset et_string_conversions
1678 if [info exists et_string_conversions
] {
1679 verbose
"check_v3_target_string_conversions: using cached result" 2
1681 set et_string_conversions
0
1683 #
Set up and preprocess a C
++0x test
program that depends
1684 #
on the string_conversions facilities to be available.
1685 set src string_conversions
[pid
].cc
1687 set f
[open $src
"w"]
1688 puts $f
"#include <bits/c++config.h>"
1689 puts $f
"#if !(_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB && _GLIBCXX_USE_C99_WCHAR) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1690 puts $f
"# error No string conversions"
1694 set cxxflags_saved $cxxflags
1695 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1697 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1698 set cxxflags $cxxflags_saved
1701 if [string match
"" $lines] {
1702 # No error message
, preprocessing succeeded.
1703 set et_string_conversions
1
1705 verbose
"check_v3_target_string_conversions: compilation failed" 2
1708 verbose
"check_v3_target_string_conversions: $et_string_conversions" 2
1709 return $et_string_conversions
1712 proc check_v3_target_swprintf
{ } {
1714 global DEFAULT_CXXFLAGS
1719 if { ![info exists et_swprintf_target_name
] } {
1720 set et_swprintf_target_name
""
1723 #
If the target has changed since we
set the cached value
, clear it.
1724 set current_target
[current_target_name
]
1725 if { $current_target
!= $et_swprintf_target_name
} {
1726 verbose
"check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1727 set et_swprintf_target_name $current_target
1728 if [info exists et_swprintf
] {
1729 verbose
"check_v3_target_swprintf: removing cached result" 2
1734 if [info exists et_swprintf
] {
1735 verbose
"check_v3_target_swprintf: using cached result" 2
1739 #
Set up and preprocess a C
++0x test
program that depends
1740 #
on a standard swprintf function to be available.
1741 set src swprintf
[pid
].cc
1743 set f
[open $src
"w"]
1744 puts $f
"#include <bits/c++config.h>"
1745 puts $f
"#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1746 puts $f
"# error No swprintf"
1750 set cxxflags_saved $cxxflags
1751 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1753 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1754 set cxxflags $cxxflags_saved
1757 if [string match
"" $lines] {
1758 # No error message
, preprocessing succeeded.
1761 verbose
"check_v3_target_swprintf: compilation failed" 2
1764 verbose
"check_v3_target_swprintf: $et_swprintf" 2
1768 proc check_v3_target_binary_io
{ } {
1770 global DEFAULT_CXXFLAGS
1775 if { ![info exists et_binary_io_target_name
] } {
1776 set et_binary_io_target_name
""
1779 #
If the target has changed since we
set the cached value
, clear it.
1780 set current_target
[current_target_name
]
1781 if { $current_target
!= $et_binary_io_target_name
} {
1782 verbose
"check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1783 set et_binary_io_target_name $current_target
1784 if [info exists et_binary_io
] {
1785 verbose
"check_v3_target_binary_io: removing cached result" 2
1790 if [info exists et_binary_io
] {
1791 verbose
"check_v3_target_binary_io: using cached result" 2
1795 #
Set up and preprocess a C
++0x test
program that depends
1796 #
on text and binary I
/O being the same.
1797 set src binary_io
[pid
].cc
1799 set f
[open $src
"w"]
1800 puts $f
"#include <bits/c++config.h>"
1801 puts $f
"#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1802 puts $f
"# error No binary io"
1806 set cxxflags_saved $cxxflags
1807 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1809 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1810 set cxxflags $cxxflags_saved
1813 if [string match
"" $lines] {
1814 # No error message
, preprocessing succeeded.
1817 verbose
"check_v3_target_binary_io: compilation failed" 2
1820 verbose
"check_v3_target_binary_io: $et_binary_io" 2
1821 return $et_binary_io
1824 proc check_v3_target_nprocs
{ } {
1826 global DEFAULT_CXXFLAGS
1831 if { ![info exists et_nprocs_target_name
] } {
1832 set et_nprocs_target_name
""
1835 #
If the target has changed since we
set the cached value
, clear it.
1836 set current_target
[current_target_name
]
1837 if { $current_target
!= $et_nprocs_target_name
} {
1838 verbose
"check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1839 set et_nprocs_target_name $current_target
1840 if [info exists et_nprocs
] {
1841 verbose
"check_v3_target_nprocs: removing cached result" 2
1846 if [info exists et_nprocs
] {
1847 verbose
"check_v3_target_nprocs: using cached result" 2
1851 #
Set up and preprocess a C
++0x test
program that depends
1852 #
on either get_nprocs or sysconf to be available.
1853 set src nprocs
[pid
].cc
1855 set f
[open $src
"w"]
1856 puts $f
"#include <bits/c++config.h>"
1857 puts $f
"#if defined(_GLIBCXX_USE_GET_NPROCS)"
1858 puts $f
"#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1859 puts $f
"#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1860 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1861 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
1863 puts $f
"# error hardware_concurrency not implemented"
1867 set cxxflags_saved $cxxflags
1868 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1870 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1871 set cxxflags $cxxflags_saved
1874 if [string match
"" $lines] {
1875 # No error message
, preprocess succeeded.
1878 verbose
"check_v3_target_nprocs: compilation failed" 2
1881 verbose
"check_v3_target_nprocs: $et_nprocs" 2
1885 proc check_v3_target_static_libstdcxx
{ } {
1887 global DEFAULT_CXXFLAGS
1888 global et_static_libstdcxx
1892 if [info exists et_static_libstdcxx
] {
1893 verbose
"check_v3_target_static_libstdcxx: using cached result" 2
1895 set et_static_libstdcxx
0
1897 #
Set up and link a C
++0x test
program that depends
1899 set src static
-maybe
[pid
].cc
1901 set f
[open $src
"w"]
1902 puts $f
"#include <iostream>"
1903 puts $f
"int main() {"
1904 puts $f
"int i(415);"
1905 puts $f
"std::cout<< i << std::endl;"
1906 puts $f
"return 0; }"
1910 set cxxflags_saved $cxxflags
1911 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -static-libstdc++"
1913 set lines
[v3_target_compile $src
/dev
/null executable
""]
1914 set cxxflags $cxxflags_saved
1917 if [string match
"" $lines] {
1918 # No error message
, link succeeded.
1919 set et_static_libstdcxx
1
1921 verbose
"check_v3_target_static_libstdcxx: compilation failed" 2
1924 verbose
"check_v3_target_static_libstdcxx: $et_static_libstdcxx" 2
1925 return $et_static_libstdcxx
1928 proc check_v3_target_little_endian
{ } {
1930 global DEFAULT_CXXFLAGS
1931 global et_little_endian
1935 if { ![info exists et_little_endian_target_name
] } {
1936 set et_little_endian_target_name
""
1939 #
If the target has changed since we
set the cached value
, clear it.
1940 set current_target
[current_target_name
]
1941 if { $current_target
!= $et_little_endian_target_name
} {
1942 verbose
"check_v3_target_little_endian: `$et_little_endian_target_name'" 2
1943 set et_little_endian_target_name $current_target
1944 if [info exists et_little_endian
] {
1945 verbose
"check_v3_target_little_endian: removing cached result" 2
1946 unset et_little_endian
1950 if [info exists et_little_endian
] {
1951 verbose
"check_v3_target_little_endian: using cached result" 2
1953 set et_little_endian
0
1955 set src little_endian
[pid
].cc
1957 set f
[open $src
"w"]
1958 puts $f
"#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__"
1959 puts $f
"# error Not little endian"
1963 set cxxflags_saved $cxxflags
1964 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1966 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1967 set cxxflags $cxxflags_saved
1970 if [string match
"" $lines] {
1971 # No error message
, preprocessing succeeded.
1972 set et_little_endian
1
1974 verbose
"check_v3_target_little_endian: compilation failed" 2
1977 verbose
"check_v3_target_little_endian: $et_little_endian" 2
1978 return $et_little_endian
1981 #
Return 1 if the Filesystem TS is supported
, 0 otherwise.
1983 proc check_v3_target_filesystem_ts
{ } {
1985 global DEFAULT_CXXFLAGS
1986 global et_filesystem_ts
1989 if { ![info exists et_filesystem_ts_target_name
] } {
1990 set et_filesystem_ts_target_name
""
1993 #
If the target has changed since we
set the cached value
, clear it.
1994 set current_target
[current_target_name
]
1995 if { $current_target
!= $et_filesystem_ts_target_name
} {
1996 verbose
"check_v3_target_filesystem_ts: `$et_filesystem_ts_target_name'" 2
1997 set et_filesystem_ts_target_name $current_target
1998 if [info exists et_filesystem_ts
] {
1999 verbose
"check_v3_target_filesystem_ts: removing cached result" 2
2000 unset et_filesystem_ts
2004 if [info exists et_filesystem_ts
] {
2005 verbose
"check_v3_target_filesystem_ts: using cached result" 2
2007 set et_filesystem_ts
0
2009 #
Set up and preprocess a C
++ test
program that depends
2010 #
on the Filesystem TS feature
-test macro being defined.
2011 set src filesystem_ts
[pid
].cc
2013 set f
[open $src
"w"]
2014 puts $f
"#include <experimental/filesystem>"
2015 puts $f
"#if ! __cpp_lib_experimental_filesystem"
2016 puts $f
"# error No Filesystem TS support"
2020 set cxxflags_saved $cxxflags
2021 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
2023 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
2024 set cxxflags $cxxflags_saved
2027 if [string match
"" $lines] {
2028 # No error message
, preprocessing succeeded.
2029 set et_filesystem_ts
1
2032 verbose
"check_v3_target_filesystem_ts: $et_filesystem_ts" 2
2033 return $et_filesystem_ts
2036 #
Return 1 if the
"cxx11" ABI is in use using the current flags, 0 otherwise.
2037 proc check_effective_target_cxx11
-abi
{ } {
2040 #
Set up and preprocess a C
++ test
program that depends
2041 #
on the new ABI being enabled.
2042 set src cxx11_abi
[pid
].cc
2044 set f
[open $src
"w"]
2045 puts $f
"#include <bits/c++config.h>"
2046 puts $f
"#if ! _GLIBCXX_USE_CXX11_ABI"
2047 puts $f
"# error old ABI in use"
2051 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
2054 if [string match
"" $lines] {
2055 # No error message
, preprocessing succeeded.
2056 verbose
"check_v3_cxx11_abi: `1'" 2
2060 verbose
"check_v3_cxx11_abi: `0'" 2
2064 set additional_prunes
""
2066 if { [info exists env
(GCC_RUNTEST_PARALLELIZE_DIR
)] \
2067 && [info procs runtest_file_p
] != [list
] \
2068 && [info procs gcc_parallelize_saved_runtest_file_p
] == [list
] } then {
2069 global gcc_runtest_parallelize_counter
2070 global gcc_runtest_parallelize_counter_minor
2071 global gcc_runtest_parallelize_enable
2072 global gcc_runtest_parallelize_dir
2073 global gcc_runtest_parallelize_last
2075 set gcc_runtest_parallelize_counter
0
2076 set gcc_runtest_parallelize_counter_minor
0
2077 set gcc_runtest_parallelize_enable
1
2078 set gcc_runtest_parallelize_dir
[getenv GCC_RUNTEST_PARALLELIZE_DIR
]
2079 set gcc_runtest_parallelize_last
0
2081 proc gcc_parallel_test_run_p
{ testcase
} {
2082 global gcc_runtest_parallelize_counter
2083 global gcc_runtest_parallelize_counter_minor
2084 global gcc_runtest_parallelize_enable
2085 global gcc_runtest_parallelize_dir
2086 global gcc_runtest_parallelize_last
2088 if { $gcc_runtest_parallelize_enable
== 0 } {
2092 # Only test the filesystem
every 10th iteration
2093 incr gcc_runtest_parallelize_counter_minor
2094 if { $gcc_runtest_parallelize_counter_minor
== 10 } {
2095 set gcc_runtest_parallelize_counter_minor
0
2097 if { $gcc_runtest_parallelize_counter_minor
!= 1 } {
2098 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
2099 return $gcc_runtest_parallelize_last
2102 set path $gcc_runtest_parallelize_dir
/$gcc_runtest_parallelize_counter
2104 if {![catch
{open $path
{RDWR CREAT EXCL
} 0600} fd
]} {
2106 set gcc_runtest_parallelize_last
1
2107 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
2108 incr gcc_runtest_parallelize_counter
2111 set gcc_runtest_parallelize_last
0
2112 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
2113 incr gcc_runtest_parallelize_counter
2117 proc gcc_parallel_test_enable
{ val
} {
2118 global gcc_runtest_parallelize_enable
2119 set gcc_runtest_parallelize_enable $val
2122 rename runtest_file_p gcc_parallelize_saved_runtest_file_p
2123 proc runtest_file_p
{ runtests testcase
} {
2124 if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase
] {
2127 return [gcc_parallel_test_run_p $testcase
]
2132 proc gcc_parallel_test_run_p
{ testcase
} {
2136 proc gcc_parallel_test_enable
{ val
} {