1 # libstdc
++ "tool init file" for DejaGNU
3 # Copyright
(C
) 2001-2015 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 # Many hosts now default to a non
-ASCII C locale
, however
, so
111 # they can
set a
charset encoding here
if they need.
112 if { [ishost
"*-*-cygwin*"] } {
113 setenv LC_ALL C.ASCII
117 set blddir
[lookfor_file
[get_multilibs
] libstdc
++-v3
]
118 set flags_file
"${blddir}/scripts/testsuite_flags"
119 set shlib_ext
[get_shlib_extension
]
122 #
If a test doesn
't have special options, use DEFAULT_CXXFLAGS.
123 # Use this variable if the behavior
124 # 1) only applies to libstdc++ testing
125 # 2) might need to be negated
126 # In particular, some tests have to be run without precompiled
127 # headers, or without assertions.
129 if ![info exists DEFAULT_CXXFLAGS] then {
130 set DEFAULT_CXXFLAGS ""
131 # Host specific goo here.
132 if { [string match "powerpc-*-darwin*" $target_triplet] } {
133 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
136 v3track DEFAULT_CXXFLAGS 2
138 # By default, we assume we want to run program images.
139 global dg-do-what-default
140 set dg-do-what-default run
142 # Copy any required data files.
143 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
144 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
146 set ld_library_path_tmp ""
148 # Locate libgcc.a so we don't need to account
for different
values of
149 # SHLIB_EXT
on different platforms
150 set gccdir
[lookfor_file $tool_root_dir gcc
/libgcc.a
]
152 set gccdir
[file dirname $gccdir
]
153 append ld_library_path_tmp
":${gccdir}"
157 # Locate libgomp. This is only required
for parallel
mode.
159 set libgompdir
[lookfor_file $blddir
/..
/libgomp .libs
/libgomp.$shlib_ext
]
160 if {$libgompdir
!= ""} {
162 set libgompdir
[file dirname $libgompdir
]
163 append ld_library_path_tmp
":${libgompdir}"
164 verbose
-log "libgomp support detected"
168 # Locate libvtv. This is only required
for --enable
-vtable
-verify.
170 set libvtvdir
[lookfor_file $blddir
/..
/libvtv .libs
/libvtv.$shlib_ext
]
171 if {$libvtvdir
!= ""} {
173 set libvtvdir
[file dirname $libvtvdir
]
174 append ld_library_path_tmp
":${libvtvdir}"
175 verbose
-log "libvtv support detected"
179 # Locate libstdc
++ shared library.
(ie libstdc
++.so.
)
181 set sharedlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.$shlib_ext
]
182 if {$sharedlibdir
!= ""} {
183 if { ([string match
"*-*-linux*" $target_triplet]
184 ||
[string match
"*-*-gnu*" $target_triplet])
185 && [isnative
] } then {
187 verbose
-log "shared library support detected"
190 v3track v3
-sharedlib
3
192 set STATIC_LIBCXXFLAGS
""
193 set staticlibdir
[lookfor_file $blddir src
/.libs
/libstdc
++.a
]
194 if {$staticlibdir
!= ""} {
195 set staticlibdir
[file dirname $staticlibdir
]
196 # Some targets use libstdc
++.a
%s in their specs
, so they need a
197 #
-B option
for uninstalled testing.
198 set STATIC_LIBCXXFLAGS
" -B${staticlibdir} "
201 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
203 set compiler $
{gccdir
}/xg
++
204 set ld_library_path $
{ld_library_path_tmp
}
205 append ld_library_path
":${blddir}/src/.libs"
207 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
208 foreach i
"[exec $compiler --print-multi-lib]" {
210 regexp
-- "\[a-z0-9=_/\.-\]*;" $i mldir
211 set mldir
[string trimright $mldir
"\;@"]
212 if { "$mldir" == "." } {
215 if { [llength
[glob
-nocomplain $
{gccdir
}/$
{mldir
}/libgcc_s
*.so.
*]] >= 1 } {
216 append ld_library_path
":${gccdir}/${mldir}"
221 set_ld_library_path_env_vars
222 if [info exists env
(LD_LIBRARY_PATH
)] {
223 verbose
-log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
226 set compiler
[transform
"g++"]
229 #
Set the default timeout
for v3 tests.
233 set cxx
[transform
"g++"]
234 set cxxflags
"-D_GLIBCXX_ASSERT -fmessage-length=0"
238 set cc
[transform
"gcc"]
239 # Locate testsuite_hooks.h and other testsuite headers.
240 set includes
"-I${srcdir}/util"
241 # Adapt the defaults
for special circumstances.
242 if [is_remote host
] {
243 # A remote host does not
, in general
, have access to the
244 # $srcdir so we copy the testsuite headers into the current
245 # directory
, and
then add that to the search path.
246 foreach src
[glob
"${srcdir}/util/*.h" \
247 "${srcdir}/util/*.cc" \
248 "${srcdir}/util/*.tcc" \
249 "${srcdir}/util/*.hpp" \
250 "${srcdir}/util/*/*.h" \
251 "${srcdir}/util/*/*.cc" \
252 "${srcdir}/util/*/*.tcc" \
253 "${srcdir}/util/*/*.hpp" \
254 "${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 # Remove everything up to
"util/..."
267 set dst
[string range $src
[string length
"${srcdir}/"] end]
268 # Create the directory containing the file.
269 set dir [file dirname $dst
]
270 remote_exec host
"mkdir" [list "-p" "$dir"]
272 set result
[remote_download host $src $dst
]
273 if { $result
== "" } {
274 verbose
-log "Unable to download ${srcdir}/${src} to host."
278 set includes
"-Iutil"
279 } elseif
{ [file
exists $flags_file
] } {
280 #
If we find a testsuite_flags file
, we
're testing in the build dir.
281 set cxx [exec sh $flags_file --build-cxx]
282 set cxxflags [exec sh $flags_file --cxxflags]
283 set cxxpchflags [exec sh $flags_file --cxxpchflags]
284 set cxxvtvflags [exec sh $flags_file --cxxvtvflags]
285 set cxxldflags [exec sh $flags_file --cxxldflags]
286 set cc [exec sh $flags_file --build-cc]
287 set includes [exec sh $flags_file --build-includes]
290 append cxxflags [getenv CXXFLAGS]
292 if ![regexp ".*-O" $cxxflags] {
293 append cxxflags " -g -O2"
298 # Should be as good as -fdiagnostics-color=never, but more compatible
300 # Always use MO files built by this test harness.
301 set ccflags "$cxxflags -DLOCALEDIR=\".\""
302 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
304 # If a PCH file is available, use it. We must delay performing
305 # this check until $cxx and such have been initialized because we
306 # perform a test compilation. (Ideally, gcc --print-file-name would
307 # list PCH files, but it does not.)
308 if { $cxxpchflags != "" } {
309 set src "config[pid].cc"
310 set f [open $src "w"]
311 puts $f "int main () {}"
314 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
315 # useful as then the requested variant of the pre-build PCH
316 # files could be tested to see if it works.
317 set lines [v3_target_compile $src "config[pid].o" object \
318 "additional_flags=-include additional_flags=bits/stdc++.h"]
319 if { $lines != "" } {
320 verbose -log "Requested PCH file: $cxxpchflags"
321 verbose -log "is not working, and will not be used."
326 v3track cxxpchflags 2
329 if ![info exists PCH_CXXFLAGS] then {
330 set PCH_CXXFLAGS $cxxpchflags
331 v3track PCH_CXXFLAGS 2
334 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
337 # Callback for cleanup routines.
338 proc libstdc++_exit { } {
341 if [info exists gluefile] {
342 file_on_build delete $gluefile;
347 # Callback from system dg-test.
348 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
349 # Set up the compiler flags, based on what we're going to
do.
352 set compile_type
"preprocess"
353 set output_file
"[file rootname [file tail $prog]].i"
356 set compile_type
"assembly"
357 set output_file
"[file rootname [file tail $prog]].s"
360 set compile_type
"object"
361 set output_file
"[file rootname [file tail $prog]].o"
364 set compile_type
"executable"
365 set output_file
"./[file rootname [file tail $prog]].exe"
368 set compile_type
"executable"
369 # FIXME
: "./" is to cope with "." not being in $PATH.
370 # Should this be handled elsewhere?
372 set output_file
"./[file rootname [file tail $prog]].exe"
373 # This is the only place where we care
if an executable was
374 # created or not.
If it was
, dg.exp will try to run it.
375 catch
{ remote_file build
delete $output_file
}
378 perror
"$do_what: not a valid dg-do keyword"
383 # Short
-circut a bunch of complicated goo here
for the special
384 # case of compiling a test file as a
"C" file, not as C++. Why? So
385 #
-nostdc
++ doesn
't trip us up. So all the extra object files
386 # don't trip us up. So automatically linking in libstdc
++ doesn
't
387 # happen. So CXXFLAGS don't error.
388 set select_compile
"v3_target_compile"
390 if { $extra_tool_flags
!= "" } {
391 verbose
-log "extra_tool_flags are:"
392 verbose
-log $extra_tool_flags
393 if { [string first
"-x c" $extra_tool_flags ] != -1 } {
394 verbose
-log "compiling and executing as C, not C++"
395 set edit_tool_flags $extra_tool_flags
396 regsub
-all
".x c" $edit_tool_flags "" edit_tool_flags
397 lappend options
"additional_flags=$edit_tool_flags"
398 set select_compile
"v3_target_compile_as_c"
400 lappend options
"additional_flags=$extra_tool_flags"
404 # There is a libstdc
++_compile made
for us by default
(via the tool
-
405 # and
-target file
), but the defaults are lacking in goodness.
406 set comp_output
[$select_compile
"$prog" "$output_file" "$compile_type" $options];
408 return [list $comp_output $output_file
]
411 # Override the DejaGnu dg
-test in order to clear flags after a test
, as
412 # is done
for compiler tests in gcc
-dg.exp.
414 if { [info procs saved
-dg
-test
] == [list
] } {
415 rename dg
-test saved
-dg
-test
417 proc dg
-test
{ args } {
418 global additional_prunes
420 global testname_with_flags
422 if { [ catch
{ eval saved
-dg
-test $
args } errmsg
] } {
423 set saved_info $errorInfo
424 set additional_prunes
""
425 if [info exists testname_with_flags
] {
426 unset testname_with_flags
429 error $errmsg $saved_info
431 set additional_prunes
""
433 if [info exists testname_with_flags
] {
434 unset testname_with_flags
439 # True
if the library supports wchar_t.
442 # True
if the library supports threads.
445 # True
if the library supports symbol versioning.
448 # Called from libstdc
++-dg
-test above. Calls
back into
system's
449 # target_compile to actually do the work.
450 proc v3_target_compile { source dest type options } {
458 global STATIC_LIBCXXFLAGS
461 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
462 lappend options "libs=${gluefile}"
463 lappend options "ldflags=${wrap_flags}"
467 set cxxlibglossflags [libgloss_link_flags]
468 set cxx_final [concat $cxx_final $cxxlibglossflags]
469 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
470 set cxx_final [concat $cxx_final $cxxflags]
471 set cxx_final [concat $cxx_final $cxxvtvflags]
472 set cxx_final [concat $cxx_final $includes]
474 # Flag setting based on type argument.
475 if { $type == "executable" } {
476 # Link the support objects into executables.
477 lappend options "additional_flags=./libtestc++.a $cxxldflags"
479 if { $type == "sharedlib" } {
480 # Don't link in anything.
481 set type
"executable"
485 lappend options
"compiler=$cxx_final"
486 lappend options
"timeout=[timeout_value]"
488 set comp_output
[target_compile $source $dest $type $options
]
494 # Called from libstdc
++-dg
-test above
, but only
for "C" compilation.
495 # Calls
back into
system's target_compile to actually do the work.
496 proc v3_target_compile_as_c { source dest type options } {
504 global STATIC_LIBCXXFLAGS
507 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
508 lappend options "libs=${gluefile}"
509 lappend options "ldflags=${wrap_flags}"
512 set tname [target_info name]
514 set cxxlibglossflags [libgloss_link_flags]
515 set cc_final [concat $cc_final $cxxlibglossflags]
516 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
517 set cc_final [concat $cc_final $cxxflags]
518 set cc_final [concat $cc_final $includes]
519 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
521 # This is needed for "C" tests, as this type of test may need the
522 # C++ includes. And if we're not testing in the build directory
,
523 # the includes
variable is not likely to
include the necessary
525 if { ![file
exists $flags_file
] } {
526 # ??? We need a
--print
-include-dirs option to GCC
, so that
527 # we can avoid these hacks. The heuristics here will not
528 # work with non
-standard
--with
-includedir
= options.
529 set version
[remote_exec host $
{cc
} -dumpversion
]
530 # Remove the trailing newline from the output.
531 set version
[string trimright
[lindex $version
1]]
532 set machine
[remote_exec host $
{cc
} -dumpmachine
]
533 set machine
[string trimright
[lindex $machine
1]]
534 set comp_base_dir
[remote_exec host $
{cc
} --print
-prog
-name=cc1
]
535 set comp_base_dir
[lindex $comp_base_dir
1]
536 set comp_base_dir
[file dirname
[file dirname
[file dirname
[file dirname
[file dirname $comp_base_dir
]]]]]
537 #
For a cross compiler
, the header files will be located in a
538 # machine
-specific subdirectory.
539 set crossbase
"${comp_base_dir}/${machine}/include/c++/${version}"
540 set crosstarget
"${crossbase}/${machine}"
541 set cc_final
[concat $cc_final
"-I$crossbase -I$crosstarget"]
542 #
For a native compiler
, the header files will be located at
544 set includesbase
"${comp_base_dir}/include/c++/${version}"
545 set includestarget
"${includesbase}/${machine}"
546 set cc_final
[concat $cc_final
"-I$includesbase -I$includestarget"]
548 set libdir
"-L${comp_base_dir}/lib"
550 set libdir
"-L${blddir}/libsupc++/.libs"
551 set libdir
[concat $libdir
"-L${blddir}/src/.libs"]
554 set cc_final
[concat $cc_final
"$libdir"]
556 lappend options
"compiler=$cc_final"
557 lappend options
"timeout=[timeout_value]"
559 set comp_output
[target_compile $source $dest $type $options
]
564 # Build the support objects linked in with the libstdc
++ tests. In
565 # addition
, set v3
-wchar_t
, v3
-threads
, and v3
-symver appropriately.
566 proc v3
-build_support
{ } {
574 # Figure out whether or not the library supports certain features.
580 set config_src
"config.cc"
581 set config_out
"config.ii"
582 set f
[open $config_src
"w"]
583 puts $f
"#include <bits/c++config.h>"
584 puts $f
"#include <bits/gthr.h>"
586 v3_target_compile $config_src $config_out preprocess
"additional_flags=-dN"
587 set file
[open $config_out r
]
588 set preprocessed
[read $file
]
590 if { [string first
"_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
591 verbose
-log "wchar_t support detected"
594 if { [string first
"_GLIBCXX_SYMVER" $preprocessed] != -1 } {
595 verbose
-log "symbol versioning support detected"
598 if { [string first
"__GTHREADS" $preprocessed] != -1 } {
599 verbose
-log "thread support detected"
603 # Try to build the MO files that are used by some of the locale
604 # tests.
If we can
't build them, that's OK
; it just means that
605 # those tests will fail.
606 foreach lang
[list
"fr" "de"] {
608 file
mkdir "$lang/LC_MESSAGES"
609 remote_exec
"build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
610 if [is_remote host
] {
611 remote_exec
"host" "mkdir" "-p $lang/LC_MESSAGES"
612 remote_download
"host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
617 # Build the support objects.
618 set source_files
[list testsuite_abi.cc testsuite_allocator.cc \
619 testsuite_character.cc testsuite_hooks.cc \
620 io
/verified_cmd_line_input.cc \
621 io
/prog_bar.cc performance
/time
/elapsed_timer.cc
]
622 foreach f $source_files
{
623 set obj [file rootname $f
].o
624 set object_file
[file tail $
obj]
625 #
Compile with
"-w" so that warnings issued by the compiler
626 #
do not prevent compilation.
627 if { [v3_target_compile $srcdir
/util
/$f $object_file
"object" \
628 [list
"incdir=$srcdir" "additional_flags=-w"]]
630 error
"could not compile $f"
632 append libtest_objs
"$object_file "
635 # Collect into libtestc
++.a
636 if [info exists env
(AR
)] {
639 set ar
[transform
"ar"]
641 set arargs
"-rc ./libtestc++.a ${libtest_objs}"
642 verbose
-log "$ar $arargs"
643 set result
[lindex
[remote_exec host
"$ar" "$arargs"] 0]
644 verbose
"link result is $result"
645 if { $result
== 0 } {
646 if [info exists env
(RANLIB
)] {
647 set ranlib $env
(RANLIB
)
649 set ranlib
[transform
"ranlib"]
651 set ranlibargs
"./libtestc++.a"
652 verbose
-log "$ranlib $ranlibargs"
653 set result
[lindex
[remote_exec host
"$ranlib" "$ranlibargs"] 0]
654 if { $result
!= 0 } {
655 error
"could not link libtestc++.a"
659 # Build
any shared objects needed
for regression testing.
660 if { $
{v3
-sharedlib
} == 1 } {
661 set source_files
[list testsuite_shared.cc
]
662 foreach f $source_files
{
663 set object_file
[file rootname $f
].so
664 #
Compile with
"-w" so that warnings issued by the compiler
665 #
do not prevent compilation.
666 if { [v3_target_compile $srcdir
/util
/$f $object_file
"sharedlib" \
667 [list
"incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC"]]
669 error
"could not compile $f"
675 proc check_v3_target_fileio
{ } {
676 global et_fileio_saved
677 global et_fileio_target_name
681 if { ![info exists et_fileio_target_name
] } {
682 set et_fileio_target_name
""
685 #
If the target has changed since we
set the cached value
, clear it.
686 set current_target
[current_target_name
]
687 if { $current_target
!= $et_fileio_target_name
} {
688 verbose
"check_v3_target_fileio: `$et_fileio_target_name'" 2
689 set et_fileio_target_name $current_target
690 if [info exists et_fileio_saved
] {
691 verbose
"check_v3_target_fileio: removing cached result" 2
692 unset et_fileio_saved
696 if [info exists et_fileio_saved
] {
697 verbose
"check_v3_target_fileio: using cached result" 2
699 set et_fileio_saved
0
701 #
Set up
, compile, and
execute a C
++ test
program that tries to use
703 set src fileio
[pid
].cc
704 set exe fileio
[pid
].x
705 set testfile
"cin_unget-1.[pid].txt"
706 v3
-copy
-file
"$srcdir/data/cin_unget-1.txt" "$testfile"
708 set f
[open $src
"w"]
709 puts $f
"#include <sys/types.h>"
710 puts $f
"#include <sys/stat.h>"
711 puts $f
"#include <fcntl.h>"
712 puts $f
"#include <unistd.h>"
713 puts $f
"#include <errno.h>"
714 puts $f
"#include <string.h>"
715 puts $f
"using namespace std;"
716 puts $f
"int main ()"
718 puts $f
" int fd = open (\"$testfile\", O_RDONLY);"
719 puts $f
" int ret = 0;"
720 puts $f
" char buf\[10\];"
721 puts $f
" if (fd == -1)"
725 puts $f
" if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
727 puts $f
" errno = 0;"
728 puts $f
" if (lseek (fd, 0, SEEK_CUR) != 0"
729 puts $f
" || read (fd, buf, 4) != 4"
730 puts $f
" || memcmp (buf, \"1234\", 4) != 0"
731 puts $f
" || lseek (fd, -2, SEEK_CUR) != 2"
732 puts $f
" || read (fd, buf, 2) != 2"
733 puts $f
" || memcmp (buf, \"34\", 2) != 0)"
735 puts $f
" close (fd);"
737 puts $f
" return ret;"
741 set lines
[v3_target_compile $src $exe executable
""]
744 if [string match
"" $lines] {
745 # No error message
, compilation succeeded.
746 set result
[$
{tool
}_load
"./$exe" "" ""]
747 set status [lindex $result
0]
748 remote_file build
delete $exe
750 verbose
"check_v3_target_fileio: status is <$status>" 2
752 if { $
status == "pass" } {
753 set et_fileio_saved
1
756 verbose
"check_v3_target_fileio: compilation failed" 2
759 return $et_fileio_saved
762 # Eventually we want C90
/C99 determining and switching from this.
763 proc check_v3_target_c_std
{ } {
764 global et_c_std_saved
765 global et_c_std_target_name
768 if { ![info exists et_c_std_target_name
] } {
769 set et_c_std_target_name
""
772 #
If the target has changed since we
set the cached value
, clear it.
773 set current_target
[current_target_name
]
774 if { $current_target
!= $et_c_std_target_name
} {
775 verbose
"check_v3_target_c_std: `$et_c_std_target_name'" 2
776 set et_c_std_target_name $current_target
777 if [info exists et_c_std_saved
] {
778 verbose
"check_v3_target_c_std: removing cached result" 2
783 if [info exists et_c_std_saved
] {
784 verbose
"check_v3_target_c_std: using cached result" 2
788 #
Set up
, compile, and
execute a C
++ test
program that tries to use
790 #
For math bits
, could use check_effective_target_c99_math.
791 set src fileio
[pid
].cc
792 set exe fileio
[pid
].x
794 set f
[open $src
"w"]
795 puts $f
"#include <tr1/cmath>"
796 puts $f
"#include <cstdlib>"
797 puts $f
"int main ()"
799 puts $f
" float f = 45.55;"
800 puts $f
" int i = std::tr1::isnan(f);"
802 puts $f
" using std::wctomb;"
807 set lines
[v3_target_compile $src $exe executable
""]
810 if [string match
"" $lines] {
811 # No error message
, compilation succeeded.
812 set result
[$
{tool
}_load
"./$exe" "" ""]
813 set status [lindex $result
0]
814 remote_file build
delete $exe
816 verbose
"check_v3_target_c_std: status is <$status>" 2
818 if { $
status == "pass" } {
822 verbose
"check_v3_target_c_std: compilation failed" 2
825 return $et_c_std_saved
828 proc check_v3_target_sharedlib
{ } {
830 return $
{v3
-sharedlib
}
833 proc check_v3_target_time
{ } {
835 global et_time_target_name
838 if { ![info exists et_time_target_name
] } {
839 set et_time_target_name
""
842 #
If the target has changed since we
set the cached value
, clear it.
843 set current_target
[current_target_name
]
844 if { $current_target
!= $et_time_target_name
} {
845 verbose
"check_v3_target_time: `$et_time_target_name'" 2
846 set et_time_target_name $current_target
847 if [info exists et_time_saved
] {
848 verbose
"check_v3_target_time: removing cached result" 2
853 if [info exists et_time_saved
] {
854 verbose
"check_v3_target_time: using cached result" 2
858 #
Set up and
compile a C
++ test
program that tries to use
862 set f
[open $src
"w"]
863 puts $f
"#include <time.h>"
864 puts $f
"using namespace std;"
865 puts $f
"int main ()"
871 set lines
[v3_target_compile $src
/dev
/null executable
""]
874 if [string match
"" $lines] {
875 # No error message
, compilation succeeded.
876 verbose
"check_v3_target_time: compilation succeeded" 2
879 verbose
"check_v3_target_time: compilation failed" 2
882 return $et_time_saved
885 proc check_v3_target_namedlocale
{ args } {
886 global et_namedlocale
891 #
Set up
, compile, and
execute a C
++ test
program that tries to use
892 # the required named locale.
893 set exe nlocale
[pid
].x
895 if ![file
exists .
/$exe
] {
896 set src nlocale
[pid
].cc
898 set f
[open $src
"w"]
899 puts $f
"#include <locale>"
900 puts $f
"#include <cstdio>"
901 puts $f
"using namespace std;"
902 puts $f
"int main (int argc, char** argv)"
904 puts $f
" if (argc < 2)"
906 puts $f
" printf(\"locale support test not supported\\n\");"
911 puts $f
" locale(*(argv + 1));"
914 puts $f
" catch(...)"
916 puts $f
" printf(\"locale '%s' not supported\\n\", *(argv + 1));"
922 set lines
[v3_target_compile $src $exe executable
""]
925 if ![string match
"" $lines] {
926 verbose
"check_v3_target_namedlocale: compilation failed" 2
927 return $et_namedlocale
929 #
else No error message
, compilation succeeded.
932 set result
[$
{tool
}_load
"./$exe" "$args" ""]
933 set status [lindex $result
0]
935 verbose
"check_v3_target_namedlocale <$args>: status is <$status>" 2
937 if { $
status == "pass" } {
940 return $et_namedlocale
943 proc check_v3_target_debug_mode
{ } {
947 if { ![info exists et_debug_mode_target_name
] } {
948 set et_debug_mode_target_name
""
951 #
If the target has changed since we
set the cached value
, clear it.
952 set current_target
[current_target_name
]
953 if { $current_target
!= $et_debug_mode_target_name
} {
954 verbose
"check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
955 set et_debug_mode_target_name $current_target
956 if [info exists et_debug_mode
] {
957 verbose
"check_v3_target_debug_mode: removing cached result" 2
962 if [info exists et_debug_mode
] {
963 verbose
"check_v3_target_debug_mode: using cached result" 2
967 #
Set up and preprocess a C
++ test
program that depends
968 #
on debug
mode activated.
969 set src debug_mode
[pid
].cc
971 set f
[open $src
"w"]
972 puts $f
"#ifndef _GLIBCXX_DEBUG"
973 puts $f
"# error No debug mode"
977 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
980 if [string match
"" $lines] {
981 # No error message
, preprocessing succeeded.
985 verbose
"check_v3_target_debug_mode: $et_debug_mode" 2
986 return $et_debug_mode
989 proc check_v3_target_profile_mode
{ } {
990 global et_profile_mode
993 if { ![info exists et_profile_mode_target_name
] } {
994 set et_profile_mode_target_name
""
997 #
If the target has changed since we
set the cached value
, clear it.
998 set current_target
[current_target_name
]
999 if { $current_target
!= $et_profile_mode_target_name
} {
1000 verbose
"check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
1001 set et_profile_mode_target_name $current_target
1002 if [info exists et_profile_mode
] {
1003 verbose
"check_v3_target_profile_mode: removing cached result" 2
1004 unset et_profile_mode
1008 if [info exists et_profile_mode
] {
1009 verbose
"check_v3_target_profile_mode: using cached result" 2
1011 set et_profile_mode
0
1013 #
Set up and preprocess a C
++ test
program that depends
1014 #
on profile
mode activated.
1015 set src profile_mode
[pid
].cc
1017 set f
[open $src
"w"]
1018 puts $f
"#ifndef _GLIBCXX_PROFILE"
1019 puts $f
"# error No profile mode"
1023 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1026 if [string match
"" $lines] {
1027 # No error message
, preprocessing succeeded.
1028 set et_profile_mode
1
1031 verbose
"check_v3_target_profile_mode: $et_profile_mode" 2
1032 return $et_profile_mode
1035 proc check_v3_target_normal_mode
{ } {
1036 global et_normal_mode
1039 if { ![info exists et_normal_mode_target_name
] } {
1040 set et_normal_mode_target_name
""
1043 #
If the target has changed since we
set the cached value
, clear it.
1044 set current_target
[current_target_name
]
1045 if { $current_target
!= $et_normal_mode_target_name
} {
1046 verbose
"check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1047 set et_normal_mode_target_name $current_target
1048 if [info exists et_normal_mode
] {
1049 verbose
"check_v3_target_normal_mode: removing cached result" 2
1050 unset et_normal_mode
1054 if [info exists et_normal_mode
] {
1055 verbose
"check_v3_target_normal_mode: using cached result" 2
1057 set et_normal_mode
0
1059 #
Set up and
compile a C
++ test
program that depends
1060 #
on normal mode activated.
1061 set src normal_mode
[pid
].cc
1063 set f
[open $src
"w"]
1064 puts $f
"#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1065 puts $f
"# error No normal mode"
1069 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1072 if [string match
"" $lines] {
1073 # No error message
, compilation succeeded.
1074 set et_normal_mode
1
1077 verbose
"check_v3_target_normal_mode: $et_normal_mode" 2
1078 return $et_normal_mode
1081 proc check_v3_target_parallel_mode
{ } {
1084 global et_parallel_mode
1088 if { ![info exists et_parallel_mode_target_name
] } {
1089 set et_parallel_mode_target_name
""
1092 #
If the target has changed since we
set the cached value
, clear it.
1093 set current_target
[current_target_name
]
1094 if { $current_target
!= $et_parallel_mode_target_name
} {
1095 verbose
"check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1096 set et_parallel_mode_target_name $current_target
1097 if [info exists et_parallel_mode
] {
1098 verbose
"check_v3_target_parallel_mode: removing cached result" 2
1099 unset et_parallel_mode
1103 if [info exists et_parallel_mode
] {
1104 verbose
"check_v3_target_parallel_mode: using cached result" 2
1106 set et_parallel_mode
0
1108 #
If 'make check-parallel' is running the test succeeds.
1109 if { $
{v3
-libgomp
} == 1 && [regexp
"libgomp" $cxxflags] } {
1110 set et_parallel_mode
1
1113 verbose
"check_v3_target_parallel_mode: $et_parallel_mode" 2
1114 return $et_parallel_mode
1117 proc check_v3_target_cstdint
{ } {
1119 global DEFAULT_CXXFLAGS
1124 if { ![info exists et_cstdint_target_name
] } {
1125 set et_cstdint_target_name
""
1128 #
If the target has changed since we
set the cached value
, clear it.
1129 set current_target
[current_target_name
]
1130 if { $current_target
!= $et_cstdint_target_name
} {
1131 verbose
"check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1132 set et_cstdint_target_name $current_target
1133 if [info exists et_cstdint
] {
1134 verbose
"check_v3_target_cstdint: removing cached result" 2
1139 if [info exists et_cstdint
] {
1140 verbose
"check_v3_target_cstdint: using cached result" 2
1144 #
Set up and preprocess a C
++0x test
program that depends
1145 #
on the C99 stdint facilities to be available.
1146 set src cstdint
[pid
].cc
1148 set f
[open $src
"w"]
1149 puts $f
"#include <tr1/cstdint>"
1150 puts $f
"#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1151 puts $f
"# error No C99 stdint"
1155 set cxxflags_saved $cxxflags
1156 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1158 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1159 set cxxflags $cxxflags_saved
1162 if [string match
"" $lines] {
1163 # No error message
, preprocess succeeded.
1166 verbose
"check_v3_target_cstdint: compilation failed" 2
1169 verbose
"check_v3_target_cstdint: $et_cstdint" 2
1173 proc check_v3_target_cmath
{ } {
1175 global DEFAULT_CXXFLAGS
1180 if { ![info exists et_c99_math_target_name
] } {
1181 set et_c99_math_target_name
""
1184 #
If the target has changed since we
set the cached value
, clear it.
1185 set current_target
[current_target_name
]
1186 if { $current_target
!= $et_c99_math_target_name
} {
1187 verbose
"check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1188 set et_c99_math_target_name $current_target
1189 if [info exists et_c99_math
] {
1190 verbose
"check_v3_target_c99_math: removing cached result" 2
1195 if [info exists et_c99_math
] {
1196 verbose
"check_v3_target_c99_math: using cached result" 2
1200 #
Set up and preprocess a C
++0x test
program that depends
1201 #
on the C99 math facilities to be available.
1202 set src c99_math
[pid
].cc
1204 set f
[open $src
"w"]
1205 puts $f
"#include <tr1/cmath>"
1206 puts $f
"#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1207 puts $f
"# error No C99 math"
1211 set cxxflags_saved $cxxflags
1212 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1214 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1215 set cxxflags $cxxflags_saved
1218 if [string match
"" $lines] {
1219 # No error message
, preprocess succeeded.
1222 verbose
"check_v3_target_c99_math: compilation failed" 2
1225 verbose
"check_v3_target_c99_math: $et_c99_math" 2
1229 proc check_v3_target_thread_fence
{ } {
1231 global DEFAULT_CXXFLAGS
1232 global et_thread_fence
1236 if { ![info exists et_thread_fence_target_name
] } {
1237 set et_thread_fence_target_name
""
1240 #
If the target has changed since we
set the cached value
, clear it.
1241 set current_target
[current_target_name
]
1242 if { $current_target
!= $et_thread_fence_target_name
} {
1243 verbose
"check_v3_target_thread_fence: `$et_thread_fence_target_name'" 2
1244 set et_thread_fence_target_name $current_target
1245 if [info exists et_thread_fence
] {
1246 verbose
"check_v3_target_thread_fence: removing cached result" 2
1247 unset et_thread_fence
1251 if [info exists et_thread_fence
] {
1252 verbose
"check_v3_target_thread_fence: using cached result" 2
1254 set et_thread_fence
0
1256 #
Set up and preprocess a C
++11 test
program that depends
1257 #
on the thread fence to be available.
1258 set src thread_fence
[pid
].cc
1260 set f
[open $src
"w"]
1261 puts $f
"int main() {"
1262 puts $f
"__atomic_thread_fence (__ATOMIC_SEQ_CST);"
1267 set cxxflags_saved $cxxflags
1268 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1270 set lines
[v3_target_compile $src
/dev
/null executable
""]
1271 set cxxflags $cxxflags_saved
1274 if [string match
"" $lines] {
1275 # No error message
, linking succeeded.
1276 set et_thread_fence
1
1278 verbose
"check_v3_target_thread_fence: compilation failed" 2
1281 verbose
"check_v3_target_thread_fence: $et_thread_fence" 2
1282 return $et_thread_fence
1285 proc check_v3_target_atomic_builtins
{ } {
1287 global DEFAULT_CXXFLAGS
1288 global et_atomic_builtins
1292 if { ![info exists et_atomic_builtins_target_name
] } {
1293 set et_atomic_builtins_target_name
""
1296 #
If the target has changed since we
set the cached value
, clear it.
1297 set current_target
[current_target_name
]
1298 if { $current_target
!= $et_atomic_builtins_target_name
} {
1299 verbose
"check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1300 set et_atomic_builtins_target_name $current_target
1301 if [info exists et_atomic_builtins
] {
1302 verbose
"check_v3_target_atomic_builtins: removing cached result" 2
1303 unset et_atomic_builtins
1307 if [info exists et_atomic_builtins
] {
1308 verbose
"check_v3_target_atomic_builtins: using cached result" 2
1310 set et_atomic_builtins
0
1312 #
Set up and preprocess a C
++11 test
program that depends
1313 #
on the atomic builtin facilities to be available.
1314 set src atomic_builtins
[pid
].cc
1316 set f
[open $src
"w"]
1317 puts $f
"#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1318 puts $f
"# error No atomic bool"
1320 puts $f
"#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1321 puts $f
"# error No atomic int"
1325 set cxxflags_saved $cxxflags
1326 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1328 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1329 set cxxflags $cxxflags_saved
1332 if [string match
"" $lines] {
1333 # No error message
, preprocess succeeded.
1334 set et_atomic_builtins
1
1336 verbose
"check_v3_target_atomic_builtins: compilation failed" 2
1339 verbose
"check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1340 return $et_atomic_builtins
1343 proc check_v3_target_gthreads
{ } {
1345 global DEFAULT_CXXFLAGS
1350 if { ![info exists et_gthreads_target_name
] } {
1351 set et_gthreads_target_name
""
1354 #
If the target has changed since we
set the cached value
, clear it.
1355 set current_target
[current_target_name
]
1356 if { $current_target
!= $et_gthreads_target_name
} {
1357 verbose
"check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1358 set et_gthreads_target_name $current_target
1359 if [info exists et_gthreads
] {
1360 verbose
"check_v3_target_gthreads: removing cached result" 2
1365 if [info exists et_gthreads
] {
1366 verbose
"check_v3_target_gthreads: using cached result" 2
1370 #
Set up and preprocess a C
++0x test
program that depends
1371 #
on the gthreads facilities to be available.
1372 set src gthreads
[pid
].cc
1374 set f
[open $src
"w"]
1375 puts $f
"#include <bits/c++config.h>"
1376 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1377 puts $f
"# error No gthread"
1381 set cxxflags_saved $cxxflags
1382 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1384 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1385 set cxxflags $cxxflags_saved
1388 if [string match
"" $lines] {
1389 # No error message
, preprocessing succeeded.
1392 verbose
"check_v3_target_gthreads: compilation failed" 2
1395 verbose
"check_v3_target_gthreads: $et_gthreads" 2
1399 proc check_v3_target_gthreads_timed
{ } {
1401 global DEFAULT_CXXFLAGS
1402 global et_gthreads_timed
1406 if { ![info exists et_gthreads_timed_target_name
] } {
1407 set et_gthreads_timed_target_name
""
1410 #
If the target has changed since we
set the cached value
, clear it.
1411 set current_target
[current_target_name
]
1412 if { $current_target
!= $et_gthreads_timed_target_name
} {
1413 verbose
"check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1414 set et_gthreads_timed_target_name $current_target
1415 if [info exists et_gthreads_timed
] {
1416 verbose
"check_v3_target_gthreads_timed: removing cached result" 2
1417 unset et_gthreads_timed
1421 if [info exists et_gthreads_timed
] {
1422 verbose
"check_v3_target_gthreads_timed: using cached result" 2
1424 set et_gthreads_timed
0
1426 #
Set up and preprocess a C
++0x test
program that depends
1427 #
on the gthreads timed mutex facilities to be available.
1428 set src gthreads_timed
[pid
].cc
1430 set f
[open $src
"w"]
1431 puts $f
"#include <bits/c++config.h>"
1432 puts $f
"#ifndef _GLIBCXX_HAS_GTHREADS"
1433 puts $f
"# error No gthread"
1435 puts $f
"#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1436 puts $f
"# error No gthread timed mutexes"
1440 set cxxflags_saved $cxxflags
1441 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1443 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1444 set cxxflags $cxxflags_saved
1447 if [string match
"" $lines] {
1448 # No error message
, preprocessing succeeded.
1449 set et_gthreads_timed
1
1451 verbose
"check_v3_target_gthreads_timed: compilation failed" 2
1454 verbose
"check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1455 return $et_gthreads_timed
1459 proc check_v3_target_sleep
{ } {
1461 global DEFAULT_CXXFLAGS
1466 if { ![info exists et_sleep_target_name
] } {
1467 set et_sleep_target_name
""
1470 #
If the target has changed since we
set the cached value
, clear it.
1471 set current_target
[current_target_name
]
1472 if { $current_target
!= $et_sleep_target_name
} {
1473 verbose
"check_v3_target_sleep: `$et_sleep_target_name'" 2
1474 set et_sleep_target_name $current_target
1475 if [info exists et_sleep
] {
1476 verbose
"check_v3_target_sleep: removing cached result" 2
1481 if [info exists et_sleep
] {
1482 verbose
"check_v3_target_sleep: using cached result" 2
1486 #
Set up and preprocess a C
++11 test
program that depends
1487 #
on the
sleep facilities to be available.
1488 set src
sleep[pid
].cc
1490 set f
[open $src
"w"]
1491 puts $f
"#include <bits/c++config.h>"
1492 puts $f
"#ifndef _GLIBCXX_USE_NANOSLEEP"
1493 puts $f
"# ifndef _GLIBCXX_HAVE_SLEEP"
1494 puts $f
"# error No nanosleep or sleep"
1499 set cxxflags_saved $cxxflags
1500 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1502 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1503 set cxxflags $cxxflags_saved
1506 if [string match
"" $lines] {
1507 # No error message
, preprocessing succeeded.
1510 verbose
"check_v3_target_sleep: compilation failed" 2
1513 verbose
"check_v3_target_sleep: $et_sleep" 2
1517 proc check_v3_target_sched_yield
{ } {
1519 global DEFAULT_CXXFLAGS
1520 global et_sched_yield
1524 if { ![info exists et_sched_yield_target_name
] } {
1525 set et_sched_yield_target_name
""
1528 #
If the target has changed since we
set the cached value
, clear it.
1529 set current_target
[current_target_name
]
1530 if { $current_target
!= $et_sched_yield_target_name
} {
1531 verbose
"check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1532 set et_sched_yield_target_name $current_target
1533 if [info exists et_sched_yield
] {
1534 verbose
"check_v3_target_sched_yield: removing cached result" 2
1535 unset et_sched_yield
1539 if [info exists et_sched_yield
] {
1540 verbose
"check_v3_target_sched_yield: using cached result" 2
1542 set et_sched_yield
0
1544 #
Set up and preprocess a C
++0x test
program that depends
1545 #
on the sched_yield facility to be available.
1546 set src sched_yield
[pid
].cc
1548 set f
[open $src
"w"]
1549 puts $f
"#include <bits/c++config.h>"
1550 puts $f
"#ifndef _GLIBCXX_USE_SCHED_YIELD"
1551 puts $f
"# error No sched yield"
1555 set cxxflags_saved $cxxflags
1556 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1558 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1559 set cxxflags $cxxflags_saved
1562 if [string match
"" $lines] {
1563 # No error message
, preprocessing succeeded.
1564 set et_sched_yield
1
1566 verbose
"check_v3_target_sched_yield: compilation failed" 2
1569 verbose
"check_v3_target_sched_yield: $et_sched_yield" 2
1570 return $et_sched_yield
1573 proc check_v3_target_string_conversions
{ } {
1575 global DEFAULT_CXXFLAGS
1576 global et_string_conversions
1580 if { ![info exists et_string_conversions_target_name
] } {
1581 set et_string_conversions_target_name
""
1584 #
If the target has changed since we
set the cached value
, clear it.
1585 set current_target
[current_target_name
]
1586 if { $current_target
!= $et_string_conversions_target_name
} {
1587 verbose
"check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1588 set et_string_conversions_target_name $current_target
1589 if [info exists et_string_conversions
] {
1590 verbose
"check_v3_target_string_conversions: removing cached result" 2
1591 unset et_string_conversions
1595 if [info exists et_string_conversions
] {
1596 verbose
"check_v3_target_string_conversions: using cached result" 2
1598 set et_string_conversions
0
1600 #
Set up and preprocess a C
++0x test
program that depends
1601 #
on the string_conversions facilities to be available.
1602 set src string_conversions
[pid
].cc
1604 set f
[open $src
"w"]
1605 puts $f
"#include <bits/c++config.h>"
1606 puts $f
"#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1607 puts $f
"# error No string conversions"
1611 set cxxflags_saved $cxxflags
1612 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1614 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1615 set cxxflags $cxxflags_saved
1618 if [string match
"" $lines] {
1619 # No error message
, preprocessing succeeded.
1620 set et_string_conversions
1
1622 verbose
"check_v3_target_string_conversions: compilation failed" 2
1625 verbose
"check_v3_target_string_conversions: $et_string_conversions" 2
1626 return $et_string_conversions
1629 proc check_v3_target_swprintf
{ } {
1631 global DEFAULT_CXXFLAGS
1636 if { ![info exists et_swprintf_target_name
] } {
1637 set et_swprintf_target_name
""
1640 #
If the target has changed since we
set the cached value
, clear it.
1641 set current_target
[current_target_name
]
1642 if { $current_target
!= $et_swprintf_target_name
} {
1643 verbose
"check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1644 set et_swprintf_target_name $current_target
1645 if [info exists et_swprintf
] {
1646 verbose
"check_v3_target_swprintf: removing cached result" 2
1651 if [info exists et_swprintf
] {
1652 verbose
"check_v3_target_swprintf: using cached result" 2
1656 #
Set up and preprocess a C
++0x test
program that depends
1657 #
on a standard swprintf function to be available.
1658 set src swprintf
[pid
].cc
1660 set f
[open $src
"w"]
1661 puts $f
"#include <bits/c++config.h>"
1662 puts $f
"#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1663 puts $f
"# error No swprintf"
1667 set cxxflags_saved $cxxflags
1668 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1670 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1671 set cxxflags $cxxflags_saved
1674 if [string match
"" $lines] {
1675 # No error message
, preprocessing succeeded.
1678 verbose
"check_v3_target_swprintf: compilation failed" 2
1681 verbose
"check_v3_target_swprintf: $et_swprintf" 2
1685 proc check_v3_target_binary_io
{ } {
1687 global DEFAULT_CXXFLAGS
1692 if { ![info exists et_binary_io_target_name
] } {
1693 set et_binary_io_target_name
""
1696 #
If the target has changed since we
set the cached value
, clear it.
1697 set current_target
[current_target_name
]
1698 if { $current_target
!= $et_binary_io_target_name
} {
1699 verbose
"check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1700 set et_binary_io_target_name $current_target
1701 if [info exists et_binary_io
] {
1702 verbose
"check_v3_target_binary_io: removing cached result" 2
1707 if [info exists et_binary_io
] {
1708 verbose
"check_v3_target_binary_io: using cached result" 2
1712 #
Set up and preprocess a C
++0x test
program that depends
1713 #
on text and binary I
/O being the same.
1714 set src binary_io
[pid
].cc
1716 set f
[open $src
"w"]
1717 puts $f
"#include <bits/c++config.h>"
1718 puts $f
"#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1719 puts $f
"# error No binary io"
1723 set cxxflags_saved $cxxflags
1724 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1726 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1727 set cxxflags $cxxflags_saved
1730 if [string match
"" $lines] {
1731 # No error message
, preprocessing succeeded.
1734 verbose
"check_v3_target_binary_io: compilation failed" 2
1737 verbose
"check_v3_target_binary_io: $et_binary_io" 2
1738 return $et_binary_io
1741 proc check_v3_target_nprocs
{ } {
1743 global DEFAULT_CXXFLAGS
1748 if { ![info exists et_nprocs_target_name
] } {
1749 set et_nprocs_target_name
""
1752 #
If the target has changed since we
set the cached value
, clear it.
1753 set current_target
[current_target_name
]
1754 if { $current_target
!= $et_nprocs_target_name
} {
1755 verbose
"check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1756 set et_nprocs_target_name $current_target
1757 if [info exists et_nprocs
] {
1758 verbose
"check_v3_target_nprocs: removing cached result" 2
1763 if [info exists et_nprocs
] {
1764 verbose
"check_v3_target_nprocs: using cached result" 2
1768 #
Set up and preprocess a C
++0x test
program that depends
1769 #
on either get_nprocs or sysconf to be available.
1770 set src nprocs
[pid
].cc
1772 set f
[open $src
"w"]
1773 puts $f
"#include <bits/c++config.h>"
1774 puts $f
"#if defined(_GLIBCXX_USE_GET_NPROCS)"
1775 puts $f
"#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1776 puts $f
"#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1777 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1778 puts $f
"#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
1780 puts $f
"# error hardware_concurrency not implemented"
1784 set cxxflags_saved $cxxflags
1785 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1787 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1788 set cxxflags $cxxflags_saved
1791 if [string match
"" $lines] {
1792 # No error message
, preprocess succeeded.
1795 verbose
"check_v3_target_nprocs: compilation failed" 2
1798 verbose
"check_v3_target_nprocs: $et_nprocs" 2
1802 proc check_v3_target_static_libstdcxx
{ } {
1804 global DEFAULT_CXXFLAGS
1805 global et_static_libstdcxx
1809 if [info exists et_static_libstdcxx
] {
1810 verbose
"check_v3_target_static_libstdcxx: using cached result" 2
1812 set et_static_libstdcxx
0
1814 #
Set up and link a C
++0x test
program that depends
1816 set src static
-maybe
[pid
].cc
1818 set f
[open $src
"w"]
1819 puts $f
"#include <iostream>"
1820 puts $f
"int main() {"
1821 puts $f
"int i(415);"
1822 puts $f
"std::cout<< i << std::endl;"
1823 puts $f
"return 0; }"
1827 set cxxflags_saved $cxxflags
1828 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -static-libstdc++"
1830 set lines
[v3_target_compile $src
/dev
/null executable
""]
1831 set cxxflags $cxxflags_saved
1834 if [string match
"" $lines] {
1835 # No error message
, link succeeded.
1836 set et_static_libstdcxx
1
1838 verbose
"check_v3_target_static_libstdcxx: compilation failed" 2
1841 verbose
"check_v3_target_static_libstdcxx: $et_static_libstdcxx" 2
1842 return $et_static_libstdcxx
1845 proc check_v3_target_little_endian
{ } {
1847 global DEFAULT_CXXFLAGS
1848 global et_little_endian
1852 if { ![info exists et_little_endian_target_name
] } {
1853 set et_little_endian_target_name
""
1856 #
If the target has changed since we
set the cached value
, clear it.
1857 set current_target
[current_target_name
]
1858 if { $current_target
!= $et_little_endian_target_name
} {
1859 verbose
"check_v3_target_little_endian: `$et_little_endian_target_name'" 2
1860 set et_little_endian_target_name $current_target
1861 if [info exists et_little_endian
] {
1862 verbose
"check_v3_target_little_endian: removing cached result" 2
1863 unset et_little_endian
1867 if [info exists et_little_endian
] {
1868 verbose
"check_v3_target_little_endian: using cached result" 2
1870 set et_little_endian
0
1872 set src little_endian
[pid
].cc
1874 set f
[open $src
"w"]
1875 puts $f
"#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__"
1876 puts $f
"# error Not little endian"
1880 set cxxflags_saved $cxxflags
1881 set cxxflags
"$cxxflags $DEFAULT_CXXFLAGS -Werror"
1883 set lines
[v3_target_compile $src
/dev
/null preprocess
""]
1884 set cxxflags $cxxflags_saved
1887 if [string match
"" $lines] {
1888 # No error message
, preprocessing succeeded.
1889 set et_little_endian
1
1891 verbose
"check_v3_target_little_endian: compilation failed" 2
1894 verbose
"check_v3_target_little_endian: $et_little_endian" 2
1895 return $et_little_endian
1898 set additional_prunes
""
1900 if { [info exists env
(GCC_RUNTEST_PARALLELIZE_DIR
)] \
1901 && [info procs runtest_file_p
] != [list
] \
1902 && [info procs gcc_parallelize_saved_runtest_file_p
] == [list
] } then {
1903 global gcc_runtest_parallelize_counter
1904 global gcc_runtest_parallelize_counter_minor
1905 global gcc_runtest_parallelize_enable
1906 global gcc_runtest_parallelize_dir
1907 global gcc_runtest_parallelize_last
1909 set gcc_runtest_parallelize_counter
0
1910 set gcc_runtest_parallelize_counter_minor
0
1911 set gcc_runtest_parallelize_enable
1
1912 set gcc_runtest_parallelize_dir
[getenv GCC_RUNTEST_PARALLELIZE_DIR
]
1913 set gcc_runtest_parallelize_last
0
1915 proc gcc_parallel_test_run_p
{ testcase
} {
1916 global gcc_runtest_parallelize_counter
1917 global gcc_runtest_parallelize_counter_minor
1918 global gcc_runtest_parallelize_enable
1919 global gcc_runtest_parallelize_dir
1920 global gcc_runtest_parallelize_last
1922 if { $gcc_runtest_parallelize_enable
== 0 } {
1926 # Only test the filesystem
every 10th iteration
1927 incr gcc_runtest_parallelize_counter_minor
1928 if { $gcc_runtest_parallelize_counter_minor
== 10 } {
1929 set gcc_runtest_parallelize_counter_minor
0
1931 if { $gcc_runtest_parallelize_counter_minor
!= 1 } {
1932 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
1933 return $gcc_runtest_parallelize_last
1936 set path $gcc_runtest_parallelize_dir
/$gcc_runtest_parallelize_counter
1938 if {![catch
{open $path
{RDWR CREAT EXCL
} 0600} fd
]} {
1940 set gcc_runtest_parallelize_last
1
1941 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
1942 incr gcc_runtest_parallelize_counter
1945 set gcc_runtest_parallelize_last
0
1946 #verbose
-log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
1947 incr gcc_runtest_parallelize_counter
1951 proc gcc_parallel_test_enable
{ val
} {
1952 global gcc_runtest_parallelize_enable
1953 set gcc_runtest_parallelize_enable $val
1956 rename runtest_file_p gcc_parallelize_saved_runtest_file_p
1957 proc runtest_file_p
{ runtests testcase
} {
1958 if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase
] {
1961 return [gcc_parallel_test_run_p $testcase
]
1966 proc gcc_parallel_test_run_p
{ testcase
} {
1970 proc gcc_parallel_test_enable
{ val
} {