]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/lib/libstdc++.exp
re PR libstdc++/50196 ([C++0x] std::thread not available under macos)
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
1 # libstdc++ "tool init file" for DejaGNU
2
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009, 2010, 2011
5 # Free Software Foundation, Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
20
21
22 # Define callbacks and load other libraries. This file is loaded relatively
23 # early, and before any other file we write ourselves. "load_lib" will
24 # find anything in the DejaGNU installation tree, or in our lib directory.
25 # "load_gcc_lib" will search the core compiler's .exp collection instead.
26 #
27 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
28 # for "tool_" when finding callbacks. Utility routines we define for
29 # our callbacks begin with "v3-".
30 #
31 # libstdc++_* callbacks we don't define, but could:
32 # ..._option_help prints additional --help output
33 # ..._option_proc (--foo) process our own options
34 # ..._init (normal.exp) called once per test file
35 # ..._finish bracketing function for libstdc++_init
36 # ...-dg-prune removing output text, see top of system dg.exp
37 #
38 # Useful hook: if ${hostname}_init exists, it will be called, almost
39 # the last thing before testing begins. This can be defined in, e.g.,
40 # ~/.dejagnurc or $DEJAGNU.
41
42 proc load_gcc_lib { filename } {
43 global srcdir
44 load_file $srcdir/../../gcc/testsuite/lib/$filename
45 }
46
47 # system routines
48 load_lib dg.exp
49 load_lib libgloss.exp
50 # compiler routines, then ours
51 load_gcc_lib target-supports.exp
52 load_gcc_lib target-supports-dg.exp
53 load_lib prune.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
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 } {
64 upvar $var val
65 verbose "++ $var is $val" $n
66 }
67
68 # Called by v3-init below. "Static" to this file.
69 proc v3-copy-files {srcfiles} {
70 foreach f $srcfiles {
71 if { [catch { set symlink [file readlink $f] } x] } then {
72 remote_download target $f
73 } else {
74 if { [regexp "^/" "$symlink"] } then {
75 remote_download target $symlink
76 } else {
77 set dirname [file dirname $f]
78 remote_download target $dirname/$symlink
79 }
80 }
81 }
82 }
83
84 # Called once, during runtest.exp setup.
85 proc libstdc++_init { testfile } {
86 global env
87 global v3-sharedlib v3-libgomp
88 global srcdir blddir objdir tool_root_dir
89 global cc cxx cxxflags cxxpchflags cxxldflags
90 global includes
91 global gluefile wrap_flags
92 global ld_library_path
93 global target_triplet
94 global flags_file
95 global tool_timeout
96 global DEFAULT_CXXFLAGS
97 global STATIC_LIBCXXFLAGS
98
99 # We set LC_ALL and LANG to C so that we get the same error
100 # messages as expected.
101 setenv LC_ALL C
102 setenv LANG C
103
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
108 setenv LANG C.ASCII
109 }
110
111 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
112 set flags_file "${blddir}/scripts/testsuite_flags"
113 set shlib_ext [get_shlib_extension]
114 v3track flags_file 2
115
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.
122
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"
128 }
129 }
130 v3track DEFAULT_CXXFLAGS 2
131
132 # By default, we assume we want to run program images.
133 global dg-do-what-default
134 set dg-do-what-default run
135
136 # Copy any required data files.
137 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
138 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
139
140 set ld_library_path_tmp ""
141
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]
145 if {$gccdir != ""} {
146 set gccdir [file dirname $gccdir]
147 append ld_library_path_tmp ":${gccdir}"
148 }
149 v3track gccdir 3
150
151 # Locate libgomp. This is only required for parallel mode.
152 set v3-libgomp 0
153 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
154 if {$libgompdir != ""} {
155 set v3-libgomp 1
156 set libgompdir [file dirname $libgompdir]
157 append ld_library_path_tmp ":${libgompdir}"
158 verbose -log "libgomp support detected"
159 }
160 v3track libgompdir 3
161
162 # Locate libstdc++ shared library. (ie libstdc++.so.)
163 set v3-sharedlib 0
164 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
165 if {$sharedlibdir != ""} {
166 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
167 set v3-sharedlib 1
168 verbose -log "shared library support detected"
169 }
170 }
171 v3track v3-sharedlib 3
172
173 set STATIC_LIBCXXFLAGS ""
174 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
175 if {$staticlibdir != ""} {
176 set staticlibdir [file dirname $staticlibdir]
177 # Some targets use libstdc++.a%s in their specs, so they need a
178 # -B option for uninstalled testing.
179 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
180 }
181
182 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
183 if {$gccdir != ""} {
184 set compiler ${gccdir}/g++
185 set ld_library_path ${ld_library_path_tmp}
186 append ld_library_path ":${blddir}/src/.libs"
187
188 if { [is_remote host] == 0 && [which $compiler] != 0 } {
189 foreach i "[exec $compiler --print-multi-lib]" {
190 set mldir ""
191 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
192 set mldir [string trimright $mldir "\;@"]
193 if { "$mldir" == "." } {
194 continue
195 }
196 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
197 append ld_library_path ":${gccdir}/${mldir}"
198 }
199 }
200 }
201
202 set_ld_library_path_env_vars
203 if [info exists env(LD_LIBRARY_PATH)] {
204 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
205 }
206 } else {
207 set compiler [transform "g++"]
208 }
209
210 # Set the default timeout for v3 tests.
211 set tool_timeout 600
212
213 # Default settings.
214 set cxx [transform "g++"]
215 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
216 set cxxpchflags ""
217 set cxxldflags ""
218 set cc [transform "gcc"]
219 # Locate testsuite_hooks.h and other testsuite headers.
220 set includes "-I${srcdir}/util"
221 # Adapt the defaults for special circumstances.
222 if [is_remote host] {
223 # A remote host does not, in general, have access to the
224 # $srcdir so we copy the testsuite headers into the current
225 # directory, and then add that to the search path.
226 foreach src [glob "${srcdir}/util/*.h" \
227 "${srcdir}/util/*.cc" \
228 "${srcdir}/util/*.tcc" \
229 "${srcdir}/util/*.hpp" \
230 "${srcdir}/util/*/*.h" \
231 "${srcdir}/util/*/*.cc" \
232 "${srcdir}/util/*/*.tcc" \
233 "${srcdir}/util/*/*.hpp" \
234 "${srcdir}/util/*/*/*.h" \
235 "${srcdir}/util/*/*/*.cc" \
236 "${srcdir}/util/*/*/*.tcc" \
237 "${srcdir}/util/*/*/*.hpp" \
238 "${srcdir}/util/*/*/*/*.h" \
239 "${srcdir}/util/*/*/*/*.cc" \
240 "${srcdir}/util/*/*/*/*.tcc" \
241 "${srcdir}/util/*/*/*/*.hpp" \
242 "${srcdir}/util/*/*/*/*/*.h" \
243 "${srcdir}/util/*/*/*/*/*.cc" \
244 "${srcdir}/util/*/*/*/*/*.tcc" \
245 "${srcdir}/util/*/*/*/*/*.hpp" ] {
246 # Remove everything up to "util/..."
247 set dst [string range $src [string length "${srcdir}/"] end]
248 # Create the directory containing the file.
249 set dir [file dirname $dst]
250 remote_exec host "mkdir" [list "-p" "$dir"]
251 # Download the file.
252 set result [remote_download host $src $dst]
253 if { $result == "" } {
254 verbose -log "Unable to download ${srcdir}/${src} to host."
255 return "untested"
256 }
257 }
258 set includes "-Iutil"
259 } elseif { [file exists $flags_file] } {
260 # If we find a testsuite_flags file, we're testing in the build dir.
261 set cxx [exec sh $flags_file --build-cxx]
262 set cxxflags [exec sh $flags_file --cxxflags]
263 set cxxpchflags [exec sh $flags_file --cxxpchflags]
264 set cxxldflags [exec sh $flags_file --cxxldflags]
265 set cc [exec sh $flags_file --build-cc]
266 set includes [exec sh $flags_file --build-includes]
267 }
268 append cxxflags " "
269 append cxxflags [getenv CXXFLAGS]
270 v3track cxxflags 2
271
272 # Always use MO files built by this test harness.
273 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
274 set ccflags "$cxxflags -DLOCALEDIR=\".\""
275
276 # If a PCH file is available, use it. We must delay performing
277 # this check until $cxx and such have been initialized because we
278 # perform a test compilation. (Ideally, gcc --print-file-name would
279 # list PCH files, but it does not.)
280 if { $cxxpchflags != "" } {
281 set src "config[pid].cc"
282 set f [open $src "w"]
283 puts $f "int main () {}"
284 close $f
285
286 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
287 # useful as then the requested variant of the pre-build PCH
288 # files could be tested to see if it works.
289 set lines [v3_target_compile $src "config[pid].o" object \
290 "additional_flags=-include additional_flags=bits/stdc++.h"]
291 if { $lines != "" } {
292 verbose -log "Requested PCH file: $cxxpchflags"
293 verbose -log "is not working, and will not be used."
294 set cxxpchflags ""
295 }
296 file delete $src
297 }
298 v3track cxxpchflags 2
299
300 global PCH_CXXFLAGS
301 if ![info exists PCH_CXXFLAGS] then {
302 set PCH_CXXFLAGS $cxxpchflags
303 v3track PCH_CXXFLAGS 2
304 }
305
306 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
307 }
308
309 # Callback for cleanup routines.
310 proc libstdc++_exit { } {
311 global gluefile;
312
313 if [info exists gluefile] {
314 file_on_build delete $gluefile;
315 unset gluefile;
316 }
317 }
318
319 # Callback from system dg-test.
320 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
321 # Set up the compiler flags, based on what we're going to do.
322 switch $do_what {
323 "preprocess" {
324 set compile_type "preprocess"
325 set output_file "[file rootname [file tail $prog]].i"
326 }
327 "compile" {
328 set compile_type "assembly"
329 set output_file "[file rootname [file tail $prog]].s"
330 }
331 "assemble" {
332 set compile_type "object"
333 set output_file "[file rootname [file tail $prog]].o"
334 }
335 "link" {
336 set compile_type "executable"
337 set output_file "./[file rootname [file tail $prog]].exe"
338 }
339 "run" {
340 set compile_type "executable"
341 # FIXME: "./" is to cope with "." not being in $PATH.
342 # Should this be handled elsewhere?
343 # YES.
344 set output_file "./[file rootname [file tail $prog]].exe"
345 # This is the only place where we care if an executable was
346 # created or not. If it was, dg.exp will try to run it.
347 catch { remote_file build delete $output_file }
348 }
349 default {
350 perror "$do_what: not a valid dg-do keyword"
351 return ""
352 }
353 }
354
355 # Short-circut a bunch of complicated goo here for the special
356 # case of compiling a test file as a "C" file, not as C++. Why? So
357 # -nostdc++ doesn't trip us up. So all the extra object files
358 # don't trip us up. So automatically linking in libstdc++ doesn't
359 # happen. So CXXFLAGS don't error.
360 set select_compile "v3_target_compile"
361 set options ""
362 if { $extra_tool_flags != "" } {
363 verbose -log "extra_tool_flags are:"
364 verbose -log $extra_tool_flags
365 if { [string first "-x c" $extra_tool_flags ] != -1 } {
366 verbose -log "compiling and executing as C, not C++"
367 set edit_tool_flags $extra_tool_flags
368 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
369 lappend options "additional_flags=$edit_tool_flags"
370 set select_compile "v3_target_compile_as_c"
371 } else {
372 lappend options "additional_flags=$extra_tool_flags"
373 }
374 }
375
376 # There is a libstdc++_compile made for us by default (via the tool-
377 # and-target file), but the defaults are lacking in goodness.
378 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
379
380 return [list $comp_output $output_file]
381 }
382
383 # Override the DejaGnu dg-test in order to clear flags after a test, as
384 # is done for compiler tests in gcc-dg.exp.
385
386 if { [info procs saved-dg-test] == [list] } {
387 rename dg-test saved-dg-test
388
389 proc dg-test { args } {
390 global additional_prunes
391 global errorInfo
392
393 if { [ catch { eval saved-dg-test $args } errmsg ] } {
394 set saved_info $errorInfo
395 set additional_prunes ""
396 unset_timeout_vars
397 error $errmsg $saved_info
398 }
399 set additional_prunes ""
400 unset_timeout_vars
401 }
402 }
403
404 # True if the library supports wchar_t.
405 set v3-wchar_t 0
406
407 # True if the library supports threads.
408 set v3-threads 0
409
410 # True if the library supports symbol versioning.
411 set v3-symver 0
412
413 # Called from libstdc++-dg-test above. Calls back into system's
414 # target_compile to actually do the work.
415 proc v3_target_compile { source dest type options } {
416 global gluefile
417 global wrap_flags
418 global cxx
419 global cxxflags
420 global cxxldflags
421 global includes
422 global STATIC_LIBCXXFLAGS
423
424 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
425 lappend options "libs=${gluefile}"
426 lappend options "ldflags=${wrap_flags}"
427 }
428
429 set cxx_final $cxx
430 set cxxlibglossflags [libgloss_link_flags]
431 set cxx_final [concat $cxx_final $cxxlibglossflags]
432 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
433 set cxx_final [concat $cxx_final $cxxflags]
434 set cxx_final [concat $cxx_final $includes]
435
436 # Flag setting based on type argument.
437 if { $type == "executable" } {
438 # Link the support objects into executables.
439 lappend options "additional_flags=./libtestc++.a $cxxldflags"
440 } else {
441 if { $type == "sharedlib" } {
442 # Don't link in anything.
443 set type "executable"
444 }
445 }
446
447 lappend options "compiler=$cxx_final"
448 lappend options "timeout=[timeout_value]"
449
450 return [target_compile $source $dest $type $options]
451 }
452
453
454 # Called from libstdc++-dg-test above, but only for "C" compilation.
455 # Calls back into system's target_compile to actually do the work.
456 proc v3_target_compile_as_c { source dest type options } {
457 global gluefile
458 global wrap_flags
459 global includes
460 global flags_file
461 global blddir
462 global cc
463 global cxxflags
464 global STATIC_LIBCXXFLAGS
465
466 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
467 lappend options "libs=${gluefile}"
468 lappend options "ldflags=${wrap_flags}"
469 }
470
471 set tname [target_info name]
472 set cc_final $cc
473 set cxxlibglossflags [libgloss_link_flags]
474 set cc_final [concat $cc_final $cxxlibglossflags]
475 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
476 set cc_final [concat $cc_final $cxxflags]
477 set cc_final [concat $cc_final $includes]
478 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
479
480 # This is needed for "C" tests, as this type of test may need the
481 # C++ includes. And if we're not testing in the build directory,
482 # the includes variable is not likely to include the necessary
483 # info.
484 if { ![file exists $flags_file] } {
485 # ??? We need a --print-include-dirs option to GCC, so that
486 # we can avoid these hacks. The heuristics here will not
487 # work with non-standard --with-includedir= options.
488 set version [remote_exec host ${cc} -dumpversion]
489 # Remove the trailing newline from the output.
490 set version [string trimright [lindex $version 1]]
491 set machine [remote_exec host ${cc} -dumpmachine]
492 set machine [string trimright [lindex $machine 1]]
493 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
494 set comp_base_dir [lindex $comp_base_dir 1]
495 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
496 # For a cross compiler, the header files will be located in a
497 # machine-specific subdirectory.
498 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
499 set crosstarget "${crossbase}/${machine}"
500 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
501 # For a native compiler, the header files will be located at
502 # the top level.
503 set includesbase "${comp_base_dir}/include/c++/${version}"
504 set includestarget "${includesbase}/${machine}"
505 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
506
507 set libdir "-L${comp_base_dir}/lib"
508 } else {
509 set libdir "-L${blddir}/libsupc++/.libs"
510 set libdir [concat $libdir "-L${blddir}/src/.libs"]
511 }
512
513 set cc_final [concat $cc_final "$libdir"]
514
515 lappend options "compiler=$cc_final"
516 lappend options "timeout=[timeout_value]"
517
518 return [target_compile $source $dest $type $options]
519 }
520
521 # Build the support objects linked in with the libstdc++ tests. In
522 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
523 proc v3-build_support { } {
524 global env
525 global srcdir
526 global v3-wchar_t
527 global v3-threads
528 global v3-symver
529 global v3-sharedlib
530
531 # Figure out whether or not the library supports certain features.
532 set v3-wchar_t 0
533 set v3-threads 0
534 set v3-symver 0
535 set libtest_objs ""
536
537 set config_src "config.cc"
538 set config_out "config.ii"
539 set f [open $config_src "w"]
540 puts $f "#include <bits/c++config.h>"
541 puts $f "#include <bits/gthr.h>"
542 close $f
543 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
544 set file [open $config_out r]
545 set preprocessed [read $file]
546 close $file
547 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
548 verbose -log "wchar_t support detected"
549 set v3-wchar_t 1
550 }
551 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
552 verbose -log "symbol versioning support detected"
553 set v3-symver 1
554 }
555 if { [string first "__GTHREADS" $preprocessed] != -1 } {
556 verbose -log "thread support detected"
557 set v3-threads 1
558 }
559
560 # Try to build the MO files that are used by some of the locale
561 # tests. If we can't build them, that's OK; it just means that
562 # those tests will fail.
563 foreach lang [list "fr" "de"] {
564 catch {
565 file mkdir "$lang/LC_MESSAGES"
566 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
567 if [is_remote host] {
568 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
569 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
570 }
571 }
572 }
573
574 # Build the support objects.
575 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
576 testsuite_character.cc testsuite_hooks.cc \
577 io/verified_cmd_line_input.cc \
578 io/prog_bar.cc performance/time/elapsed_timer.cc ]
579 foreach f $source_files {
580 set obj [file rootname $f].o
581 set object_file [file tail $obj]
582 # Compile with "-w" so that warnings issued by the compiler
583 # do not prevent compilation.
584 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
585 [list "incdir=$srcdir" "additional_flags=-w"]]
586 != "" } {
587 error "could not compile $f"
588 }
589 append libtest_objs "$object_file "
590 }
591
592 # Collect into libtestc++.a
593 # Delete libtestc++.a first. Mixed 32 and 64-bit archives cannot be
594 # linked on IRIX 6.
595 # Use same procedure as gcc-dg.exp (remove-build-file).
596 if [is_remote host] {
597 # Ensure the host knows the file is gone by deleting there
598 # first.
599 remote_file host delete "./libtestc++.a"
600 }
601 remote_file build delete "./libtestc++.a"
602 if [info exists env(AR)] {
603 set ar $env(AR)
604 } else {
605 set ar [transform "ar"]
606 }
607 set arargs "-rc ./libtestc++.a ${libtest_objs}"
608 verbose -log "$ar $arargs"
609 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
610 verbose "link result is $result"
611 if { $result == 0 } {
612 if [info exists env(RANLIB)] {
613 set ranlib $env(RANLIB)
614 } else {
615 set ranlib [transform "ranlib"]
616 }
617 set ranlibargs "./libtestc++.a"
618 verbose -log "$ranlib $ranlibargs"
619 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
620 if { $result != 0 } {
621 error "could not link libtestc++.a"
622 }
623 }
624
625 # Build any shared objects needed for regression testing.
626 if { ${v3-sharedlib} == 1 } {
627 set source_files [list testsuite_shared.cc]
628 foreach f $source_files {
629 set object_file [file rootname $f].so
630 # Compile with "-w" so that warnings issued by the compiler
631 # do not prevent compilation.
632 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
633 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
634 != "" } {
635 error "could not compile $f"
636 }
637 }
638 }
639 }
640
641 proc check_v3_target_fileio { } {
642 global et_fileio_saved
643 global et_fileio_target_name
644 global tool
645 global srcdir
646
647 if { ![info exists et_fileio_target_name] } {
648 set et_fileio_target_name ""
649 }
650
651 # If the target has changed since we set the cached value, clear it.
652 set current_target [current_target_name]
653 if { $current_target != $et_fileio_target_name } {
654 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
655 set et_fileio_target_name $current_target
656 if [info exists et_fileio_saved] {
657 verbose "check_v3_target_fileio: removing cached result" 2
658 unset et_fileio_saved
659 }
660 }
661
662 if [info exists et_fileio_saved] {
663 verbose "check_v3_target_fileio: using cached result" 2
664 } else {
665 set et_fileio_saved 0
666
667 # Set up, compile, and execute a C++ test program that tries to use
668 # the file functions
669 set src fileio[pid].cc
670 set exe fileio[pid].x
671 set testfile "cin_unget-1.txt"
672 v3-copy-files "$srcdir/data/$testfile"
673
674 set f [open $src "w"]
675 puts $f "#include <sys/types.h>"
676 puts $f "#include <sys/stat.h>"
677 puts $f "#include <fcntl.h>"
678 puts $f "#include <unistd.h>"
679 puts $f "#include <errno.h>"
680 puts $f "#include <string.h>"
681 puts $f "using namespace std;"
682 puts $f "int main ()"
683 puts $f "{"
684 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
685 puts $f " int ret = 0;"
686 puts $f " char buf\[10\];"
687 puts $f " if (fd == -1)"
688 puts $f " ret = 1;"
689 puts $f " else"
690 puts $f " {"
691 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
692 puts $f " ret = 1;"
693 puts $f " errno = 0;"
694 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
695 puts $f " || read (fd, buf, 4) != 4"
696 puts $f " || memcmp (buf, \"1234\", 4) != 0"
697 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
698 puts $f " || read (fd, buf, 2) != 2"
699 puts $f " || memcmp (buf, \"34\", 2) != 0)"
700 puts $f " ret = 1;"
701 puts $f " close (fd);"
702 puts $f " }"
703 puts $f " return ret;"
704 puts $f "}"
705 close $f
706
707 set lines [v3_target_compile $src $exe executable ""]
708 file delete $src
709
710 if [string match "" $lines] {
711 # No error message, compilation succeeded.
712 set result [${tool}_load "./$exe" "" ""]
713 set status [lindex $result 0]
714 remote_file build delete $exe
715
716 verbose "check_v3_target_fileio: status is <$status>" 2
717
718 if { $status == "pass" } {
719 set et_fileio_saved 1
720 }
721 } else {
722 verbose "check_v3_target_fileio: compilation failed" 2
723 }
724 }
725 return $et_fileio_saved
726 }
727
728 # Eventually we want C90/C99 determining and switching from this.
729 proc check_v3_target_c_std { } {
730 global et_c_std_saved
731 global et_c_std_target_name
732 global tool
733
734 if { ![info exists et_c_std_target_name] } {
735 set et_c_std_target_name ""
736 }
737
738 # If the target has changed since we set the cached value, clear it.
739 set current_target [current_target_name]
740 if { $current_target != $et_c_std_target_name } {
741 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
742 set et_c_std_target_name $current_target
743 if [info exists et_c_std_saved] {
744 verbose "check_v3_target_c_std: removing cached result" 2
745 unset et_c_std_saved
746 }
747 }
748
749 if [info exists et_c_std_saved] {
750 verbose "check_v3_target_c_std: using cached result" 2
751 } else {
752 set et_c_std_saved 0
753
754 # Set up, compile, and execute a C++ test program that tries to use
755 # C99 functionality.
756 # For math bits, could use check_effective_target_c99_math.
757 set src fileio[pid].cc
758 set exe fileio[pid].x
759
760 set f [open $src "w"]
761 puts $f "#include <tr1/cmath>"
762 puts $f "#include <cstdlib>"
763 puts $f "int main ()"
764 puts $f "{"
765 puts $f " float f = 45.55;"
766 puts $f " int i = std::tr1::isnan(f);"
767 puts $f " "
768 puts $f " using std::wctomb;"
769 puts $f " return i;"
770 puts $f "}"
771 close $f
772
773 set lines [v3_target_compile $src $exe executable ""]
774 file delete $src
775
776 if [string match "" $lines] {
777 # No error message, compilation succeeded.
778 set result [${tool}_load "./$exe" "" ""]
779 set status [lindex $result 0]
780 remote_file build delete $exe
781
782 verbose "check_v3_target_c_std: status is <$status>" 2
783
784 if { $status == "pass" } {
785 set et_c_std_saved 1
786 }
787 } else {
788 verbose "check_v3_target_c_std: compilation failed" 2
789 }
790 }
791 return $et_c_std_saved
792 }
793
794 proc check_v3_target_sharedlib { } {
795 global v3-sharedlib
796 return ${v3-sharedlib}
797 }
798
799 proc check_v3_target_time { } {
800 global et_time_saved
801 global et_time_target_name
802 global tool
803
804 if { ![info exists et_time_target_name] } {
805 set et_time_target_name ""
806 }
807
808 # If the target has changed since we set the cached value, clear it.
809 set current_target [current_target_name]
810 if { $current_target != $et_time_target_name } {
811 verbose "check_v3_target_time: `$et_time_target_name'" 2
812 set et_time_target_name $current_target
813 if [info exists et_time_saved] {
814 verbose "check_v3_target_time: removing cached result" 2
815 unset et_time_saved
816 }
817 }
818
819 if [info exists et_time_saved] {
820 verbose "check_v3_target_time: using cached result" 2
821 } else {
822 set et_time_saved 0
823
824 # Set up and compile a C++ test program that tries to use
825 # the time function
826 set src time[pid].cc
827
828 set f [open $src "w"]
829 puts $f "#include <time.h>"
830 puts $f "using namespace std;"
831 puts $f "int main ()"
832 puts $f "{"
833 puts $f " time (0);"
834 puts $f "}"
835 close $f
836
837 set lines [v3_target_compile $src /dev/null executable ""]
838 file delete $src
839
840 if [string match "" $lines] {
841 # No error message, compilation succeeded.
842 verbose "check_v3_target_time: compilation succeeded" 2
843 set et_time_saved 1
844 } else {
845 verbose "check_v3_target_time: compilation failed" 2
846 }
847 }
848 return $et_time_saved
849 }
850
851 proc check_v3_target_namedlocale { args } {
852 global et_namedlocale
853 global tool
854
855 set et_namedlocale 0
856
857 # Set up, compile, and execute a C++ test program that tries to use
858 # the required named locale.
859 set exe nlocale[pid].x
860
861 if ![file exists ./$exe] {
862 set src nlocale[pid].cc
863
864 set f [open $src "w"]
865 puts $f "#include <locale>"
866 puts $f "#include <cstdio>"
867 puts $f "using namespace std;"
868 puts $f "int main (int argc, char** argv)"
869 puts $f "{"
870 puts $f " try"
871 puts $f " {"
872 puts $f " locale(*(argv + 1));"
873 puts $f " return 0;"
874 puts $f " }"
875 puts $f " catch(...)"
876 puts $f " {"
877 puts $f " printf(\"locale '%s' not supported\\n\", *(argv + 1));"
878 puts $f " return 1;"
879 puts $f " }"
880 puts $f "}"
881 close $f
882
883 set lines [v3_target_compile $src $exe executable ""]
884 file delete $src
885
886 if ![string match "" $lines] {
887 verbose "check_v3_target_namedlocale: compilation failed" 2
888 return $et_namedlocale
889 }
890 # else No error message, compilation succeeded.
891 }
892
893 set result [${tool}_load "./$exe" "$args" ""]
894 set status [lindex $result 0]
895
896 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
897
898 if { $status == "pass" } {
899 set et_namedlocale 1
900 }
901 return $et_namedlocale
902 }
903
904 proc check_v3_target_debug_mode { } {
905 global et_debug_mode
906 global tool
907
908 if { ![info exists et_debug_mode_target_name] } {
909 set et_debug_mode_target_name ""
910 }
911
912 # If the target has changed since we set the cached value, clear it.
913 set current_target [current_target_name]
914 if { $current_target != $et_debug_mode_target_name } {
915 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
916 set et_debug_mode_target_name $current_target
917 if [info exists et_debug_mode] {
918 verbose "check_v3_target_debug_mode: removing cached result" 2
919 unset et_debug_mode
920 }
921 }
922
923 if [info exists et_debug_mode] {
924 verbose "check_v3_target_debug_mode: using cached result" 2
925 } else {
926 set et_debug_mode 0
927
928 # Set up and preprocess a C++ test program that depends
929 # on debug mode activated.
930 set src debug_mode[pid].cc
931
932 set f [open $src "w"]
933 puts $f "#ifndef _GLIBCXX_DEBUG"
934 puts $f "# error No debug mode"
935 puts $f "#endif"
936 close $f
937
938 set lines [v3_target_compile $src /dev/null preprocess ""]
939 file delete $src
940
941 if [string match "" $lines] {
942 # No error message, preprocessing succeeded.
943 set et_debug_mode 1
944 }
945 }
946 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
947 return $et_debug_mode
948 }
949
950 proc check_v3_target_profile_mode { } {
951 global et_profile_mode
952 global tool
953
954 if { ![info exists et_profile_mode_target_name] } {
955 set et_profile_mode_target_name ""
956 }
957
958 # If the target has changed since we set the cached value, clear it.
959 set current_target [current_target_name]
960 if { $current_target != $et_profile_mode_target_name } {
961 verbose "check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
962 set et_profile_mode_target_name $current_target
963 if [info exists et_profile_mode] {
964 verbose "check_v3_target_profile_mode: removing cached result" 2
965 unset et_profile_mode
966 }
967 }
968
969 if [info exists et_profile_mode] {
970 verbose "check_v3_target_profile_mode: using cached result" 2
971 } else {
972 set et_profile_mode 0
973
974 # Set up and preprocess a C++ test program that depends
975 # on profile mode activated.
976 set src profile_mode[pid].cc
977
978 set f [open $src "w"]
979 puts $f "#ifndef _GLIBCXX_PROFILE"
980 puts $f "# error No profile mode"
981 puts $f "#endif"
982 close $f
983
984 set lines [v3_target_compile $src /dev/null preprocess ""]
985 file delete $src
986
987 if [string match "" $lines] {
988 # No error message, preprocessing succeeded.
989 set et_profile_mode 1
990 }
991 }
992 verbose "check_v3_target_profile_mode: $et_profile_mode" 2
993 return $et_profile_mode
994 }
995
996 proc check_v3_target_normal_mode { } {
997 global et_normal_mode
998 global tool
999
1000 if { ![info exists et_normal_mode_target_name] } {
1001 set et_normal_mode_target_name ""
1002 }
1003
1004 # If the target has changed since we set the cached value, clear it.
1005 set current_target [current_target_name]
1006 if { $current_target != $et_normal_mode_target_name } {
1007 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1008 set et_normal_mode_target_name $current_target
1009 if [info exists et_normal_mode] {
1010 verbose "check_v3_target_normal_mode: removing cached result" 2
1011 unset et_normal_mode
1012 }
1013 }
1014
1015 if [info exists et_normal_mode] {
1016 verbose "check_v3_target_normal_mode: using cached result" 2
1017 } else {
1018 set et_normal_mode 0
1019
1020 # Set up and compile a C++ test program that depends
1021 # on normal mode activated.
1022 set src normal_mode[pid].cc
1023
1024 set f [open $src "w"]
1025 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1026 puts $f "# error No normal mode"
1027 puts $f "#endif"
1028 close $f
1029
1030 set lines [v3_target_compile $src /dev/null preprocess ""]
1031 file delete $src
1032
1033 if [string match "" $lines] {
1034 # No error message, compilation succeeded.
1035 set et_normal_mode 1
1036 }
1037 }
1038 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
1039 return $et_normal_mode
1040 }
1041
1042 proc check_v3_target_parallel_mode { } {
1043 global cxxflags
1044 global v3-libgomp
1045 global et_parallel_mode
1046
1047 global tool
1048
1049 if { ![info exists et_parallel_mode_target_name] } {
1050 set et_parallel_mode_target_name ""
1051 }
1052
1053 # If the target has changed since we set the cached value, clear it.
1054 set current_target [current_target_name]
1055 if { $current_target != $et_parallel_mode_target_name } {
1056 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1057 set et_parallel_mode_target_name $current_target
1058 if [info exists et_parallel_mode] {
1059 verbose "check_v3_target_parallel_mode: removing cached result" 2
1060 unset et_parallel_mode
1061 }
1062 }
1063
1064 if [info exists et_parallel_mode] {
1065 verbose "check_v3_target_parallel_mode: using cached result" 2
1066 } else {
1067 set et_parallel_mode 0
1068
1069 # If 'make check-parallel' is running the test succeeds.
1070 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1071 set et_parallel_mode 1
1072 }
1073 }
1074 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1075 return $et_parallel_mode
1076 }
1077
1078 proc check_v3_target_cstdint { } {
1079 global cxxflags
1080 global DEFAULT_CXXFLAGS
1081 global et_cstdint
1082
1083 global tool
1084
1085 if { ![info exists et_cstdint_target_name] } {
1086 set et_cstdint_target_name ""
1087 }
1088
1089 # If the target has changed since we set the cached value, clear it.
1090 set current_target [current_target_name]
1091 if { $current_target != $et_cstdint_target_name } {
1092 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1093 set et_cstdint_target_name $current_target
1094 if [info exists et_cstdint] {
1095 verbose "check_v3_target_cstdint: removing cached result" 2
1096 unset et_cstdint
1097 }
1098 }
1099
1100 if [info exists et_cstdint] {
1101 verbose "check_v3_target_cstdint: using cached result" 2
1102 } else {
1103 set et_cstdint 0
1104
1105 # Set up and preprocess a C++0x test program that depends
1106 # on the C99 stdint facilities to be available.
1107 set src cstdint[pid].cc
1108
1109 set f [open $src "w"]
1110 puts $f "#include <tr1/cstdint>"
1111 puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1112 puts $f "# error No C99 stdint"
1113 puts $f "#endif"
1114 close $f
1115
1116 set cxxflags_saved $cxxflags
1117 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1118
1119 set lines [v3_target_compile $src /dev/null preprocess ""]
1120 set cxxflags $cxxflags_saved
1121 file delete $src
1122
1123 if [string match "" $lines] {
1124 # No error message, preprocess succeeded.
1125 set et_cstdint 1
1126 } else {
1127 verbose "check_v3_target_cstdint: compilation failed" 2
1128 }
1129 }
1130 verbose "check_v3_target_cstdint: $et_cstdint" 2
1131 return $et_cstdint
1132 }
1133
1134 proc check_v3_target_cmath { } {
1135 global cxxflags
1136 global DEFAULT_CXXFLAGS
1137 global et_c99_math
1138
1139 global tool
1140
1141 if { ![info exists et_c99_math_target_name] } {
1142 set et_c99_math_target_name ""
1143 }
1144
1145 # If the target has changed since we set the cached value, clear it.
1146 set current_target [current_target_name]
1147 if { $current_target != $et_c99_math_target_name } {
1148 verbose "check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1149 set et_c99_math_target_name $current_target
1150 if [info exists et_c99_math] {
1151 verbose "check_v3_target_c99_math: removing cached result" 2
1152 unset et_c99_math
1153 }
1154 }
1155
1156 if [info exists et_c99_math] {
1157 verbose "check_v3_target_c99_math: using cached result" 2
1158 } else {
1159 set et_c99_math 0
1160
1161 # Set up and preprocess a C++0x test program that depends
1162 # on the C99 math facilities to be available.
1163 set src c99_math[pid].cc
1164
1165 set f [open $src "w"]
1166 puts $f "#include <tr1/cmath>"
1167 puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1168 puts $f "# error No C99 math"
1169 puts $f "#endif"
1170 close $f
1171
1172 set cxxflags_saved $cxxflags
1173 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1174
1175 set lines [v3_target_compile $src /dev/null preprocess ""]
1176 set cxxflags $cxxflags_saved
1177 file delete $src
1178
1179 if [string match "" $lines] {
1180 # No error message, preprocess succeeded.
1181 set et_c99_math 1
1182 } else {
1183 verbose "check_v3_target_c99_math: compilation failed" 2
1184 }
1185 }
1186 verbose "check_v3_target_c99_math: $et_c99_math" 2
1187 return $et_c99_math
1188 }
1189
1190 proc check_v3_target_atomic_builtins { } {
1191 global cxxflags
1192 global DEFAULT_CXXFLAGS
1193 global et_atomic_builtins
1194
1195 global tool
1196
1197 if { ![info exists et_atomic_builtins_target_name] } {
1198 set et_atomic_builtins_target_name ""
1199 }
1200
1201 # If the target has changed since we set the cached value, clear it.
1202 set current_target [current_target_name]
1203 if { $current_target != $et_atomic_builtins_target_name } {
1204 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1205 set et_atomic_builtins_target_name $current_target
1206 if [info exists et_atomic_builtins] {
1207 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1208 unset et_atomic_builtins
1209 }
1210 }
1211
1212 if [info exists et_atomic_builtins] {
1213 verbose "check_v3_target_atomic_builtins: using cached result" 2
1214 } else {
1215 set et_atomic_builtins 0
1216
1217 # Set up and preprocess a C++0x test program that depends
1218 # on the atomic builtin facilities to be available.
1219 set src atomic_builtins[pid].cc
1220
1221 set f [open $src "w"]
1222 puts $f "#include <bits/c++config.h>"
1223 puts $f "#ifndef _GLIBCXX_ATOMIC_BUILTINS_4"
1224 puts $f "# error No atomic builtins"
1225 puts $f "#endif"
1226 close $f
1227
1228 set cxxflags_saved $cxxflags
1229 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1230
1231 set lines [v3_target_compile $src /dev/null preprocess ""]
1232 set cxxflags $cxxflags_saved
1233 file delete $src
1234
1235 if [string match "" $lines] {
1236 # No error message, preprocess succeeded.
1237 set et_atomic_builtins 1
1238 } else {
1239 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1240 }
1241 }
1242 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1243 return $et_atomic_builtins
1244 }
1245
1246 proc check_v3_target_gthreads { } {
1247 global cxxflags
1248 global DEFAULT_CXXFLAGS
1249 global et_gthreads
1250
1251 global tool
1252
1253 if { ![info exists et_gthreads_target_name] } {
1254 set et_gthreads_target_name ""
1255 }
1256
1257 # If the target has changed since we set the cached value, clear it.
1258 set current_target [current_target_name]
1259 if { $current_target != $et_gthreads_target_name } {
1260 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1261 set et_gthreads_target_name $current_target
1262 if [info exists et_gthreads] {
1263 verbose "check_v3_target_gthreads: removing cached result" 2
1264 unset et_gthreads
1265 }
1266 }
1267
1268 if [info exists et_gthreads] {
1269 verbose "check_v3_target_gthreads: using cached result" 2
1270 } else {
1271 set et_gthreads 0
1272
1273 # Set up and preprocess a C++0x test program that depends
1274 # on the gthreads facilities to be available.
1275 set src gthreads[pid].cc
1276
1277 set f [open $src "w"]
1278 puts $f "#include <bits/c++config.h>"
1279 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1280 puts $f "# error No gthread"
1281 puts $f "#endif"
1282 close $f
1283
1284 set cxxflags_saved $cxxflags
1285 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1286
1287 set lines [v3_target_compile $src /dev/null preprocess ""]
1288 set cxxflags $cxxflags_saved
1289 file delete $src
1290
1291 if [string match "" $lines] {
1292 # No error message, preprocessing succeeded.
1293 set et_gthreads 1
1294 } else {
1295 verbose "check_v3_target_gthreads: compilation failed" 2
1296 }
1297 }
1298 verbose "check_v3_target_gthreads: $et_gthreads" 2
1299 return $et_gthreads
1300 }
1301
1302 proc check_v3_target_gthreads_timed { } {
1303 global cxxflags
1304 global DEFAULT_CXXFLAGS
1305 global et_gthreads_timed
1306
1307 global tool
1308
1309 if { ![info exists et_gthreads_timed_target_name] } {
1310 set et_gthreads_timed_target_name ""
1311 }
1312
1313 # If the target has changed since we set the cached value, clear it.
1314 set current_target [current_target_name]
1315 if { $current_target != $et_gthreads_timed_target_name } {
1316 verbose "check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1317 set et_gthreads_timed_target_name $current_target
1318 if [info exists et_gthreads_timed] {
1319 verbose "check_v3_target_gthreads_timed: removing cached result" 2
1320 unset et_gthreads_timed
1321 }
1322 }
1323
1324 if [info exists et_gthreads_timed] {
1325 verbose "check_v3_target_gthreads_timed: using cached result" 2
1326 } else {
1327 set et_gthreads_timed 0
1328
1329 # Set up and preprocess a C++0x test program that depends
1330 # on the gthreads timed mutex facilities to be available.
1331 set src gthreads_timed[pid].cc
1332
1333 set f [open $src "w"]
1334 puts $f "#include <bits/c++config.h>"
1335 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1336 puts $f "# error No gthread"
1337 puts $f "#endif"
1338 puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1339 puts $f "# error No gthread timed mutexes"
1340 puts $f "#endif"
1341 close $f
1342
1343 set cxxflags_saved $cxxflags
1344 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1345
1346 set lines [v3_target_compile $src /dev/null preprocess ""]
1347 set cxxflags $cxxflags_saved
1348 file delete $src
1349
1350 if [string match "" $lines] {
1351 # No error message, preprocessing succeeded.
1352 set et_gthreads_timed 1
1353 } else {
1354 verbose "check_v3_target_gthreads_timed: compilation failed" 2
1355 }
1356 }
1357 verbose "check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1358 return $et_gthreads_timed
1359 }
1360
1361
1362 proc check_v3_target_nanosleep { } {
1363 global cxxflags
1364 global DEFAULT_CXXFLAGS
1365 global et_nanosleep
1366
1367 global tool
1368
1369 if { ![info exists et_nanosleep_target_name] } {
1370 set et_nanosleep_target_name ""
1371 }
1372
1373 # If the target has changed since we set the cached value, clear it.
1374 set current_target [current_target_name]
1375 if { $current_target != $et_nanosleep_target_name } {
1376 verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1377 set et_nanosleep_target_name $current_target
1378 if [info exists et_nanosleep] {
1379 verbose "check_v3_target_nanosleep: removing cached result" 2
1380 unset et_nanosleep
1381 }
1382 }
1383
1384 if [info exists et_nanosleep] {
1385 verbose "check_v3_target_nanosleep: using cached result" 2
1386 } else {
1387 set et_nanosleep 0
1388
1389 # Set up and preprocess a C++0x test program that depends
1390 # on the nanosleep facilities to be available.
1391 set src nanosleep[pid].cc
1392
1393 set f [open $src "w"]
1394 puts $f "#include <bits/c++config.h>"
1395 puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP"
1396 puts $f "# error No nanosleep"
1397 puts $f "#endif"
1398 close $f
1399
1400 set cxxflags_saved $cxxflags
1401 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1402
1403 set lines [v3_target_compile $src /dev/null preprocess ""]
1404 set cxxflags $cxxflags_saved
1405 file delete $src
1406
1407 if [string match "" $lines] {
1408 # No error message, preprocessing succeeded.
1409 set et_nanosleep 1
1410 } else {
1411 verbose "check_v3_target_nanosleep: compilation failed" 2
1412 }
1413 }
1414 verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1415 return $et_nanosleep
1416 }
1417
1418 proc check_v3_target_sched_yield { } {
1419 global cxxflags
1420 global DEFAULT_CXXFLAGS
1421 global et_sched_yield
1422
1423 global tool
1424
1425 if { ![info exists et_sched_yield_target_name] } {
1426 set et_sched_yield_target_name ""
1427 }
1428
1429 # If the target has changed since we set the cached value, clear it.
1430 set current_target [current_target_name]
1431 if { $current_target != $et_sched_yield_target_name } {
1432 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1433 set et_sched_yield_target_name $current_target
1434 if [info exists et_sched_yield] {
1435 verbose "check_v3_target_sched_yield: removing cached result" 2
1436 unset et_sched_yield
1437 }
1438 }
1439
1440 if [info exists et_sched_yield] {
1441 verbose "check_v3_target_sched_yield: using cached result" 2
1442 } else {
1443 set et_sched_yield 0
1444
1445 # Set up and preprocess a C++0x test program that depends
1446 # on the sched_yield facility to be available.
1447 set src sched_yield[pid].cc
1448
1449 set f [open $src "w"]
1450 puts $f "#include <bits/c++config.h>"
1451 puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD"
1452 puts $f "# error No sched yield"
1453 puts $f "#endif"
1454 close $f
1455
1456 set cxxflags_saved $cxxflags
1457 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1458
1459 set lines [v3_target_compile $src /dev/null preprocess ""]
1460 set cxxflags $cxxflags_saved
1461 file delete $src
1462
1463 if [string match "" $lines] {
1464 # No error message, preprocessing succeeded.
1465 set et_sched_yield 1
1466 } else {
1467 verbose "check_v3_target_sched_yield: compilation failed" 2
1468 }
1469 }
1470 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1471 return $et_sched_yield
1472 }
1473
1474 proc check_v3_target_string_conversions { } {
1475 global cxxflags
1476 global DEFAULT_CXXFLAGS
1477 global et_string_conversions
1478
1479 global tool
1480
1481 if { ![info exists et_string_conversions_target_name] } {
1482 set et_string_conversions_target_name ""
1483 }
1484
1485 # If the target has changed since we set the cached value, clear it.
1486 set current_target [current_target_name]
1487 if { $current_target != $et_string_conversions_target_name } {
1488 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1489 set et_string_conversions_target_name $current_target
1490 if [info exists et_string_conversions] {
1491 verbose "check_v3_target_string_conversions: removing cached result" 2
1492 unset et_string_conversions
1493 }
1494 }
1495
1496 if [info exists et_string_conversions] {
1497 verbose "check_v3_target_string_conversions: using cached result" 2
1498 } else {
1499 set et_string_conversions 0
1500
1501 # Set up and preprocess a C++0x test program that depends
1502 # on the string_conversions facilities to be available.
1503 set src string_conversions[pid].cc
1504
1505 set f [open $src "w"]
1506 puts $f "#include <bits/c++config.h>"
1507 puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1508 puts $f "# error No string conversions"
1509 puts $f "#endif"
1510 close $f
1511
1512 set cxxflags_saved $cxxflags
1513 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1514
1515 set lines [v3_target_compile $src /dev/null preprocess ""]
1516 set cxxflags $cxxflags_saved
1517 file delete $src
1518
1519 if [string match "" $lines] {
1520 # No error message, preprocessing succeeded.
1521 set et_string_conversions 1
1522 } else {
1523 verbose "check_v3_target_string_conversions: compilation failed" 2
1524 }
1525 }
1526 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1527 return $et_string_conversions
1528 }
1529
1530 proc check_v3_target_swprintf { } {
1531 global cxxflags
1532 global DEFAULT_CXXFLAGS
1533 global et_swprintf
1534
1535 global tool
1536
1537 if { ![info exists et_swprintf_target_name] } {
1538 set et_swprintf_target_name ""
1539 }
1540
1541 # If the target has changed since we set the cached value, clear it.
1542 set current_target [current_target_name]
1543 if { $current_target != $et_swprintf_target_name } {
1544 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1545 set et_swprintf_target_name $current_target
1546 if [info exists et_swprintf] {
1547 verbose "check_v3_target_swprintf: removing cached result" 2
1548 unset et_swprintf
1549 }
1550 }
1551
1552 if [info exists et_swprintf] {
1553 verbose "check_v3_target_swprintf: using cached result" 2
1554 } else {
1555 set et_swprintf 0
1556
1557 # Set up and preprocess a C++0x test program that depends
1558 # on a standard swprintf function to be available.
1559 set src swprintf[pid].cc
1560
1561 set f [open $src "w"]
1562 puts $f "#include <bits/c++config.h>"
1563 puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1564 puts $f "# error No swprintf"
1565 puts $f "#endif"
1566 close $f
1567
1568 set cxxflags_saved $cxxflags
1569 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1570
1571 set lines [v3_target_compile $src /dev/null preprocess ""]
1572 set cxxflags $cxxflags_saved
1573 file delete $src
1574
1575 if [string match "" $lines] {
1576 # No error message, preprocessing succeeded.
1577 set et_swprintf 1
1578 } else {
1579 verbose "check_v3_target_swprintf: compilation failed" 2
1580 }
1581 }
1582 verbose "check_v3_target_swprintf: $et_swprintf" 2
1583 return $et_swprintf
1584 }
1585
1586 proc check_v3_target_binary_io { } {
1587 global cxxflags
1588 global DEFAULT_CXXFLAGS
1589 global et_binary_io
1590
1591 global tool
1592
1593 if { ![info exists et_binary_io_target_name] } {
1594 set et_binary_io_target_name ""
1595 }
1596
1597 # If the target has changed since we set the cached value, clear it.
1598 set current_target [current_target_name]
1599 if { $current_target != $et_binary_io_target_name } {
1600 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1601 set et_binary_io_target_name $current_target
1602 if [info exists et_binary_io] {
1603 verbose "check_v3_target_binary_io: removing cached result" 2
1604 unset et_binary_io
1605 }
1606 }
1607
1608 if [info exists et_binary_io] {
1609 verbose "check_v3_target_binary_io: using cached result" 2
1610 } else {
1611 set et_binary_io 0
1612
1613 # Set up and preprocess a C++0x test program that depends
1614 # on text and binary I/O being the same.
1615 set src binary_io[pid].cc
1616
1617 set f [open $src "w"]
1618 puts $f "#include <bits/c++config.h>"
1619 puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1620 puts $f "# error No binary io"
1621 puts $f "#endif"
1622 close $f
1623
1624 set cxxflags_saved $cxxflags
1625 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1626
1627 set lines [v3_target_compile $src /dev/null preprocess ""]
1628 set cxxflags $cxxflags_saved
1629 file delete $src
1630
1631 if [string match "" $lines] {
1632 # No error message, preprocessing succeeded.
1633 set et_binary_io 1
1634 } else {
1635 verbose "check_v3_target_binary_io: compilation failed" 2
1636 }
1637 }
1638 verbose "check_v3_target_binary_io: $et_binary_io" 2
1639 return $et_binary_io
1640 }
1641
1642 proc check_v3_target_nprocs { } {
1643 global cxxflags
1644 global DEFAULT_CXXFLAGS
1645 global et_nprocs
1646
1647 global tool
1648
1649 if { ![info exists et_nprocs_target_name] } {
1650 set et_nprocs_target_name ""
1651 }
1652
1653 # If the target has changed since we set the cached value, clear it.
1654 set current_target [current_target_name]
1655 if { $current_target != $et_nprocs_target_name } {
1656 verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1657 set et_nprocs_target_name $current_target
1658 if [info exists et_nprocs] {
1659 verbose "check_v3_target_nprocs: removing cached result" 2
1660 unset et_nprocs
1661 }
1662 }
1663
1664 if [info exists et_nprocs] {
1665 verbose "check_v3_target_nprocs: using cached result" 2
1666 } else {
1667 set et_nprocs 0
1668
1669 # Set up and preprocess a C++0x test program that depends
1670 # on either get_nprocs or sysconf to be available.
1671 set src nprocs[pid].cc
1672
1673 set f [open $src "w"]
1674 puts $f "#include <bits/c++config.h>"
1675 puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
1676 puts $f "#elif defined(_GLIBCXX_USE_SYSCONF)"
1677 puts $f "# include <unistd.h>"
1678 puts $f "# if !defined(_SC_NPROCESSORS_ONLN)"
1679 puts $f "# error No sysconf option"
1680 puts $f "# endif"
1681 puts $f "#else"
1682 puts $f "# error No get_nprocs or sysconf"
1683 puts $f "#endif"
1684 close $f
1685
1686 set cxxflags_saved $cxxflags
1687 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1688
1689 set lines [v3_target_compile $src /dev/null preprocess ""]
1690 set cxxflags $cxxflags_saved
1691 file delete $src
1692
1693 if [string match "" $lines] {
1694 # No error message, preprocess succeeded.
1695 set et_nprocs 1
1696 } else {
1697 verbose "check_v3_target_nprocs: compilation failed" 2
1698 }
1699 }
1700 verbose "check_v3_target_nprocs: $et_nprocs" 2
1701 return $et_nprocs
1702 }
1703
1704
1705 set additional_prunes ""