1 # libstdc
++ "tool init file" for DejaGNU
3 # Copyright
(C
) 2001-2014 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
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 cxxvtvflags
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 libvtv. This is only required
for --enable
-vtable
-verify.
164 set libvtvdir
[lookfor_file $blddir
/..
/libvtv .libs
/libvtv.$shlib_ext
]
165 if {$libvtvdir
!= ""} {
167 set libvtvdir
[file dirname $libvtvdir
]
168 append ld_library_path_tmp
":${libvtvdir}"
169 verbose
-log "libvtv support detected"
173 # Locate libstdc
++ shared library.
(ie libstdc
++.so.
)
175 set sharedlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.$shlib_ext
]
176 if {$sharedlibdir
!= ""} {
177 if { ([string match
"*-*-linux*" $target_triplet]
178 ||
[string match
"*-*-gnu*" $target_triplet])
179 && [isnative
] } then {
181 verbose
-log "shared library support detected"
184 v3track v3
-sharedlib
3
186 set STATIC_LIBCXXFLAGS
""
187 set staticlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.a
]
188 if {$staticlibdir
!= ""} {
189 set staticlibdir
[file dirname $staticlibdir
]
190 # Some targets use libstdc
++.a
%s in their specs
, so they need a
191 #
-B option
for uninstalled testing.
192 set STATIC_LIBCXXFLAGS
" -B${staticlibdir} "
195 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
197 set compiler $
{gccdir
}/xg
++
198 set ld_library_path $
{ld_library_path_tmp
}
199 append ld_library_path
":${blddir}/src/.libs"
201 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
202 foreach i
"[exec $compiler --print-multi-lib]" {
204 regexp
-- "\[a-z0-9=_/\.-\]*;" $i mldir
205 set mldir
[string trimright $mldir
"\;@"]
206 if { "$mldir" == "." } {
209 if { [llength
[glob
-nocomplain $
{gccdir
}/$
{mldir
}/libgcc_s
*.so.
*]] >= 1 } {
210 append ld_library_path
":${gccdir}/${mldir}"
215 set_ld_library_path_env_vars
216 if [info exists env
(LD_LIBRARY_PATH
)] {
217 verbose
-log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
220 set compiler
[transform
"g++"]
223 #
Set the default timeout
for v3 tests.
227 set cxx
[transform
"g++"]
228 set cxxflags
"-D_GLIBCXX_ASSERT -fmessage-length=0"
232 set cc
[transform
"gcc"]
233 # Locate testsuite_hooks.h and other testsuite headers.
234 set includes
"-I${srcdir}/util"
235 # Adapt the defaults
for special circumstances.
236 if [is_remote host
] {
237 # A remote host does not
, in general
, have access to the
238 # $srcdir so we copy the testsuite headers into the current
239 # directory
, and
then add that to the search path.
240 foreach src
[glob
"${srcdir}/util/*.h" \
241 "${srcdir}/util/*.cc" \
242 "${srcdir}/util/*.tcc" \
243 "${srcdir}/util/*.hpp" \
244 "${srcdir}/util/*/*.h" \
245 "${srcdir}/util/*/*.cc" \
246 "${srcdir}/util/*/*.tcc" \
247 "${srcdir}/util/*/*.hpp" \
248 "${srcdir}/util/*/*/*.h" \
249 "${srcdir}/util/*/*/*.cc" \
250 "${srcdir}/util/*/*/*.tcc" \
251 "${srcdir}/util/*/*/*.hpp" \
252 "${srcdir}/util/*/*/*/*.h" \
253 "${srcdir}/util/*/*/*/*.cc" \
254 "${srcdir}/util/*/*/*/*.tcc" \
255 "${srcdir}/util/*/*/*/*.hpp" \
256 "${srcdir}/util/*/*/*/*/*.h" \
257 "${srcdir}/util/*/*/*/*/*.cc" \
258 "${srcdir}/util/*/*/*/*/*.tcc" \
259 "${srcdir}/util/*/*/*/*/*.hpp" ] {
260 # Remove everything up to
"util/..."
261 set dst
[string range $src
[string length
"${srcdir}/"] end]
262 # Create the directory containing the file.
263 set dir [file dirname $dst
]
264 remote_exec host
"mkdir" [list "-p" "$dir"]
266 set result
[remote_download host $src $dst
]
267 if { $result
== "" } {
268 verbose
-log "Unable to download ${srcdir}/${src} to host."
272 set includes
"-Iutil"
273 } elseif
{ [file
exists $flags_file
] } {
274 #
If we find a testsuite_flags file
, we
're testing in the build dir.
275 set cxx [exec sh $flags_file --build-cxx]
276 set cxxflags [exec sh $flags_file --cxxflags]
277 set cxxpchflags [exec sh $flags_file --cxxpchflags]
278 set cxxvtvflags [exec sh $flags_file --cxxvtvflags]
279 set cxxldflags [exec sh $flags_file --cxxldflags]
280 set cc [exec sh $flags_file --build-cc]
281 set includes [exec sh $flags_file --build-includes]
284 append cxxflags [getenv CXXFLAGS]
286 if ![regexp ".*-O" $cxxflags] {
287 append cxxflags " -g -O2"
292 # Should be as good as -fdiagnostics-color=never, but more compatible
294 # Always use MO files built by this test harness.
295 set ccflags "$cxxflags -DLOCALEDIR=\".\""
296 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
298 # If a PCH file is available, use it. We must delay performing
299 # this check until $cxx and such have been initialized because we
300 # perform a test compilation. (Ideally, gcc --print-file-name would
301 # list PCH files, but it does not.)
302 if { $cxxpchflags != "" } {
303 set src "config[pid].cc"
304 set f [open $src "w"]
305 puts $f "int main () {}"
308 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
309 # useful as then the requested variant of the pre-build PCH
310 # files could be tested to see if it works.
311 set lines [v3_target_compile $src "config[pid].o" object \
312 "additional_flags=-include additional_flags=bits/stdc++.h"]
313 if { $lines != "" } {
314 verbose -log "Requested PCH file: $cxxpchflags"
315 verbose -log "is not working, and will not be used."
320 v3track cxxpchflags 2
323 if ![info exists PCH_CXXFLAGS] then {
324 set PCH_CXXFLAGS $cxxpchflags
325 v3track PCH_CXXFLAGS 2
328 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
331 # Callback for cleanup routines.
332 proc libstdc++_exit { } {
335 if [info exists gluefile] {
336 file_on_build delete $gluefile;
341 # Callback from system dg-test.
342 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
343 # Set up the compiler flags, based on what we're going to
do.
346 set compile_type
"preprocess"
347 set output_file
"[file rootname [file tail $prog]].i"
350 set compile_type
"assembly"
351 set output_file
"[file rootname [file tail $prog]].s"
354 set compile_type
"object"
355 set output_file
"[file rootname [file tail $prog]].o"
358 set compile_type
"executable"
359 set output_file
"./[file rootname [file tail $prog]].exe"
362 set compile_type
"executable"
363 # FIXME
: "./" is to cope with "." not being in $PATH.
364 # Should this be handled elsewhere?
366 set output_file
"./[file rootname [file tail $prog]].exe"
367 # This is the only place where we care
if an executable was
368 # created or not.
If it was
, dg.exp will try to run it.
369 catch
{ remote_file build
delete $output_file
}
372 perror
"$do_what: not a valid dg-do keyword"
377 # Short
-circut a bunch of complicated goo here
for the special
378 # case of compiling a test file as a
"C" file, not as C++. Why? So
379 #
-nostdc
++ doesn
't trip us up. So all the extra object files
380 # don't trip us up. So automatically linking in libstdc
++ doesn
't
381 # happen. So CXXFLAGS don't error.
382 set select_compile
"v3_target_compile"
384 if { $extra_tool_flags
!= "" } {
385 verbose
-log "extra_tool_flags are:"
386 verbose
-log $extra_tool_flags
387 if { [string first
"-x c" $extra_tool_flags ] != -1 } {
388 verbose
-log "compiling and executing as C, not C++"
389 set edit_tool_flags $extra_tool_flags
390 regsub
-all
".x c" $edit_tool_flags "" edit_tool_flags
391 lappend options
"additional_flags=$edit_tool_flags"
392 set select_compile
"v3_target_compile_as_c"
394 lappend options
"additional_flags=$extra_tool_flags"
398 # There is a libstdc
++_compile made
for us by default
(via the tool
-
399 # and
-target file
), but the defaults are lacking in goodness.
400 set comp_output
[$select_compile
"$prog" "$output_file" "$compile_type" $options];
402 return [list $comp_output $output_file
]
405 # Override the DejaGnu dg
-test in order to clear flags after a test
, as
406 # is done
for compiler tests in gcc
-dg.exp.
408 if { [info procs saved
-dg
-test
] == [list
] } {
409 rename dg
-test saved
-dg
-test
411 proc dg
-test
{ args } {
412 global additional_prunes
414 global testname_with_flags
416 if { [ catch
{ eval saved
-dg
-test $
args } errmsg
] } {
417 set saved_info $errorInfo
418 set additional_prunes
""
419 if [info exists testname_with_flags
] {
420 unset testname_with_flags
423 error $errmsg $saved_info
425 set additional_prunes
""
427 if [info exists testname_with_flags
] {
428 unset testname_with_flags
433 # True
if the library supports wchar_t.
436 # True
if the library supports threads.
439 # True
if the library supports symbol versioning.
442 # Called from libstdc
++-dg
-test above. Calls
back into
system's
443 # target_compile to actually do the work.
444 proc v3_target_compile { source dest type options } {
452 global STATIC_LIBCXXFLAGS
454 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
455 lappend options "libs=${gluefile}"
456 lappend options "ldflags=${wrap_flags}"
460 set cxxlibglossflags [libgloss_link_flags]
461 set cxx_final [concat $cxx_final $cxxlibglossflags]
462 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
463 set cxx_final [concat $cxx_final $cxxflags]
464 set cxx_final [concat $cxx_final $cxxvtvflags]
465 set cxx_final [concat $cxx_final $includes]
467 # Flag setting based on type argument.
468 if { $type == "executable" } {
469 # Link the support objects into executables.
470 lappend options "additional_flags=./libtestc++.a $cxxldflags"
472 if { $type == "sharedlib" } {
473 # Don't link in anything.
474 set type
"executable"
478 lappend options
"compiler=$cxx_final"
479 lappend options
"timeout=[timeout_value]"
481 return [target_compile $source $dest $type $options
]
485 # Called from libstdc
++-dg
-test above
, but only
for "C" compilation.
486 # Calls
back into
system's target_compile to actually do the work.
487 proc v3_target_compile_as_c { source dest type options } {
495 global STATIC_LIBCXXFLAGS
497 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
498 lappend options "libs=${gluefile}"
499 lappend options "ldflags=${wrap_flags}"
502 set tname [target_info name]
504 set cxxlibglossflags [libgloss_link_flags]
505 set cc_final [concat $cc_final $cxxlibglossflags]
506 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
507 set cc_final [concat $cc_final $cxxflags]
508 set cc_final [concat $cc_final $includes]
509 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
511 # This is needed for "C" tests, as this type of test may need the
512 # C++ includes. And if we're not testing in the build directory
,
513 # the includes
variable is not likely to
include the necessary
515 if { ![file
exists $flags_file
] } {
516 # ??? We need a
--print
-include-dirs option to GCC
, so that
517 # we can avoid these hacks. The heuristics here will not
518 # work with non
-standard
--with
-includedir
= options.
519 set version
[remote_exec host $
{cc
} -dumpversion
]
520 # Remove the trailing newline from the output.
521 set version
[string trimright
[lindex $version
1]]
522 set machine
[remote_exec host $
{cc
} -dumpmachine
]
523 set machine
[string trimright
[lindex $machine
1]]
524 set comp_base_dir
[remote_exec host $
{cc
} --print
-prog
-name=cc1
]
525 set comp_base_dir
[lindex $comp_base_dir
1]
526 set comp_base_dir
[file dirname
[file dirname
[file dirname
[file dirname
[file dirname $comp_base_dir
]]]]]
527 #
For a cross compiler
, the header files will be located in a
528 # machine
-specific subdirectory.
529 set crossbase
"${comp_base_dir}/${machine}/include/c++/${version}"
530 set crosstarget
"${crossbase}/${machine}"
531 set cc_final
[concat $cc_final
"-I$crossbase -I$crosstarget"]
532 #
For a native compiler
, the header files will be located at
534 set includesbase
"${comp_base_dir}/include/c++/${version}"
535 set includestarget
"${includesbase}/${machine}"
536 set cc_final
[concat $cc_final
"-I$includesbase -I$includestarget"]
538 set libdir
"-L${comp_base_dir}/lib"
540 set libdir
"-L${blddir}/libsupc++/.libs"
541 set libdir
[concat $libdir
"-L${blddir}/src/.libs"]
544 set cc_final
[concat $cc_final
"$libdir"]
546 lappend options
"compiler=$cc_final"
547 lappend options
"timeout=[timeout_value]"
549 return [target_compile $source $dest $type $options
]
552 # Build the support objects linked in with the libstdc
++ tests. In
553 # addition
, set v3
-wchar_t
, v3
-threads
, and v3
-symver appropriately.
554 proc v3
-build_support
{ } {
562 # Figure out whether or not the library supports certain features.
568 set config_src
"config.cc"
569 set config_out
"config.ii"
570 set f
[open $config_src
"w"]
571 puts $f
"#include <bits/c++config.h>"
572 puts $f
"#include <bits/gthr.h>"
574 v3_target_compile $config_src $config_out preprocess
"additional_flags=-dN"
575 set file
[open $config_out r
]
576 set preprocessed
[read $file
]
578 if { [string first
"_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
579 verbose
-log "wchar_t support detected"
582 if { [string first
"_GLIBCXX_SYMVER" $preprocessed] != -1 } {
583 verbose
-log "symbol versioning support detected"
586 if { [string first
"__GTHREADS" $preprocessed] != -1 } {
587 verbose
-log "thread support detected"
591 # Try to build the MO files that are used by some of the locale
592 # tests.
If we can
't build them, that's OK
; it just means that
593 # those tests will fail.
594 foreach lang
[list
"fr" "de"] {
596 file
mkdir "$lang/LC_MESSAGES"
597 remote_exec
"build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
598 if [is_remote host
] {
599 remote_exec
"host" "mkdir" "-p $lang/LC_MESSAGES"
600 remote_download
"host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
605 # Build the support objects.
606 set source_files
[list testsuite_abi.cc testsuite_allocator.cc \
607 testsuite_character.cc testsuite_hooks.cc \
608 io
/verified_cmd_line_input.cc \
609 io
/prog_bar.cc performance
/time
/elapsed_timer.cc
]
610 foreach f $source_files
{
611 set obj [file rootname $f
].o
612 set object_file
[file tail $
obj]
613 #
Compile with
"-w" so that warnings issued by the compiler
614 #
do not prevent compilation.
615 if { [v3_target_compile $srcdir
/util
/$f $object_file
"object" \
616 [list
"incdir=$srcdir" "additional_flags=-w"]]
618 error
"could not compile $f"
620 append libtest_objs
"$object_file "
623 # Collect into libtestc
++.a
624 if [info exists env
(AR
)] {
627 set ar
[transform
"ar"]
629 set arargs
"-rc ./libtestc++.a ${libtest_objs}"
630 verbose
-log "$ar $arargs"
631 set result
[lindex
[remote_exec host
"$ar" "$arargs"] 0]
632 verbose
"link result is $result"
633 if { $result
== 0 } {
634 if [info exists env
(RANLIB
)] {
635 set ranlib $env
(RANLIB
)
637 set ranlib
[transform
"ranlib"]
639 set ranlibargs
"./libtestc++.a"
640 verbose
-log "$ranlib $ranlibargs"
641 set result
[lindex
[remote_exec host
"$ranlib" "$ranlibargs"] 0]
642 if { $result
!= 0 } {
643 error
"could not link libtestc++.a"
647 # Build
any shared objects needed
for regression testing.
648 if { $
{v3
-sharedlib
} == 1 } {
649 set source_files
[list testsuite_shared.cc
]
650 foreach f $source_files
{
651 set object_file
[file rootname $f
].so
652 #
Compile with
"-w" so that warnings issued by the compiler
653 #
do not prevent compilation.
654 if { [v3_target_compile $srcdir
/util
/$f $object_file
"sharedlib" \
655 [list
"incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC"]]
657 error
"could not compile $f"
663 proc check_v3_target_fileio
{ } {
664 global et_fileio_saved
665 global et_fileio_target_name
669 if { ![info exists et_fileio_target_name
] } {
670 set et_fileio_target_name
""
673 #
If the target has changed since we
set the cached value
, clear it.
674 set current_target
[current_target_name
]
675 if { $current_target
!= $et_fileio_target_name
} {
676 verbose
"check_v3_target_fileio: `$et_fileio_target_name'" 2
677 set et_fileio_target_name $current_target
678 if [info exists et_fileio_saved
] {
679 verbose
"check_v3_target_fileio: removing cached result" 2
680 unset et_fileio_saved
684 if [info exists et_fileio_saved
] {
685 verbose
"check_v3_target_fileio: using cached result" 2
687 set et_fileio_saved
0
689 #
Set up
, compile, and
execute a C
++ test
program that tries to use
691 set src fileio
[pid
].cc
692 set exe fileio
[pid
].x
693 set testfile
"cin_unget-1.txt"
694 v3
-copy
-files
"$srcdir/data/$testfile"
696 set f
[open $src
"w"]
697 puts $f
"#include <sys/types.h>"
698 puts $f
"#include <sys/stat.h>"
699 puts $f
"#include <fcntl.h>"
700 puts $f
"#include <unistd.h>"
701 puts $f
"#include <errno.h>"
702 puts $f
"#include <string.h>"
703 puts $f
"using namespace std;"
704 puts $f
"int main ()"
706 puts $f
" int fd = open (\"$testfile\", O_RDONLY);"
707 puts $f
" int ret = 0;"
708 puts $f
" char buf\[10\];"
709 puts $f
" if (fd == -1)"
713 puts $f
" if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
715 puts $f
" errno = 0;"
716 puts $f
" if (lseek (fd, 0, SEEK_CUR) != 0"
717 puts $f
" || read (fd, buf, 4) != 4"
718 puts $f
" || memcmp (buf, \"1234\", 4) != 0"
719 puts $f
" || lseek (fd, -2, SEEK_CUR) != 2"
720 puts $f
" || read (fd, buf, 2) != 2"
721 puts $f
" || memcmp (buf, \"34\", 2) != 0)"
723 puts $f
" close (fd);"
725 puts $f
" return ret;"
729 set lines
[v3_target_compile $src $exe executable
""]
732 if [string match
"" $lines] {
733 # No error message
, compilation succeeded.
734 set result
[$
{tool
}_load
"./$exe" "" ""]
735 set status [lindex $result
0]
736 remote_file build
delete $exe
738 verbose
"check_v3_target_fileio: status is <$status>" 2
740 if { $
status == "pass" } {
741 set et_fileio_saved
1
744 verbose
"check_v3_target_fileio: compilation failed" 2
747 return $et_fileio_saved
750 # Eventually we want C90
/C99 determining and switching from this.
751 proc check_v3_target_c_std
{ } {
752 global et_c_std_saved
753 global et_c_std_target_name
756 if { ![info exists et_c_std_target_name
] } {
757 set et_c_std_target_name
""
760 #
If the target has changed since we
set the cached value
, clear it.
761 set current_target
[current_target_name
]
762 if { $current_target
!= $et_c_std_target_name
} {
763 verbose
"check_v3_target_c_std: `$et_c_std_target_name'" 2
764 set et_c_std_target_name $current_target
765 if [info exists et_c_std_saved
] {
766 verbose
"check_v3_target_c_std: removing cached result" 2
771 if [info exists et_c_std_saved
] {
772 verbose
"check_v3_target_c_std: using cached result" 2
776 #
Set up
, compile, and
execute a C
++ test
program that tries to use
778 #
For math bits
, could use check_effective_target_c99_math.
779 set src fileio
[pid
].cc
780 set exe fileio
[pid
].x
782 set f
[open $src
"w"]
783 puts $f
"#include <tr1/cmath>"
784 puts $f
"#include <cstdlib>"
785 puts $f
"int main ()"
787 puts $f
" float f = 45.55;"
788 puts $f
" int i = std::tr1::isnan(f);"
790 puts $f
" using std::wctomb;"
795 set lines
[v3_target_compile $src $exe executable
""]
798 if [string match
"" $lines] {
799 # No error message
, compilation succeeded.
800 set result
[$
{tool
}_load
"./$exe" "" ""]
801 set status [lindex $result
0]
802 remote_file build
delete $exe
804 verbose
"check_v3_target_c_std: status is <$status>" 2
806 if { $
status == "pass" } {
810 verbose
"check_v3_target_c_std: compilation failed" 2
813 return $et_c_std_saved
816 proc check_v3_target_sharedlib
{ } {
818 return $
{v3
-sharedlib
}
821 proc check_v3_target_time
{ } {
823 global et_time_target_name
826 if { ![info exists et_time_target_name
] } {
827 set et_time_target_name
""
830 #
If the target has changed since we
set the cached value
, clear it.
831 set current_target
[current_target_name
]
832 if { $current_target
!= $et_time_target_name
} {
833 verbose
"check_v3_target_time: `$et_time_target_name'" 2
834 set et_time_target_name $current_target
835 if [info exists et_time_saved
] {
836 verbose
"check_v3_target_time: removing cached result" 2
841 if [info exists et_time_saved
] {
842 verbose
"check_v3_target_time: using cached result" 2
846 #
Set up and
compile a C
++ test
program that tries to use
850 set f
[open $src
"w"]
851 puts $f
"#include <time.h>"
852 puts $f
"using namespace std;"
853 puts $f
"int main ()"
859 set lines
[v3_target_compile $src
/dev
/null executable
""]
862 if [string match
"" $lines] {
863 # No error message
, compilation succeeded.
864 verbose
"check_v3_target_time: compilation succeeded" 2
867 verbose
"check_v3_target_time: compilation failed" 2
870 return $et_time_saved
873 proc check_v3_target_namedlocale
{ args } {
874 global et_namedlocale
879 #
Set up
, compile, and
execute a C
++ test
program that tries to use
880 # the required named locale.
881 set exe nlocale
[pid
].x
883 if ![file
exists .
/$exe
] {
884 set src nlocale
[pid
].cc
886 set f
[open $src
"w"]
887 puts $f
"#include <locale>"
888 puts $f
"#include <cstdio>"
889 puts $f
"using namespace std;"
890 puts $f
"int main (int argc, char** argv)"
894 puts $f
" locale(*(argv + 1));"
897 puts $f
" catch(...)"
899 puts $f
" printf(\"locale '%s' not supported\\n\", *(argv + 1));"
905 set lines
[v3_target_compile $src $exe executable
""]
908 if ![string match
"" $lines] {
909 verbose
"check_v3_target_namedlocale: compilation failed" 2
910 return $et_namedlocale
912 #
else No error message
, compilation succeeded.
915 set result
[$
{tool
}_load
"./$exe" "$args" ""]
916 set status [lindex $result
0]
918 verbose
"check_v3_target_namedlocale <$args>: status is <$status>" 2
920 if { $
status == "pass" } {
923 return $et_namedlocale
926 proc check_v3_target_debug_mode
{ } {
930 if { ![info exists et_debug_mode_target_name
] } {
931 set et_debug_mode_target_name
""
934 #
If the target has changed since we
set the cached value
, clear it.
935 set current_target
[current_target_name
]
936 if { $current_target
!= $et_debug_mode_target_name
} {
937 verbose
"check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
938 set et_debug_mode_target_name $current_target
939 if [info exists et_debug_mode
] {
940 verbose
"check_v3_target_debug_mode: removing cached result" 2
945 if [info exists et_debug_mode
] {
946 verbose
"check_v3_target_debug_mode: using cached result" 2
950 #
Set up and preprocess a C
++ test
program that depends
951 #
on debug
mode activated.
952 set src debug_mode
[pid
].cc
954 set f
[open $src
"w"]
955 puts $f
"#ifndef _GLIBCXX_DEBUG"
956 puts $f
"# error No debug mode"
960 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
963 if [string match
"" $lines] {
964 # No error message
, preprocessing succeeded.
968 verbose
"check_v3_target_debug_mode: $et_debug_mode" 2
969 return $et_debug_mode
972 proc check_v3_target_profile_mode
{ } {
973 global et_profile_mode
976 if { ![info exists et_profile_mode_target_name
] } {
977 set et_profile_mode_target_name
""
980 #
If the target has changed since we
set the cached value
, clear it.
981 set current_target
[current_target_name
]
982 if { $current_target
!= $et_profile_mode_target_name
} {
983 verbose
"check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
984 set et_profile_mode_target_name $current_target
985 if [info exists et_profile_mode
] {
986 verbose
"check_v3_target_profile_mode: removing cached result" 2
987 unset et_profile_mode
991 if [info exists et_profile_mode
] {
992 verbose
"check_v3_target_profile_mode: using cached result" 2
994 set et_profile_mode
0
996 #
Set up and preprocess a C
++ test
program that depends
997 #
on profile
mode activated.
998 set src profile_mode
[pid
].cc
1000 set f
[open $src
"w"]
1001 puts $f
"#ifndef _GLIBCXX_PROFILE"
1002 puts $f
"# error No profile mode"
1006 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1009 if [string match
"" $lines] {
1010 # No error message
, preprocessing succeeded.
1011 set et_profile_mode
1
1014 verbose
"check_v3_target_profile_mode: $et_profile_mode" 2
1015 return $et_profile_mode
1018 proc check_v3_target_normal_mode
{ } {
1019 global et_normal_mode
1022 if { ![info exists et_normal_mode_target_name
] } {
1023 set et_normal_mode_target_name
""
1026 #
If the target has changed since we
set the cached value
, clear it.
1027 set current_target
[current_target_name
]
1028 if { $current_target
!= $et_normal_mode_target_name
} {
1029 verbose
"check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1030 set et_normal_mode_target_name $current_target
1031 if [info exists et_normal_mode
] {
1032 verbose
"check_v3_target_normal_mode: removing cached result" 2
1033 unset et_normal_mode
1037 if [info exists et_normal_mode
] {
1038 verbose
"check_v3_target_normal_mode: using cached result" 2
1040 set et_normal_mode
0
1042 #
Set up and
compile a C
++ test
program that depends
1043 #
on normal mode activated.
1044 set src normal_mode
[pid
].cc
1046 set f
[open $src
"w"]
1047 puts $f
"#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1048 puts $f
"# error No normal mode"
1052 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1055 if [string match
"" $lines] {
1056 # No error message
, compilation succeeded.
1057 set et_normal_mode
1
1060 verbose
"check_v3_target_normal_mode: $et_normal_mode" 2
1061 return $et_normal_mode
1064 proc check_v3_target_parallel_mode
{ } {
1067 global et_parallel_mode
1071 if { ![info exists et_parallel_mode_target_name
] } {
1072 set et_parallel_mode_target_name
""
1075 #
If the target has changed since we
set the cached value
, clear it.
1076 set current_target
[current_target_name
]
1077 if { $current_target
!= $et_parallel_mode_target_name
} {
1078 verbose
"check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1079 set et_parallel_mode_target_name $current_target
1080 if [info exists et_parallel_mode
] {
1081 verbose
"check_v3_target_parallel_mode: removing cached result" 2
1082 unset et_parallel_mode
1086 if [info exists et_parallel_mode
] {
1087 verbose
"check_v3_target_parallel_mode: using cached result" 2
1089 set et_parallel_mode
0
1091 #
If 'make check-parallel' is running the test succeeds.
1092 if { $
{v3
-libgomp
} == 1 && [regexp
"libgomp" $cxxflags] } {
1093 set et_parallel_mode
1
1096 verbose
"check_v3_target_parallel_mode: $et_parallel_mode" 2
1097 return $et_parallel_mode
1100 proc check_v3_target_cstdint
{ } {
1102 global DEFAULT_CXXFLAGS
1107 if { ![info exists et_cstdint_target_name
] } {
1108 set et_cstdint_target_name
""
1111 #
If the target has changed since we
set the cached value
, clear it.
1112 set current_target
[current_target_name
]
1113 if { $current_target
!= $et_cstdint_target_name
} {
1114 verbose
"check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1115 set et_cstdint_target_name $current_target
1116 if [info exists et_cstdint
] {
1117 verbose
"check_v3_target_cstdint: removing cached result" 2
1122 if [info exists et_cstdint
] {
1123 verbose
"check_v3_target_cstdint: using cached result" 2
1127 #
Set up and preprocess a C
++0x test
program that depends
1128 #
on the C99 stdint facilities to be available.
1129 set src cstdint
[pid
].cc
1131 set f
[open $src
"w"]
1132 puts $f
"#include <tr1/cstdint>"
1133 puts $f
"#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1134 puts $f
"# error No C99 stdint"
1138 set cxxflags_saved $cxxflags
1139 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1141 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1142 set cxxflags $cxxflags_saved
1145 if [string match
"" $lines] {
1146 # No error message
, preprocess succeeded.
1149 verbose
"check_v3_target_cstdint: compilation failed" 2
1152 verbose
"check_v3_target_cstdint: $et_cstdint" 2
1156 proc check_v3_target_cmath
{ } {
1158 global DEFAULT_CXXFLAGS
1163 if { ![info exists et_c99_math_target_name
] } {
1164 set et_c99_math_target_name
""
1167 #
If the target has changed since we
set the cached value
, clear it.
1168 set current_target
[current_target_name
]
1169 if { $current_target
!= $et_c99_math_target_name
} {
1170 verbose
"check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1171 set et_c99_math_target_name $current_target
1172 if [info exists et_c99_math
] {
1173 verbose
"check_v3_target_c99_math: removing cached result" 2
1178 if [info exists et_c99_math
] {
1179 verbose
"check_v3_target_c99_math: using cached result" 2
1183 #
Set up and preprocess a C
++0x test
program that depends
1184 #
on the C99 math facilities to be available.
1185 set src c99_math
[pid
].cc
1187 set f
[open $src
"w"]
1188 puts $f
"#include <tr1/cmath>"
1189 puts $f
"#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1190 puts $f
"# error No C99 math"
1194 set cxxflags_saved $cxxflags
1195 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1197 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1198 set cxxflags $cxxflags_saved
1201 if [string match
"" $lines] {
1202 # No error message
, preprocess succeeded.
1205 verbose
"check_v3_target_c99_math: compilation failed" 2
1208 verbose
"check_v3_target_c99_math: $et_c99_math" 2
1212 proc check_v3_target_atomic_builtins
{ } {
1214 global DEFAULT_CXXFLAGS
1215 global et_atomic_builtins
1219 if { ![info exists et_atomic_builtins_target_name
] } {
1220 set et_atomic_builtins_target_name
""
1223 #
If the target has changed since we
set the cached value
, clear it.
1224 set current_target
[current_target_name
]
1225 if { $current_target
!= $et_atomic_builtins_target_name
} {
1226 verbose
"check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1227 set et_atomic_builtins_target_name $current_target
1228 if [info exists et_atomic_builtins
] {
1229 verbose
"check_v3_target_atomic_builtins: removing cached result" 2
1230 unset et_atomic_builtins
1234 if [info exists et_atomic_builtins
] {
1235 verbose
"check_v3_target_atomic_builtins: using cached result" 2
1237 set et_atomic_builtins
0
1239 #
Set up and preprocess a C
++0x test
program that depends
1240 #
on the atomic builtin facilities to be available.
1241 set src atomic_builtins
[pid
].cc
1243 set f
[open $src
"w"]
1244 puts $f
"#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1245 puts $f
"# error No atomic bool"
1247 puts $f
"#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1248 puts $f
"# error No atomic int"
1252 set cxxflags_saved $cxxflags
1253 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++0x"
1255 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1256 set cxxflags $cxxflags_saved
1259 if [string match
"" $lines] {
1260 # No error message
, preprocess succeeded.
1261 set et_atomic_builtins
1
1263 verbose
"check_v3_target_atomic_builtins: compilation failed" 2
1266 verbose
"check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1267 return $et_atomic_builtins
1270 proc check_v3_target_gthreads
{ } {
1272 global DEFAULT_CXXFLAGS
1277 if { ![info exists et_gthreads_target_name
] } {
1278 set et_gthreads_target_name
""
1281 #
If the target has changed since we
set the cached value
, clear it.
1282 set current_target
[current_target_name
]
1283 if { $current_target
!= $et_gthreads_target_name
} {
1284 verbose
"check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1285 set et_gthreads_target_name $current_target
1286 if [info exists et_gthreads
] {
1287 verbose
"check_v3_target_gthreads: removing cached result" 2
1292 if [info exists et_gthreads
] {
1293 verbose
"check_v3_target_gthreads: using cached result" 2
1297 #
Set up and preprocess a C
++0x test
program that depends
1298 #
on the gthreads facilities to be available.
1299 set src gthreads
[pid
].cc
1301 set f
[open $src
"w"]
1302 puts $f
"#include <bits/c++config.h>"
1303 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1304 puts $f
"# error No gthread"
1308 set cxxflags_saved $cxxflags
1309 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1311 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1312 set cxxflags $cxxflags_saved
1315 if [string match
"" $lines] {
1316 # No error message
, preprocessing succeeded.
1319 verbose
"check_v3_target_gthreads: compilation failed" 2
1322 verbose
"check_v3_target_gthreads: $et_gthreads" 2
1326 proc check_v3_target_gthreads_timed
{ } {
1328 global DEFAULT_CXXFLAGS
1329 global et_gthreads_timed
1333 if { ![info exists et_gthreads_timed_target_name
] } {
1334 set et_gthreads_timed_target_name
""
1337 #
If the target has changed since we
set the cached value
, clear it.
1338 set current_target
[current_target_name
]
1339 if { $current_target
!= $et_gthreads_timed_target_name
} {
1340 verbose
"check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1341 set et_gthreads_timed_target_name $current_target
1342 if [info exists et_gthreads_timed
] {
1343 verbose
"check_v3_target_gthreads_timed: removing cached result" 2
1344 unset et_gthreads_timed
1348 if [info exists et_gthreads_timed
] {
1349 verbose
"check_v3_target_gthreads_timed: using cached result" 2
1351 set et_gthreads_timed
0
1353 #
Set up and preprocess a C
++0x test
program that depends
1354 #
on the gthreads timed mutex facilities to be available.
1355 set src gthreads_timed
[pid
].cc
1357 set f
[open $src
"w"]
1358 puts $f
"#include <bits/c++config.h>"
1359 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1360 puts $f
"# error No gthread"
1362 puts $f
"#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1363 puts $f
"# error No gthread timed mutexes"
1367 set cxxflags_saved $cxxflags
1368 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1370 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1371 set cxxflags $cxxflags_saved
1374 if [string match
"" $lines] {
1375 # No error message
, preprocessing succeeded.
1376 set et_gthreads_timed
1
1378 verbose
"check_v3_target_gthreads_timed: compilation failed" 2
1381 verbose
"check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1382 return $et_gthreads_timed
1386 proc check_v3_target_sleep
{ } {
1388 global DEFAULT_CXXFLAGS
1393 if { ![info exists et_sleep_target_name
] } {
1394 set et_sleep_target_name
""
1397 #
If the target has changed since we
set the cached value
, clear it.
1398 set current_target
[current_target_name
]
1399 if { $current_target
!= $et_sleep_target_name
} {
1400 verbose
"check_v3_target_sleep: `$et_sleep_target_name'" 2
1401 set et_sleep_target_name $current_target
1402 if [info exists et_sleep
] {
1403 verbose
"check_v3_target_sleep: removing cached result" 2
1408 if [info exists et_sleep
] {
1409 verbose
"check_v3_target_sleep: using cached result" 2
1413 #
Set up and preprocess a C
++11 test
program that depends
1414 #
on the
sleep facilities to be available.
1415 set src
sleep[pid
].cc
1417 set f
[open $src
"w"]
1418 puts $f
"#include <bits/c++config.h>"
1419 puts $f
"#ifndef _GLIBCXX_USE_NANOSLEEP"
1420 puts $f
"# ifndef _GLIBCXX_HAVE_SLEEP"
1421 puts $f
"# error No nanosleep or sleep"
1426 set cxxflags_saved $cxxflags
1427 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1429 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1430 set cxxflags $cxxflags_saved
1433 if [string match
"" $lines] {
1434 # No error message
, preprocessing succeeded.
1437 verbose
"check_v3_target_sleep: compilation failed" 2
1440 verbose
"check_v3_target_sleep: $et_sleep" 2
1444 proc check_v3_target_sched_yield
{ } {
1446 global DEFAULT_CXXFLAGS
1447 global et_sched_yield
1451 if { ![info exists et_sched_yield_target_name
] } {
1452 set et_sched_yield_target_name
""
1455 #
If the target has changed since we
set the cached value
, clear it.
1456 set current_target
[current_target_name
]
1457 if { $current_target
!= $et_sched_yield_target_name
} {
1458 verbose
"check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1459 set et_sched_yield_target_name $current_target
1460 if [info exists et_sched_yield
] {
1461 verbose
"check_v3_target_sched_yield: removing cached result" 2
1462 unset et_sched_yield
1466 if [info exists et_sched_yield
] {
1467 verbose
"check_v3_target_sched_yield: using cached result" 2
1469 set et_sched_yield
0
1471 #
Set up and preprocess a C
++0x test
program that depends
1472 #
on the sched_yield facility to be available.
1473 set src sched_yield
[pid
].cc
1475 set f
[open $src
"w"]
1476 puts $f
"#include <bits/c++config.h>"
1477 puts $f
"#ifndef _GLIBCXX_USE_SCHED_YIELD"
1478 puts $f
"# error No sched yield"
1482 set cxxflags_saved $cxxflags
1483 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1485 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1486 set cxxflags $cxxflags_saved
1489 if [string match
"" $lines] {
1490 # No error message
, preprocessing succeeded.
1491 set et_sched_yield
1
1493 verbose
"check_v3_target_sched_yield: compilation failed" 2
1496 verbose
"check_v3_target_sched_yield: $et_sched_yield" 2
1497 return $et_sched_yield
1500 proc check_v3_target_string_conversions
{ } {
1502 global DEFAULT_CXXFLAGS
1503 global et_string_conversions
1507 if { ![info exists et_string_conversions_target_name
] } {
1508 set et_string_conversions_target_name
""
1511 #
If the target has changed since we
set the cached value
, clear it.
1512 set current_target
[current_target_name
]
1513 if { $current_target
!= $et_string_conversions_target_name
} {
1514 verbose
"check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1515 set et_string_conversions_target_name $current_target
1516 if [info exists et_string_conversions
] {
1517 verbose
"check_v3_target_string_conversions: removing cached result" 2
1518 unset et_string_conversions
1522 if [info exists et_string_conversions
] {
1523 verbose
"check_v3_target_string_conversions: using cached result" 2
1525 set et_string_conversions
0
1527 #
Set up and preprocess a C
++0x test
program that depends
1528 #
on the string_conversions facilities to be available.
1529 set src string_conversions
[pid
].cc
1531 set f
[open $src
"w"]
1532 puts $f
"#include <bits/c++config.h>"
1533 puts $f
"#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1534 puts $f
"# error No string conversions"
1538 set cxxflags_saved $cxxflags
1539 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1541 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1542 set cxxflags $cxxflags_saved
1545 if [string match
"" $lines] {
1546 # No error message
, preprocessing succeeded.
1547 set et_string_conversions
1
1549 verbose
"check_v3_target_string_conversions: compilation failed" 2
1552 verbose
"check_v3_target_string_conversions: $et_string_conversions" 2
1553 return $et_string_conversions
1556 proc check_v3_target_swprintf
{ } {
1558 global DEFAULT_CXXFLAGS
1563 if { ![info exists et_swprintf_target_name
] } {
1564 set et_swprintf_target_name
""
1567 #
If the target has changed since we
set the cached value
, clear it.
1568 set current_target
[current_target_name
]
1569 if { $current_target
!= $et_swprintf_target_name
} {
1570 verbose
"check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1571 set et_swprintf_target_name $current_target
1572 if [info exists et_swprintf
] {
1573 verbose
"check_v3_target_swprintf: removing cached result" 2
1578 if [info exists et_swprintf
] {
1579 verbose
"check_v3_target_swprintf: using cached result" 2
1583 #
Set up and preprocess a C
++0x test
program that depends
1584 #
on a standard swprintf function to be available.
1585 set src swprintf
[pid
].cc
1587 set f
[open $src
"w"]
1588 puts $f
"#include <bits/c++config.h>"
1589 puts $f
"#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1590 puts $f
"# error No swprintf"
1594 set cxxflags_saved $cxxflags
1595 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1597 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1598 set cxxflags $cxxflags_saved
1601 if [string match
"" $lines] {
1602 # No error message
, preprocessing succeeded.
1605 verbose
"check_v3_target_swprintf: compilation failed" 2
1608 verbose
"check_v3_target_swprintf: $et_swprintf" 2
1612 proc check_v3_target_binary_io
{ } {
1614 global DEFAULT_CXXFLAGS
1619 if { ![info exists et_binary_io_target_name
] } {
1620 set et_binary_io_target_name
""
1623 #
If the target has changed since we
set the cached value
, clear it.
1624 set current_target
[current_target_name
]
1625 if { $current_target
!= $et_binary_io_target_name
} {
1626 verbose
"check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1627 set et_binary_io_target_name $current_target
1628 if [info exists et_binary_io
] {
1629 verbose
"check_v3_target_binary_io: removing cached result" 2
1634 if [info exists et_binary_io
] {
1635 verbose
"check_v3_target_binary_io: using cached result" 2
1639 #
Set up and preprocess a C
++0x test
program that depends
1640 #
on text and binary I
/O being the same.
1641 set src binary_io
[pid
].cc
1643 set f
[open $src
"w"]
1644 puts $f
"#include <bits/c++config.h>"
1645 puts $f
"#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1646 puts $f
"# error No binary io"
1650 set cxxflags_saved $cxxflags
1651 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1653 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1654 set cxxflags $cxxflags_saved
1657 if [string match
"" $lines] {
1658 # No error message
, preprocessing succeeded.
1661 verbose
"check_v3_target_binary_io: compilation failed" 2
1664 verbose
"check_v3_target_binary_io: $et_binary_io" 2
1665 return $et_binary_io
1668 proc check_v3_target_nprocs
{ } {
1670 global DEFAULT_CXXFLAGS
1675 if { ![info exists et_nprocs_target_name
] } {
1676 set et_nprocs_target_name
""
1679 #
If the target has changed since we
set the cached value
, clear it.
1680 set current_target
[current_target_name
]
1681 if { $current_target
!= $et_nprocs_target_name
} {
1682 verbose
"check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1683 set et_nprocs_target_name $current_target
1684 if [info exists et_nprocs
] {
1685 verbose
"check_v3_target_nprocs: removing cached result" 2
1690 if [info exists et_nprocs
] {
1691 verbose
"check_v3_target_nprocs: using cached result" 2
1695 #
Set up and preprocess a C
++0x test
program that depends
1696 #
on either get_nprocs or sysconf to be available.
1697 set src nprocs
[pid
].cc
1699 set f
[open $src
"w"]
1700 puts $f
"#include <bits/c++config.h>"
1701 puts $f
"#if defined(_GLIBCXX_USE_GET_NPROCS)"
1702 puts $f
"#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1703 puts $f
"#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1704 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1705 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
1707 puts $f
"# error hardware_concurrency not implemented"
1711 set cxxflags_saved $cxxflags
1712 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1714 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1715 set cxxflags $cxxflags_saved
1718 if [string match
"" $lines] {
1719 # No error message
, preprocess succeeded.
1722 verbose
"check_v3_target_nprocs: compilation failed" 2
1725 verbose
"check_v3_target_nprocs: $et_nprocs" 2
1729 proc check_v3_target_static_libstdcxx
{ } {
1731 global DEFAULT_CXXFLAGS
1732 global et_static_libstdcxx
1736 if [info exists et_static_libstdcxx
] {
1737 verbose
"check_v3_target_static_libstdcxx: using cached result" 2
1739 set et_static_libstdcxx
0
1741 #
Set up and link a C
++0x test
program that depends
1743 set src static
-maybe
[pid
].cc
1745 set f
[open $src
"w"]
1746 puts $f
"#include <iostream>"
1747 puts $f
"int main() {"
1748 puts $f
"int i(415);"
1749 puts $f
"std::cout<< i << std::endl;"
1750 puts $f
"return 0; }"
1754 set cxxflags_saved $cxxflags
1755 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -static-libstdc++"
1757 set lines
[v3_target_compile $src
/dev
/null executable
""]
1758 set cxxflags $cxxflags_saved
1761 if [string match
"" $lines] {
1762 # No error message
, link succeeded.
1763 set et_static_libstdcxx
1
1765 verbose
"check_v3_target_static_libstdcxx: compilation failed" 2
1768 verbose
"check_v3_target_static_libstdcxx: $et_static_libstdcxx" 2
1769 return $et_static_libstdcxx
1772 proc check_v3_target_little_endian
{ } {
1774 global DEFAULT_CXXFLAGS
1775 global et_little_endian
1779 if { ![info exists et_little_endian_target_name
] } {
1780 set et_little_endian_target_name
""
1783 #
If the target has changed since we
set the cached value
, clear it.
1784 set current_target
[current_target_name
]
1785 if { $current_target
!= $et_little_endian_target_name
} {
1786 verbose
"check_v3_target_little_endian: `$et_little_endian_target_name'" 2
1787 set et_little_endian_target_name $current_target
1788 if [info exists et_little_endian
] {
1789 verbose
"check_v3_target_little_endian: removing cached result" 2
1790 unset et_little_endian
1794 if [info exists et_little_endian
] {
1795 verbose
"check_v3_target_little_endian: using cached result" 2
1797 set et_little_endian
0
1799 set src little_endian
[pid
].cc
1801 set f
[open $src
"w"]
1802 puts $f
"#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__"
1803 puts $f
"# error Not little endian"
1807 set cxxflags_saved $cxxflags
1808 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1810 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1811 set cxxflags $cxxflags_saved
1814 if [string match
"" $lines] {
1815 # No error message
, preprocessing succeeded.
1816 set et_little_endian
1
1818 verbose
"check_v3_target_little_endian: compilation failed" 2
1821 verbose
"check_v3_target_little_endian: $et_little_endian" 2
1822 return $et_little_endian
1825 set additional_prunes
""
1827 if { [info exists env
(GCC_RUNTEST_PARALLELIZE_DIR
)] \
1828 && [info procs runtest_file_p
] != [list
] \
1829 && [info procs gcc_parallelize_saved_runtest_file_p
] == [list
] } then {
1830 global gcc_runtest_parallelize_counter
1831 global gcc_runtest_parallelize_counter_minor
1832 global gcc_runtest_parallelize_enable
1833 global gcc_runtest_parallelize_dir
1834 global gcc_runtest_parallelize_last
1836 set gcc_runtest_parallelize_counter
0
1837 set gcc_runtest_parallelize_counter_minor
0
1838 set gcc_runtest_parallelize_enable
1
1839 set gcc_runtest_parallelize_dir
[getenv GCC_RUNTEST_PARALLELIZE_DIR
]
1840 set gcc_runtest_parallelize_last
0
1842 proc gcc_parallel_test_run_p
{ testcase
} {
1843 global gcc_runtest_parallelize_counter
1844 global gcc_runtest_parallelize_counter_minor
1845 global gcc_runtest_parallelize_enable
1846 global gcc_runtest_parallelize_dir
1847 global gcc_runtest_parallelize_last
1849 if { $gcc_runtest_parallelize_enable
== 0 } {
1853 # Only test the filesystem
every 10th iteration
1854 incr gcc_runtest_parallelize_counter_minor
1855 if { $gcc_runtest_parallelize_counter_minor
== 10 } {
1856 set gcc_runtest_parallelize_counter_minor
0
1858 if { $gcc_runtest_parallelize_counter_minor
!= 1 } {
1859 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
1860 return $gcc_runtest_parallelize_last
1863 set path $gcc_runtest_parallelize_dir
/$gcc_runtest_parallelize_counter
1865 if {![catch
{open $path
{RDWR CREAT EXCL
} 0600} fd
]} {
1867 set gcc_runtest_parallelize_last
1
1868 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
1869 incr gcc_runtest_parallelize_counter
1872 set gcc_runtest_parallelize_last
0
1873 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
1874 incr gcc_runtest_parallelize_counter
1878 proc gcc_parallel_test_enable
{ val
} {
1879 global gcc_runtest_parallelize_enable
1880 set gcc_runtest_parallelize_enable $val
1883 rename runtest_file_p gcc_parallelize_saved_runtest_file_p
1884 proc runtest_file_p
{ runtests testcase
} {
1885 if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase
] {
1888 return [gcc_parallel_test_run_p $testcase
]
1893 proc gcc_parallel_test_run_p
{ testcase
} {
1897 proc gcc_parallel_test_enable
{ val
} {