]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/lib/libstdc++.exp
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
CommitLineData
0b1d1fa1 1# libstdc++ "tool init file" for DejaGNU
b665bffc 2
f1717362 3# Copyright (C) 2001-2016 Free Software Foundation, Inc.
0b1d1fa1 4#
c152eebe 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
6bc9506f 7# the Free Software Foundation; either version 3 of the License, or
c152eebe 8# (at your option) any later version.
9#
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.
14#
15# You should have received a copy of the GNU General Public License
6bc9506f 16# along with this program; see the file COPYING3. If not see
17# <http://www.gnu.org/licenses/>.
b665bffc 18
c152eebe 19
0b1d1fa1 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.
24#
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-".
28#
29# libstdc++_* callbacks we don't define, but could:
30# ..._option_help prints additional --help output
31# ..._option_proc (--foo) process our own options
0b1d1fa1 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
35#
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.
39
40proc load_gcc_lib { filename } {
af902e2b 41 global srcdir loaded_libs
42
0b1d1fa1 43 load_file $srcdir/../../gcc/testsuite/lib/$filename
af902e2b 44 set loaded_libs($filename) ""
0b1d1fa1 45}
46
47# system routines
c152eebe 48load_lib dg.exp
49load_lib libgloss.exp
0b1d1fa1 50# compiler routines, then ours
d7b207f6 51load_gcc_lib target-supports.exp
30c40ce2 52load_gcc_lib target-supports-dg.exp
c152eebe 53load_lib prune.exp
0b1d1fa1 54load_lib dg-options.exp
bcafd86c 55load_gcc_lib scanasm.exp
c0e31427 56load_gcc_lib target-libpath.exp
0557b60a 57load_gcc_lib timeout.exp
58load_gcc_lib timeout-dg.exp
53994134 59load_gcc_lib wrapper.exp
39367567 60load_gcc_lib target-utils.exp
0b1d1fa1 61
62# Useful for debugging. Pass the name of a variable and the verbosity
63# threshold (number of -v's on the command line).
64proc v3track { var n } {
65 upvar $var val
66 verbose "++ $var is $val" $n
67}
c152eebe 68
e2b86ae4 69# Copy file to the target.
70proc v3-copy-file {src dst} {
71 if { [catch { set symlink [file readlink $src] } x] } then {
72 remote_download target $src $dst
73 } else {
74 if { [regexp "^/" "$symlink"] } then {
75 remote_download target $symlink $dst
76 } else {
77 set dirname [file dirname $f]
78 remote_download target $dirname/$symlink $dst
79 }
80 }
81}
82
67549fc2 83# Called by v3-init below. "Static" to this file.
345e0682 84proc v3-copy-files {srcfiles} {
c152eebe 85 foreach f $srcfiles {
e2b86ae4 86 v3-copy-file $f [file tail $f]
c152eebe 87 }
88}
89
0b1d1fa1 90# Called once, during runtest.exp setup.
91proc libstdc++_init { testfile } {
92 global env
3ec8f42c 93 global v3-sharedlib v3-libgomp
345e0682 94 global srcdir blddir objdir tool_root_dir
b710ec85 95 global cc cxx cxxflags cxxpchflags cxxldflags cxxvtvflags
c152eebe 96 global includes
c152eebe 97 global gluefile wrap_flags
c0e31427 98 global ld_library_path
0b1d1fa1 99 global target_triplet
7fc8c877 100 global flags_file
0557b60a 101 global tool_timeout
145d8b5f 102 global DEFAULT_CXXFLAGS
103 global STATIC_LIBCXXFLAGS
c152eebe 104
4f67a81c 105 # We set LC_ALL and LANG to C so that we get the same error
106 # messages as expected.
e899394f 107 setenv LC_ALL C
108 setenv LANG C
109
0bc0130b 110 # LANGUAGE changes the behavior of GNU gettext(3) and causes
111 # std::messages tests to fail.
112 array unset env LANGUAGE
113
94d54446 114 # Many hosts now default to a non-ASCII C locale, however, so
115 # they can set a charset encoding here if they need.
116 if { [ishost "*-*-cygwin*"] } {
117 setenv LC_ALL C.ASCII
118 setenv LANG C.ASCII
119 }
120
c152eebe 121 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
0b1d1fa1 122 set flags_file "${blddir}/scripts/testsuite_flags"
145d8b5f 123 set shlib_ext [get_shlib_extension]
0b1d1fa1 124 v3track flags_file 2
125
126 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
127 # Use this variable if the behavior
128 # 1) only applies to libstdc++ testing
129 # 2) might need to be negated
130 # In particular, some tests have to be run without precompiled
131 # headers, or without assertions.
145d8b5f 132
0b1d1fa1 133 if ![info exists DEFAULT_CXXFLAGS] then {
a21676d1 134 set DEFAULT_CXXFLAGS ""
0b1d1fa1 135 # Host specific goo here.
136 if { [string match "powerpc-*-darwin*" $target_triplet] } {
137 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
138 }
139 }
140 v3track DEFAULT_CXXFLAGS 2
c152eebe 141
142 # By default, we assume we want to run program images.
143 global dg-do-what-default
144 set dg-do-what-default run
145
146 # Copy any required data files.
345e0682 147 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
148 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
c152eebe 149
dc6ce3b8 150 set ld_library_path_tmp ""
151
d437d68d 152 # Locate libgcc.a so we don't need to account for different values of
c152eebe 153 # SHLIB_EXT on different platforms
154 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
155 if {$gccdir != ""} {
67549fc2 156 set gccdir [file dirname $gccdir]
f09e0522 157 append ld_library_path_tmp ":${gccdir}"
c152eebe 158 }
0b1d1fa1 159 v3track gccdir 3
c152eebe 160
dc6ce3b8 161 # Locate libgomp. This is only required for parallel mode.
3ec8f42c 162 set v3-libgomp 0
145d8b5f 163 set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
dc6ce3b8 164 if {$libgompdir != ""} {
3ec8f42c 165 set v3-libgomp 1
dc6ce3b8 166 set libgompdir [file dirname $libgompdir]
f09e0522 167 append ld_library_path_tmp ":${libgompdir}"
3ec8f42c 168 verbose -log "libgomp support detected"
dc6ce3b8 169 }
170 v3track libgompdir 3
171
b710ec85 172 # Locate libvtv. This is only required for --enable-vtable-verify.
173 set v3-libvtv 0
174 set libvtvdir [lookfor_file $blddir/../libvtv .libs/libvtv.$shlib_ext]
175 if {$libvtvdir != ""} {
176 set v3-libvtv 1
177 set libvtvdir [file dirname $libvtvdir]
178 append ld_library_path_tmp ":${libvtvdir}"
179 verbose -log "libvtv support detected"
180 }
181 v3track libvtvdir 3
182
dc6ce3b8 183 # Locate libstdc++ shared library. (ie libstdc++.so.)
6eb81ee0 184 set v3-sharedlib 0
145d8b5f 185 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
6eb81ee0 186 if {$sharedlibdir != ""} {
2c27bea9 187 if { ([string match "*-*-linux*" $target_triplet]
188 || [string match "*-*-gnu*" $target_triplet])
189 && [isnative] } then {
681ed1dc 190 set v3-sharedlib 1
191 verbose -log "shared library support detected"
192 }
6eb81ee0 193 }
194 v3track v3-sharedlib 3
195
145d8b5f 196 set STATIC_LIBCXXFLAGS ""
197 set staticlibdir [lookfor_file $blddir src/.libs/libstdc++.a]
198 if {$staticlibdir != ""} {
199 set staticlibdir [file dirname $staticlibdir]
200 # Some targets use libstdc++.a%s in their specs, so they need a
201 # -B option for uninstalled testing.
202 set STATIC_LIBCXXFLAGS " -B${staticlibdir} "
203 }
204
d437d68d 205 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
175d5683 206 if {$gccdir != ""} {
3e54888f 207 set compiler ${gccdir}/xg++
dc6ce3b8 208 set ld_library_path ${ld_library_path_tmp}
f09e0522 209 append ld_library_path ":${blddir}/src/.libs"
210
211 if { [is_remote host] == 0 && [which $compiler] != 0 } {
212 foreach i "[exec $compiler --print-multi-lib]" {
213 set mldir ""
214 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
215 set mldir [string trimright $mldir "\;@"]
216 if { "$mldir" == "." } {
217 continue
218 }
219 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
220 append ld_library_path ":${gccdir}/${mldir}"
221 }
222 }
223 }
224
175d5683 225 set_ld_library_path_env_vars
226 if [info exists env(LD_LIBRARY_PATH)] {
227 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
228 }
229 } else {
230 set compiler [transform "g++"]
c0e31427 231 }
c152eebe 232
0557b60a 233 # Set the default timeout for v3 tests.
234 set tool_timeout 600
235
ad81f8d6 236 # Default settings.
237 set cxx [transform "g++"]
a2a4cb2d 238 set cxxflags "-D_GLIBCXX_ASSERT -fmessage-length=0"
32ce5c15 239 set cxxpchflags ""
b710ec85 240 set cxxvtvflags ""
ad81f8d6 241 set cxxldflags ""
242 set cc [transform "gcc"]
243 # Locate testsuite_hooks.h and other testsuite headers.
244 set includes "-I${srcdir}/util"
177d1b75 245 # Adapt the defaults for special circumstances.
c152eebe 246 if [is_remote host] {
177d1b75 247 # A remote host does not, in general, have access to the
248 # $srcdir so we copy the testsuite headers into the current
249 # directory, and then add that to the search path.
250 foreach src [glob "${srcdir}/util/*.h" \
251 "${srcdir}/util/*.cc" \
dfdfba40 252 "${srcdir}/util/*.tcc" \
253 "${srcdir}/util/*.hpp" \
254 "${srcdir}/util/*/*.h" \
177d1b75 255 "${srcdir}/util/*/*.cc" \
dfdfba40 256 "${srcdir}/util/*/*.tcc" \
177d1b75 257 "${srcdir}/util/*/*.hpp" \
dfdfba40 258 "${srcdir}/util/*/*/*.h" \
177d1b75 259 "${srcdir}/util/*/*/*.cc" \
dfdfba40 260 "${srcdir}/util/*/*/*.tcc" \
177d1b75 261 "${srcdir}/util/*/*/*.hpp" \
dfdfba40 262 "${srcdir}/util/*/*/*/*.h" \
177d1b75 263 "${srcdir}/util/*/*/*/*.cc" \
dfdfba40 264 "${srcdir}/util/*/*/*/*.tcc" \
177d1b75 265 "${srcdir}/util/*/*/*/*.hpp" \
dfdfba40 266 "${srcdir}/util/*/*/*/*/*.h" \
177d1b75 267 "${srcdir}/util/*/*/*/*/*.cc" \
dfdfba40 268 "${srcdir}/util/*/*/*/*/*.tcc" \
177d1b75 269 "${srcdir}/util/*/*/*/*/*.hpp" ] {
270 # Remove everything up to "util/..."
271 set dst [string range $src [string length "${srcdir}/"] end]
272 # Create the directory containing the file.
273 set dir [file dirname $dst]
274 remote_exec host "mkdir" [list "-p" "$dir"]
af9a450c 275 # Download the file.
177d1b75 276 set result [remote_download host $src $dst]
277 if { $result == "" } {
af9a450c 278 verbose -log "Unable to download ${srcdir}/${src} to host."
177d1b75 279 return "untested"
280 }
281 }
282 set includes "-Iutil"
283 } elseif { [file exists $flags_file] } {
c152eebe 284 # If we find a testsuite_flags file, we're testing in the build dir.
177d1b75 285 set cxx [exec sh $flags_file --build-cxx]
286 set cxxflags [exec sh $flags_file --cxxflags]
32ce5c15 287 set cxxpchflags [exec sh $flags_file --cxxpchflags]
b710ec85 288 set cxxvtvflags [exec sh $flags_file --cxxvtvflags]
af9a450c 289 set cxxldflags [exec sh $flags_file --cxxldflags]
290 set cc [exec sh $flags_file --build-cc]
177d1b75 291 set includes [exec sh $flags_file --build-includes]
c152eebe 292 }
a2c4a7f3 293 append cxxflags " "
294 append cxxflags [getenv CXXFLAGS]
61dc68af 295
b0ce9fe7 296 if ![regexp ".*-O" $cxxflags] {
61dc68af 297 append cxxflags " -g -O2"
298 }
299
a2c4a7f3 300 v3track cxxflags 2
c152eebe 301
5bee5337 302 # Should be as good as -fdiagnostics-color=never, but more compatible
303 setenv GCC_COLORS ""
1e4fed69 304 # Always use MO files built by this test harness.
af9a450c 305 set ccflags "$cxxflags -DLOCALEDIR=\".\""
5bee5337 306 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
1e4fed69 307
a21676d1 308 # If a PCH file is available, use it. We must delay performing
309 # this check until $cxx and such have been initialized because we
310 # perform a test compilation. (Ideally, gcc --print-file-name would
311 # list PCH files, but it does not.)
32ce5c15 312 if { $cxxpchflags != "" } {
a21676d1 313 set src "config[pid].cc"
314 set f [open $src "w"]
315 puts $f "int main () {}"
316 close $f
317
32ce5c15 318 # Fixme: "additional_flags=$cxxpchflags" fails, but would be
319 # useful as then the requested variant of the pre-build PCH
320 # files could be tested to see if it works.
a21676d1 321 set lines [v3_target_compile $src "config[pid].o" object \
32ce5c15 322 "additional_flags=-include additional_flags=bits/stdc++.h"]
323 if { $lines != "" } {
324 verbose -log "Requested PCH file: $cxxpchflags"
325 verbose -log "is not working, and will not be used."
326 set cxxpchflags ""
327 }
a21676d1 328 file delete $src
32ce5c15 329 }
330 v3track cxxpchflags 2
331
332 global PCH_CXXFLAGS
333 if ![info exists PCH_CXXFLAGS] then {
334 set PCH_CXXFLAGS $cxxpchflags
a21676d1 335 v3track PCH_CXXFLAGS 2
336 }
337
2f506d70 338 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
c152eebe 339}
340
7b7d38d6 341# Callback for cleanup routines.
c1894418 342proc libstdc++_exit { } {
343 global gluefile;
344
345 if [info exists gluefile] {
346 file_on_build delete $gluefile;
347 unset gluefile;
348 }
349}
350
c152eebe 351# Callback from system dg-test.
67549fc2 352proc libstdc++-dg-test { prog do_what extra_tool_flags } {
c152eebe 353 # Set up the compiler flags, based on what we're going to do.
c152eebe 354 switch $do_what {
67549fc2 355 "preprocess" {
356 set compile_type "preprocess"
357 set output_file "[file rootname [file tail $prog]].i"
358 }
359 "compile" {
360 set compile_type "assembly"
361 set output_file "[file rootname [file tail $prog]].s"
362 }
363 "assemble" {
364 set compile_type "object"
365 set output_file "[file rootname [file tail $prog]].o"
366 }
367 "link" {
368 set compile_type "executable"
369 set output_file "./[file rootname [file tail $prog]].exe"
370 }
371 "run" {
372 set compile_type "executable"
373 # FIXME: "./" is to cope with "." not being in $PATH.
374 # Should this be handled elsewhere?
375 # YES.
376 set output_file "./[file rootname [file tail $prog]].exe"
377 # This is the only place where we care if an executable was
378 # created or not. If it was, dg.exp will try to run it.
023af126 379 catch { remote_file build delete $output_file }
67549fc2 380 }
6b2678bb 381 default {
67549fc2 382 perror "$do_what: not a valid dg-do keyword"
383 return ""
384 }
c152eebe 385 }
6b2678bb 386
bcf86f01 387 # Short-circut a bunch of complicated goo here for the special
388 # case of compiling a test file as a "C" file, not as C++. Why? So
389 # -nostdc++ doesn't trip us up. So all the extra object files
390 # don't trip us up. So automatically linking in libstdc++ doesn't
391 # happen. So CXXFLAGS don't error.
b9dd4b84 392 set select_compile "v3_target_compile"
c152eebe 393 set options ""
394 if { $extra_tool_flags != "" } {
6b2678bb 395 verbose -log "extra_tool_flags are:"
396 verbose -log $extra_tool_flags
397 if { [string first "-x c" $extra_tool_flags ] != -1 } {
6b2678bb 398 verbose -log "compiling and executing as C, not C++"
b9dd4b84 399 set edit_tool_flags $extra_tool_flags
400 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
401 lappend options "additional_flags=$edit_tool_flags"
b9dd4b84 402 set select_compile "v3_target_compile_as_c"
6b2678bb 403 } else {
404 lappend options "additional_flags=$extra_tool_flags"
405 }
c152eebe 406 }
407
0b1d1fa1 408 # There is a libstdc++_compile made for us by default (via the tool-
409 # and-target file), but the defaults are lacking in goodness.
b9dd4b84 410 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
c152eebe 411
7972c5a7 412 set unsupported_message [libstdc++_check_unsupported_p $comp_output]
413 if { $unsupported_message != "" } {
414 set comp_output "::unsupported::$unsupported_message"
415 }
416
c152eebe 417 return [list $comp_output $output_file]
418}
419
0557b60a 420# Override the DejaGnu dg-test in order to clear flags after a test, as
421# is done for compiler tests in gcc-dg.exp.
422
423if { [info procs saved-dg-test] == [list] } {
424 rename dg-test saved-dg-test
425
426 proc dg-test { args } {
e63793af 427 global additional_prunes
0557b60a 428 global errorInfo
4e7290b1 429 global testname_with_flags
0557b60a 430
431 if { [ catch { eval saved-dg-test $args } errmsg ] } {
432 set saved_info $errorInfo
e63793af 433 set additional_prunes ""
4e7290b1 434 if [info exists testname_with_flags] {
435 unset testname_with_flags
436 }
0557b60a 437 unset_timeout_vars
438 error $errmsg $saved_info
439 }
e63793af 440 set additional_prunes ""
0557b60a 441 unset_timeout_vars
4e7290b1 442 if [info exists testname_with_flags] {
443 unset testname_with_flags
444 }
0557b60a 445 }
446}
447
175d5683 448# True if the library supports wchar_t.
ca1b7575 449set v3-wchar_t 0
175d5683 450
451# True if the library supports threads.
ca1b7575 452set v3-threads 0
175d5683 453
099c5a78 454# True if the library supports symbol versioning.
455set v3-symver 0
456
67549fc2 457# Called from libstdc++-dg-test above. Calls back into system's
c152eebe 458# target_compile to actually do the work.
67549fc2 459proc v3_target_compile { source dest type options } {
c152eebe 460 global gluefile
461 global wrap_flags
462 global cxx
463 global cxxflags
b710ec85 464 global cxxvtvflags
fd9a63cd 465 global cxxldflags
c152eebe 466 global includes
145d8b5f 467 global STATIC_LIBCXXFLAGS
39367567 468 global tool
c152eebe 469
025772b9 470 lappend options "additional_flags=-fno-diagnostics-show-caret -fdiagnostics-color=never"
471
c152eebe 472 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
67549fc2 473 lappend options "libs=${gluefile}"
474 lappend options "ldflags=${wrap_flags}"
c152eebe 475 }
476
477 set cxx_final $cxx
478 set cxxlibglossflags [libgloss_link_flags]
479 set cxx_final [concat $cxx_final $cxxlibglossflags]
145d8b5f 480 set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
c152eebe 481 set cxx_final [concat $cxx_final $cxxflags]
b710ec85 482 set cxx_final [concat $cxx_final $cxxvtvflags]
c152eebe 483 set cxx_final [concat $cxx_final $includes]
d353dc54 484
485 # Flag setting based on type argument.
175d5683 486 if { $type == "executable" } {
d353dc54 487 # Link the support objects into executables.
a0f312e3 488 lappend options "additional_flags=./libtestc++.a $cxxldflags"
d353dc54 489 } else {
490 if { $type == "sharedlib" } {
491 # Don't link in anything.
492 set type "executable"
493 }
175d5683 494 }
c152eebe 495
496 lappend options "compiler=$cxx_final"
0557b60a 497 lappend options "timeout=[timeout_value]"
c152eebe 498
39367567 499 set comp_output [target_compile $source $dest $type $options]
39367567 500
39367567 501 return $comp_output
c152eebe 502}
503
4f67a81c 504
b9dd4b84 505# Called from libstdc++-dg-test above, but only for "C" compilation.
506# Calls back into system's target_compile to actually do the work.
507proc v3_target_compile_as_c { source dest type options } {
508 global gluefile
509 global wrap_flags
510 global includes
7fc8c877 511 global flags_file
8ae260b8 512 global blddir
af9a450c 513 global cc
6482a45c 514 global cxxflags
145d8b5f 515 global STATIC_LIBCXXFLAGS
39367567 516 global tool
b9dd4b84 517
518 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
519 lappend options "libs=${gluefile}"
520 lappend options "ldflags=${wrap_flags}"
521 }
522
523 set tname [target_info name]
7fc8c877 524 set cc_final $cc
525 set cxxlibglossflags [libgloss_link_flags]
b9dd4b84 526 set cc_final [concat $cc_final $cxxlibglossflags]
145d8b5f 527 set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
6482a45c 528 set cc_final [concat $cc_final $cxxflags]
b9dd4b84 529 set cc_final [concat $cc_final $includes]
9cf9e3f7 530 regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
b9dd4b84 531
7fc8c877 532 # This is needed for "C" tests, as this type of test may need the
533 # C++ includes. And if we're not testing in the build directory,
177d1b75 534 # the includes variable is not likely to include the necessary
535 # info.
7fc8c877 536 if { ![file exists $flags_file] } {
5e3dac22 537 # ??? We need a --print-include-dirs option to GCC, so that
538 # we can avoid these hacks. The heuristics here will not
539 # work with non-standard --with-includedir= options.
177d1b75 540 set version [remote_exec host ${cc} -dumpversion]
61bacda0 541 # Remove the trailing newline from the output.
542 set version [string trimright [lindex $version 1]]
543 set machine [remote_exec host ${cc} -dumpmachine]
544 set machine [string trimright [lindex $machine 1]]
177d1b75 545 set comp_base_dir [remote_exec host ${cc} --print-prog-name=cc1]
546 set comp_base_dir [lindex $comp_base_dir 1]
547 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname $comp_base_dir]]]]]
5e3dac22 548 # For a cross compiler, the header files will be located in a
549 # machine-specific subdirectory.
550 set crossbase "${comp_base_dir}/${machine}/include/c++/${version}"
551 set crosstarget "${crossbase}/${machine}"
552 set cc_final [concat $cc_final "-I$crossbase -I$crosstarget"]
553 # For a native compiler, the header files will be located at
554 # the top level.
7fc8c877 555 set includesbase "${comp_base_dir}/include/c++/${version}"
556 set includestarget "${includesbase}/${machine}"
557 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
8ae260b8 558
857d9b7b 559 set libdir "-L${comp_base_dir}/lib"
8ae260b8 560 } else {
857d9b7b 561 set libdir "-L${blddir}/libsupc++/.libs"
562 set libdir [concat $libdir "-L${blddir}/src/.libs"]
7fc8c877 563 }
564
857d9b7b 565 set cc_final [concat $cc_final "$libdir"]
8ae260b8 566
b9dd4b84 567 lappend options "compiler=$cc_final"
0557b60a 568 lappend options "timeout=[timeout_value]"
b9dd4b84 569
39367567 570 set comp_output [target_compile $source $dest $type $options]
39367567 571
39367567 572 return $comp_output
b9dd4b84 573}
574
175d5683 575# Build the support objects linked in with the libstdc++ tests. In
bcf86f01 576# addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
e57bcbd3 577proc v3-build_support { } {
bf679df8 578 global env
a5e6b236 579 global srcdir
ca1b7575 580 global v3-wchar_t
581 global v3-threads
099c5a78 582 global v3-symver
6eb81ee0 583 global v3-sharedlib
175d5683 584
585 # Figure out whether or not the library supports certain features.
ca1b7575 586 set v3-wchar_t 0
587 set v3-threads 0
099c5a78 588 set v3-symver 0
bcf86f01 589 set libtest_objs ""
175d5683 590
591 set config_src "config.cc"
d560552f 592 set config_out "config.ii"
175d5683 593 set f [open $config_src "w"]
594 puts $f "#include <bits/c++config.h>"
1d171a16 595 puts $f "#include <bits/gthr.h>"
175d5683 596 close $f
d560552f 597 v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
598 set file [open $config_out r]
599 set preprocessed [read $file]
600 close $file
1d171a16 601 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
602 verbose -log "wchar_t support detected"
603 set v3-wchar_t 1
604 }
099c5a78 605 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
606 verbose -log "symbol versioning support detected"
607 set v3-symver 1
608 }
1d171a16 609 if { [string first "__GTHREADS" $preprocessed] != -1 } {
610 verbose -log "thread support detected"
611 set v3-threads 1
175d5683 612 }
a5e6b236 613
1e4fed69 614 # Try to build the MO files that are used by some of the locale
615 # tests. If we can't build them, that's OK; it just means that
616 # those tests will fail.
617 foreach lang [list "fr" "de"] {
618 catch {
619 file mkdir "$lang/LC_MESSAGES"
620 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
621 if [is_remote host] {
622 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
623 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
624 }
625 }
626 }
627
175d5683 628 # Build the support objects.
36fed23c 629 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
630 testsuite_character.cc testsuite_hooks.cc \
2661beb5 631 io/verified_cmd_line_input.cc \
f675bba6 632 io/prog_bar.cc performance/time/elapsed_timer.cc ]
175d5683 633 foreach f $source_files {
36fed23c 634 set obj [file rootname $f].o
635 set object_file [file tail $obj]
4b4caab0 636 # Compile with "-w" so that warnings issued by the compiler
637 # do not prevent compilation.
acb09254 638 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
4b4caab0 639 [list "incdir=$srcdir" "additional_flags=-w"]]
175d5683 640 != "" } {
641 error "could not compile $f"
642 }
bcf86f01 643 append libtest_objs "$object_file "
c152eebe 644 }
6eb81ee0 645
36fed23c 646 # Collect into libtestc++.a
f7708e07 647 if [info exists env(AR)] {
648 set ar $env(AR)
bf679df8 649 } else {
650 set ar [transform "ar"]
651 }
d560552f 652 set arargs "-rc ./libtestc++.a ${libtest_objs}"
653 verbose -log "$ar $arargs"
654 set result [lindex [remote_exec host "$ar" "$arargs"] 0]
36fed23c 655 verbose "link result is $result"
656 if { $result == 0 } {
f7708e07 657 if [info exists env(RANLIB)] {
658 set ranlib $env(RANLIB)
bf679df8 659 } else {
660 set ranlib [transform "ranlib"]
661 }
d560552f 662 set ranlibargs "./libtestc++.a"
663 verbose -log "$ranlib $ranlibargs"
664 set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
36fed23c 665 if { $result != 0 } {
666 error "could not link libtestc++.a"
36fed23c 667 }
668 }
669
670 # Build any shared objects needed for regression testing.
6eb81ee0 671 if { ${v3-sharedlib} == 1 } {
36fed23c 672 set source_files [list testsuite_shared.cc]
6eb81ee0 673 foreach f $source_files {
674 set object_file [file rootname $f].so
675 # Compile with "-w" so that warnings issued by the compiler
676 # do not prevent compilation.
acb09254 677 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
a13f5fbe 678 [list "incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC -std=gnu++98"]]
6eb81ee0 679 != "" } {
680 error "could not compile $f"
681 }
682 }
683 }
684}
685
b14642ed 686proc check_v3_target_fileio { } {
687 global et_fileio_saved
688 global et_fileio_target_name
689 global tool
a34ea04a 690 global srcdir
b14642ed 691
692 if { ![info exists et_fileio_target_name] } {
693 set et_fileio_target_name ""
694 }
695
696 # If the target has changed since we set the cached value, clear it.
697 set current_target [current_target_name]
698 if { $current_target != $et_fileio_target_name } {
699 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
700 set et_fileio_target_name $current_target
701 if [info exists et_fileio_saved] {
702 verbose "check_v3_target_fileio: removing cached result" 2
703 unset et_fileio_saved
704 }
705 }
706
707 if [info exists et_fileio_saved] {
708 verbose "check_v3_target_fileio: using cached result" 2
709 } else {
710 set et_fileio_saved 0
711
712 # Set up, compile, and execute a C++ test program that tries to use
713 # the file functions
714 set src fileio[pid].cc
715 set exe fileio[pid].x
e2b86ae4 716 set testfile "cin_unget-1.[pid].txt"
717 v3-copy-file "$srcdir/data/cin_unget-1.txt" "$testfile"
b14642ed 718
719 set f [open $src "w"]
720 puts $f "#include <sys/types.h>"
721 puts $f "#include <sys/stat.h>"
722 puts $f "#include <fcntl.h>"
723 puts $f "#include <unistd.h>"
724 puts $f "#include <errno.h>"
a34ea04a 725 puts $f "#include <string.h>"
b14642ed 726 puts $f "using namespace std;"
727 puts $f "int main ()"
728 puts $f "{"
a34ea04a 729 puts $f " int fd = open (\"$testfile\", O_RDONLY);"
8b855da1 730 puts $f " int ret = 0;"
a34ea04a 731 puts $f " char buf\[10\];"
b14642ed 732 puts $f " if (fd == -1)"
a34ea04a 733 puts $f " ret = 1;"
b14642ed 734 puts $f " else"
8b855da1 735 puts $f " {"
a34ea04a 736 puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
737 puts $f " ret = 1;"
738 puts $f " errno = 0;"
739 puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
740 puts $f " || read (fd, buf, 4) != 4"
741 puts $f " || memcmp (buf, \"1234\", 4) != 0"
742 puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
743 puts $f " || read (fd, buf, 2) != 2"
744 puts $f " || memcmp (buf, \"34\", 2) != 0)"
8b855da1 745 puts $f " ret = 1;"
b14642ed 746 puts $f " close (fd);"
8b855da1 747 puts $f " }"
748 puts $f " return ret;"
b14642ed 749 puts $f "}"
750 close $f
751
752 set lines [v3_target_compile $src $exe executable ""]
753 file delete $src
754
755 if [string match "" $lines] {
756 # No error message, compilation succeeded.
757 set result [${tool}_load "./$exe" "" ""]
758 set status [lindex $result 0]
759 remote_file build delete $exe
760
761 verbose "check_v3_target_fileio: status is <$status>" 2
762
763 if { $status == "pass" } {
764 set et_fileio_saved 1
765 }
766 } else {
767 verbose "check_v3_target_fileio: compilation failed" 2
768 }
769 }
770 return $et_fileio_saved
771}
772
d2e0944d 773# Eventually we want C90/C99 determining and switching from this.
b34f60ac 774proc check_v3_target_c_std { } {
775 global et_c_std_saved
776 global et_c_std_target_name
777 global tool
778
779 if { ![info exists et_c_std_target_name] } {
780 set et_c_std_target_name ""
781 }
782
783 # If the target has changed since we set the cached value, clear it.
784 set current_target [current_target_name]
785 if { $current_target != $et_c_std_target_name } {
786 verbose "check_v3_target_c_std: `$et_c_std_target_name'" 2
787 set et_c_std_target_name $current_target
788 if [info exists et_c_std_saved] {
789 verbose "check_v3_target_c_std: removing cached result" 2
790 unset et_c_std_saved
791 }
792 }
793
794 if [info exists et_c_std_saved] {
795 verbose "check_v3_target_c_std: using cached result" 2
796 } else {
797 set et_c_std_saved 0
798
799 # Set up, compile, and execute a C++ test program that tries to use
800 # C99 functionality.
d2e0944d 801 # For math bits, could use check_effective_target_c99_math.
b34f60ac 802 set src fileio[pid].cc
803 set exe fileio[pid].x
804
805 set f [open $src "w"]
806 puts $f "#include <tr1/cmath>"
d2e0944d 807 puts $f "#include <cstdlib>"
b34f60ac 808 puts $f "int main ()"
809 puts $f "{"
810 puts $f " float f = 45.55;"
811 puts $f " int i = std::tr1::isnan(f);"
d2e0944d 812 puts $f " "
813 puts $f " using std::wctomb;"
f6837aa8 814 puts $f " return i;"
b34f60ac 815 puts $f "}"
816 close $f
817
818 set lines [v3_target_compile $src $exe executable ""]
819 file delete $src
820
821 if [string match "" $lines] {
822 # No error message, compilation succeeded.
823 set result [${tool}_load "./$exe" "" ""]
824 set status [lindex $result 0]
825 remote_file build delete $exe
826
827 verbose "check_v3_target_c_std: status is <$status>" 2
828
829 if { $status == "pass" } {
830 set et_c_std_saved 1
831 }
832 } else {
833 verbose "check_v3_target_c_std: compilation failed" 2
834 }
835 }
836 return $et_c_std_saved
837}
838
6eb81ee0 839proc check_v3_target_sharedlib { } {
840 global v3-sharedlib
841 return ${v3-sharedlib}
c152eebe 842}
e590fca1 843
b14642ed 844proc check_v3_target_time { } {
845 global et_time_saved
846 global et_time_target_name
847 global tool
848
849 if { ![info exists et_time_target_name] } {
850 set et_time_target_name ""
851 }
852
853 # If the target has changed since we set the cached value, clear it.
854 set current_target [current_target_name]
855 if { $current_target != $et_time_target_name } {
856 verbose "check_v3_target_time: `$et_time_target_name'" 2
857 set et_time_target_name $current_target
858 if [info exists et_time_saved] {
859 verbose "check_v3_target_time: removing cached result" 2
860 unset et_time_saved
861 }
862 }
863
864 if [info exists et_time_saved] {
865 verbose "check_v3_target_time: using cached result" 2
866 } else {
867 set et_time_saved 0
868
869 # Set up and compile a C++ test program that tries to use
870 # the time function
871 set src time[pid].cc
b14642ed 872
873 set f [open $src "w"]
874 puts $f "#include <time.h>"
875 puts $f "using namespace std;"
876 puts $f "int main ()"
877 puts $f "{"
878 puts $f " time (0);"
879 puts $f "}"
880 close $f
881
93ed75e7 882 set lines [v3_target_compile $src /dev/null executable ""]
b14642ed 883 file delete $src
884
885 if [string match "" $lines] {
886 # No error message, compilation succeeded.
887 verbose "check_v3_target_time: compilation succeeded" 2
b14642ed 888 set et_time_saved 1
889 } else {
890 verbose "check_v3_target_time: compilation failed" 2
891 }
892 }
893 return $et_time_saved
894}
895
5beab936 896proc check_v3_target_namedlocale { args } {
897 global et_namedlocale
be803e41 898 global tool
e590fca1 899
5beab936 900 set et_namedlocale 0
901
902 # Set up, compile, and execute a C++ test program that tries to use
903 # the required named locale.
904 set exe nlocale[pid].x
905
906 if ![file exists ./$exe] {
907 set src nlocale[pid].cc
908
909 set f [open $src "w"]
910 puts $f "#include <locale>"
911 puts $f "#include <cstdio>"
be803e41 912 puts $f "#include <cstring>"
913 puts $f "using namespace std;"
914 puts $f "char *transform_locale(const char *name)"
915 puts $f "{"
916 puts $f " char *result = new char\[50\];"
917 puts $f " strcpy(result, name);"
918 puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
919 puts $f " /* fall-through */"
920 puts $f "#else"
921 puts $f " if (strstr(result, \"ISO8859-15\")) {"
922 puts $f " strcat(result, \"@euro\");"
923 puts $f " }"
924 puts $f "#endif"
925 puts $f " return result;"
926 puts $f "}"
5beab936 927 puts $f "int main (int argc, char** argv)"
928 puts $f "{"
8eac3de8 929 puts $f " if (argc < 2)"
930 puts $f " {"
931 puts $f " printf(\"locale support test not supported\\n\");"
932 puts $f " return 1;"
be803e41 933 puts $f " }"
934 puts $f " const char *namedloc = transform_locale(*(argv + 1));"
935 puts $f " try"
5beab936 936 puts $f " {"
be803e41 937 puts $f " locale((const char*)namedloc);"
938 puts $f " delete namedloc;"
5beab936 939 puts $f " return 0;"
940 puts $f " }"
941 puts $f " catch(...)"
942 puts $f " {"
be803e41 943 puts $f " printf(\"locale '%s' not supported\\n\", namedloc);"
944 puts $f " delete namedloc;"
5beab936 945 puts $f " return 1;"
be803e41 946 puts $f " }"
5beab936 947 puts $f "}"
948 close $f
949
950 set lines [v3_target_compile $src $exe executable ""]
dd135461 951 file delete $src
5beab936 952
953 if ![string match "" $lines] {
954 verbose "check_v3_target_namedlocale: compilation failed" 2
955 return $et_namedlocale
956 }
957 # else No error message, compilation succeeded.
958 }
959
960 set result [${tool}_load "./$exe" "$args" ""]
961 set status [lindex $result 0]
962
963 verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
964
965 if { $status == "pass" } {
966 set et_namedlocale 1
967 }
968 return $et_namedlocale
e590fca1 969}
a63dd01b 970
e57bcbd3 971proc check_v3_target_debug_mode { } {
e57bcbd3 972 global et_debug_mode
e57bcbd3 973 global tool
974
975 if { ![info exists et_debug_mode_target_name] } {
976 set et_debug_mode_target_name ""
977 }
978
979 # If the target has changed since we set the cached value, clear it.
980 set current_target [current_target_name]
981 if { $current_target != $et_debug_mode_target_name } {
982 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
983 set et_debug_mode_target_name $current_target
984 if [info exists et_debug_mode] {
985 verbose "check_v3_target_debug_mode: removing cached result" 2
986 unset et_debug_mode
987 }
988 }
989
990 if [info exists et_debug_mode] {
991 verbose "check_v3_target_debug_mode: using cached result" 2
992 } else {
993 set et_debug_mode 0
994
93ed75e7 995 # Set up and preprocess a C++ test program that depends
eaca3c99 996 # on debug mode activated.
e57bcbd3 997 set src debug_mode[pid].cc
e57bcbd3 998
999 set f [open $src "w"]
eaca3c99 1000 puts $f "#ifndef _GLIBCXX_DEBUG"
1001 puts $f "# error No debug mode"
1002 puts $f "#endif"
e57bcbd3 1003 close $f
1004
93ed75e7 1005 set lines [v3_target_compile $src /dev/null preprocess ""]
e57bcbd3 1006 file delete $src
1007
1008 if [string match "" $lines] {
93ed75e7 1009 # No error message, preprocessing succeeded.
e57bcbd3 1010 set et_debug_mode 1
1011 }
1012 }
1013 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
1014 return $et_debug_mode
1015}
6482a45c 1016
839f6471 1017proc check_v3_target_profile_mode { } {
1018 global et_profile_mode
1019 global tool
1020
1021 if { ![info exists et_profile_mode_target_name] } {
1022 set et_profile_mode_target_name ""
1023 }
1024
1025 # If the target has changed since we set the cached value, clear it.
1026 set current_target [current_target_name]
1027 if { $current_target != $et_profile_mode_target_name } {
1028 verbose "check_v3_target_profile_mode: `$et_profile_mode_target_name'" 2
1029 set et_profile_mode_target_name $current_target
1030 if [info exists et_profile_mode] {
1031 verbose "check_v3_target_profile_mode: removing cached result" 2
1032 unset et_profile_mode
1033 }
1034 }
1035
1036 if [info exists et_profile_mode] {
1037 verbose "check_v3_target_profile_mode: using cached result" 2
1038 } else {
1039 set et_profile_mode 0
1040
93ed75e7 1041 # Set up and preprocess a C++ test program that depends
839f6471 1042 # on profile mode activated.
1043 set src profile_mode[pid].cc
839f6471 1044
1045 set f [open $src "w"]
1046 puts $f "#ifndef _GLIBCXX_PROFILE"
1047 puts $f "# error No profile mode"
1048 puts $f "#endif"
839f6471 1049 close $f
1050
93ed75e7 1051 set lines [v3_target_compile $src /dev/null preprocess ""]
839f6471 1052 file delete $src
1053
1054 if [string match "" $lines] {
93ed75e7 1055 # No error message, preprocessing succeeded.
839f6471 1056 set et_profile_mode 1
1057 }
1058 }
1059 verbose "check_v3_target_profile_mode: $et_profile_mode" 2
1060 return $et_profile_mode
1061}
1062
9c3137f6 1063proc check_v3_target_normal_mode { } {
1064 global et_normal_mode
1065 global tool
1066
1067 if { ![info exists et_normal_mode_target_name] } {
1068 set et_normal_mode_target_name ""
1069 }
1070
1071 # If the target has changed since we set the cached value, clear it.
1072 set current_target [current_target_name]
1073 if { $current_target != $et_normal_mode_target_name } {
1074 verbose "check_v3_target_normal_mode: `$et_normal_mode_target_name'" 2
1075 set et_normal_mode_target_name $current_target
1076 if [info exists et_normal_mode] {
1077 verbose "check_v3_target_normal_mode: removing cached result" 2
1078 unset et_normal_mode
1079 }
1080 }
1081
1082 if [info exists et_normal_mode] {
1083 verbose "check_v3_target_normal_mode: using cached result" 2
1084 } else {
1085 set et_normal_mode 0
1086
1087 # Set up and compile a C++ test program that depends
1088 # on normal mode activated.
1089 set src normal_mode[pid].cc
9c3137f6 1090
1091 set f [open $src "w"]
1092 puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE) || defined(_GLIBCXX_PARALLEL)"
1093 puts $f "# error No normal mode"
1094 puts $f "#endif"
9c3137f6 1095 close $f
1096
93ed75e7 1097 set lines [v3_target_compile $src /dev/null preprocess ""]
9c3137f6 1098 file delete $src
1099
1100 if [string match "" $lines] {
1101 # No error message, compilation succeeded.
1102 set et_normal_mode 1
1103 }
1104 }
1105 verbose "check_v3_target_normal_mode: $et_normal_mode" 2
1106 return $et_normal_mode
1107}
1108
6482a45c 1109proc check_v3_target_parallel_mode { } {
1110 global cxxflags
3ec8f42c 1111 global v3-libgomp
6482a45c 1112 global et_parallel_mode
1113
1114 global tool
1115
1116 if { ![info exists et_parallel_mode_target_name] } {
1117 set et_parallel_mode_target_name ""
1118 }
1119
1120 # If the target has changed since we set the cached value, clear it.
1121 set current_target [current_target_name]
1122 if { $current_target != $et_parallel_mode_target_name } {
1123 verbose "check_v3_target_parallel_mode: `$et_parallel_mode_target_name'" 2
1124 set et_parallel_mode_target_name $current_target
1125 if [info exists et_parallel_mode] {
1126 verbose "check_v3_target_parallel_mode: removing cached result" 2
1127 unset et_parallel_mode
1128 }
1129 }
1130
1131 if [info exists et_parallel_mode] {
1132 verbose "check_v3_target_parallel_mode: using cached result" 2
1133 } else {
1134 set et_parallel_mode 0
1135
3ec8f42c 1136 # If 'make check-parallel' is running the test succeeds.
1137 if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
6482a45c 1138 set et_parallel_mode 1
6482a45c 1139 }
1140 }
1141 verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1142 return $et_parallel_mode
1143}
652b2fbd 1144
1145proc check_v3_target_cstdint { } {
1146 global cxxflags
1147 global DEFAULT_CXXFLAGS
1148 global et_cstdint
1149
1150 global tool
1151
1152 if { ![info exists et_cstdint_target_name] } {
1153 set et_cstdint_target_name ""
1154 }
1155
1156 # If the target has changed since we set the cached value, clear it.
1157 set current_target [current_target_name]
1158 if { $current_target != $et_cstdint_target_name } {
1159 verbose "check_v3_target_cstdint: `$et_cstdint_target_name'" 2
1160 set et_cstdint_target_name $current_target
1161 if [info exists et_cstdint] {
1162 verbose "check_v3_target_cstdint: removing cached result" 2
1163 unset et_cstdint
1164 }
1165 }
1166
1167 if [info exists et_cstdint] {
1168 verbose "check_v3_target_cstdint: using cached result" 2
1169 } else {
1170 set et_cstdint 0
1171
93ed75e7 1172 # Set up and preprocess a C++0x test program that depends
652b2fbd 1173 # on the C99 stdint facilities to be available.
1174 set src cstdint[pid].cc
652b2fbd 1175
1176 set f [open $src "w"]
a79add34 1177 puts $f "#include <tr1/cstdint>"
93ed75e7 1178 puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1179 puts $f "# error No C99 stdint"
652b2fbd 1180 puts $f "#endif"
1181 close $f
1182
1183 set cxxflags_saved $cxxflags
a79add34 1184 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
652b2fbd 1185
93ed75e7 1186 set lines [v3_target_compile $src /dev/null preprocess ""]
652b2fbd 1187 set cxxflags $cxxflags_saved
1188 file delete $src
1189
1190 if [string match "" $lines] {
93ed75e7 1191 # No error message, preprocess succeeded.
652b2fbd 1192 set et_cstdint 1
1193 } else {
1194 verbose "check_v3_target_cstdint: compilation failed" 2
1195 }
1196 }
1197 verbose "check_v3_target_cstdint: $et_cstdint" 2
1198 return $et_cstdint
1199}
1e75b4be 1200
80e4c797 1201proc check_v3_target_cmath { } {
9351d214 1202 global cxxflags
1203 global DEFAULT_CXXFLAGS
1204 global et_c99_math
1205
1206 global tool
1207
1208 if { ![info exists et_c99_math_target_name] } {
1209 set et_c99_math_target_name ""
1210 }
1211
1212 # If the target has changed since we set the cached value, clear it.
1213 set current_target [current_target_name]
1214 if { $current_target != $et_c99_math_target_name } {
1215 verbose "check_v3_target_c99_math: `$et_c99_math_target_name'" 2
1216 set et_c99_math_target_name $current_target
1217 if [info exists et_c99_math] {
1218 verbose "check_v3_target_c99_math: removing cached result" 2
1219 unset et_c99_math
1220 }
1221 }
1222
1223 if [info exists et_c99_math] {
1224 verbose "check_v3_target_c99_math: using cached result" 2
1225 } else {
1226 set et_c99_math 0
1227
93ed75e7 1228 # Set up and preprocess a C++0x test program that depends
9351d214 1229 # on the C99 math facilities to be available.
1230 set src c99_math[pid].cc
9351d214 1231
1232 set f [open $src "w"]
1233 puts $f "#include <tr1/cmath>"
93ed75e7 1234 puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1235 puts $f "# error No C99 math"
9351d214 1236 puts $f "#endif"
1237 close $f
1238
1239 set cxxflags_saved $cxxflags
1240 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1241
93ed75e7 1242 set lines [v3_target_compile $src /dev/null preprocess ""]
9351d214 1243 set cxxflags $cxxflags_saved
1244 file delete $src
1245
1246 if [string match "" $lines] {
93ed75e7 1247 # No error message, preprocess succeeded.
9351d214 1248 set et_c99_math 1
1249 } else {
1250 verbose "check_v3_target_c99_math: compilation failed" 2
1251 }
1252 }
1253 verbose "check_v3_target_c99_math: $et_c99_math" 2
1254 return $et_c99_math
1255}
1256
3f188677 1257proc check_v3_target_thread_fence { } {
1258 global cxxflags
1259 global DEFAULT_CXXFLAGS
1260 global et_thread_fence
1261
1262 global tool
1263
1264 if { ![info exists et_thread_fence_target_name] } {
1265 set et_thread_fence_target_name ""
1266 }
1267
1268 # If the target has changed since we set the cached value, clear it.
1269 set current_target [current_target_name]
1270 if { $current_target != $et_thread_fence_target_name } {
1271 verbose "check_v3_target_thread_fence: `$et_thread_fence_target_name'" 2
1272 set et_thread_fence_target_name $current_target
1273 if [info exists et_thread_fence] {
1274 verbose "check_v3_target_thread_fence: removing cached result" 2
1275 unset et_thread_fence
1276 }
1277 }
1278
1279 if [info exists et_thread_fence] {
1280 verbose "check_v3_target_thread_fence: using cached result" 2
1281 } else {
1282 set et_thread_fence 0
1283
1284 # Set up and preprocess a C++11 test program that depends
1285 # on the thread fence to be available.
1286 set src thread_fence[pid].cc
1287
1288 set f [open $src "w"]
1289 puts $f "int main() {"
1290 puts $f "__atomic_thread_fence (__ATOMIC_SEQ_CST);"
1291 puts $f "return 0;"
1292 puts $f "}"
1293 close $f
1294
1295 set cxxflags_saved $cxxflags
1296 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1297
1298 set lines [v3_target_compile $src /dev/null executable ""]
1299 set cxxflags $cxxflags_saved
1300 file delete $src
1301
1302 if [string match "" $lines] {
1303 # No error message, linking succeeded.
1304 set et_thread_fence 1
1305 } else {
1306 verbose "check_v3_target_thread_fence: compilation failed" 2
1307 }
1308 }
1309 verbose "check_v3_target_thread_fence: $et_thread_fence" 2
1310 return $et_thread_fence
1311}
1312
1e75b4be 1313proc check_v3_target_atomic_builtins { } {
1314 global cxxflags
1315 global DEFAULT_CXXFLAGS
9351d214 1316 global et_atomic_builtins
1e75b4be 1317
9351d214 1318 global tool
1e75b4be 1319
1320 if { ![info exists et_atomic_builtins_target_name] } {
1321 set et_atomic_builtins_target_name ""
1322 }
1323
1324 # If the target has changed since we set the cached value, clear it.
1325 set current_target [current_target_name]
1326 if { $current_target != $et_atomic_builtins_target_name } {
1327 verbose "check_v3_target_atomic_builtins: `$et_atomic_builtins_target_name'" 2
1328 set et_atomic_builtins_target_name $current_target
1329 if [info exists et_atomic_builtins] {
1330 verbose "check_v3_target_atomic_builtins: removing cached result" 2
1331 unset et_atomic_builtins
1332 }
1333 }
1334
1335 if [info exists et_atomic_builtins] {
1336 verbose "check_v3_target_atomic_builtins: using cached result" 2
1337 } else {
1338 set et_atomic_builtins 0
1339
8868286e 1340 # Set up and preprocess a C++11 test program that depends
5cee5730 1341 # on the atomic builtin facilities to be available.
1e75b4be 1342 set src atomic_builtins[pid].cc
1e75b4be 1343
1344 set f [open $src "w"]
06bc5cca 1345 puts $f "#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1346 puts $f "# error No atomic bool"
1347 puts $f "#endif"
1348 puts $f "#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1349 puts $f "# error No atomic int"
1e75b4be 1350 puts $f "#endif"
1351 close $f
1352
1353 set cxxflags_saved $cxxflags
8868286e 1354 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1e75b4be 1355
93ed75e7 1356 set lines [v3_target_compile $src /dev/null preprocess ""]
1e75b4be 1357 set cxxflags $cxxflags_saved
1358 file delete $src
1359
1360 if [string match "" $lines] {
93ed75e7 1361 # No error message, preprocess succeeded.
1e75b4be 1362 set et_atomic_builtins 1
1363 } else {
1364 verbose "check_v3_target_atomic_builtins: compilation failed" 2
1365 }
1366 }
1367 verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1368 return $et_atomic_builtins
1369}
5cee5730 1370
1371proc check_v3_target_gthreads { } {
1372 global cxxflags
1373 global DEFAULT_CXXFLAGS
1374 global et_gthreads
1375
1376 global tool
1377
1378 if { ![info exists et_gthreads_target_name] } {
1379 set et_gthreads_target_name ""
1380 }
1381
1382 # If the target has changed since we set the cached value, clear it.
1383 set current_target [current_target_name]
1384 if { $current_target != $et_gthreads_target_name } {
1385 verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1386 set et_gthreads_target_name $current_target
1387 if [info exists et_gthreads] {
1388 verbose "check_v3_target_gthreads: removing cached result" 2
1389 unset et_gthreads
1390 }
1391 }
1392
1393 if [info exists et_gthreads] {
1394 verbose "check_v3_target_gthreads: using cached result" 2
1395 } else {
1396 set et_gthreads 0
1397
93ed75e7 1398 # Set up and preprocess a C++0x test program that depends
5cee5730 1399 # on the gthreads facilities to be available.
1400 set src gthreads[pid].cc
5cee5730 1401
1402 set f [open $src "w"]
1403 puts $f "#include <bits/c++config.h>"
93ed75e7 1404 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1405 puts $f "# error No gthread"
5cee5730 1406 puts $f "#endif"
1407 close $f
1408
1409 set cxxflags_saved $cxxflags
1410 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1411
93ed75e7 1412 set lines [v3_target_compile $src /dev/null preprocess ""]
5cee5730 1413 set cxxflags $cxxflags_saved
1414 file delete $src
1415
1416 if [string match "" $lines] {
93ed75e7 1417 # No error message, preprocessing succeeded.
5cee5730 1418 set et_gthreads 1
1419 } else {
1420 verbose "check_v3_target_gthreads: compilation failed" 2
1421 }
1422 }
1423 verbose "check_v3_target_gthreads: $et_gthreads" 2
1424 return $et_gthreads
1425}
d5be2d8e 1426
7a0b241e 1427proc check_v3_target_gthreads_timed { } {
1428 global cxxflags
1429 global DEFAULT_CXXFLAGS
1430 global et_gthreads_timed
1431
1432 global tool
1433
1434 if { ![info exists et_gthreads_timed_target_name] } {
1435 set et_gthreads_timed_target_name ""
1436 }
1437
1438 # If the target has changed since we set the cached value, clear it.
1439 set current_target [current_target_name]
1440 if { $current_target != $et_gthreads_timed_target_name } {
1441 verbose "check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1442 set et_gthreads_timed_target_name $current_target
1443 if [info exists et_gthreads_timed] {
1444 verbose "check_v3_target_gthreads_timed: removing cached result" 2
1445 unset et_gthreads_timed
1446 }
1447 }
1448
1449 if [info exists et_gthreads_timed] {
1450 verbose "check_v3_target_gthreads_timed: using cached result" 2
1451 } else {
1452 set et_gthreads_timed 0
1453
1454 # Set up and preprocess a C++0x test program that depends
1455 # on the gthreads timed mutex facilities to be available.
1456 set src gthreads_timed[pid].cc
1457
1458 set f [open $src "w"]
1459 puts $f "#include <bits/c++config.h>"
1460 puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1461 puts $f "# error No gthread"
1462 puts $f "#endif"
1463 puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1464 puts $f "# error No gthread timed mutexes"
1465 puts $f "#endif"
1466 close $f
1467
1468 set cxxflags_saved $cxxflags
1469 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1470
1471 set lines [v3_target_compile $src /dev/null preprocess ""]
1472 set cxxflags $cxxflags_saved
1473 file delete $src
1474
1475 if [string match "" $lines] {
1476 # No error message, preprocessing succeeded.
1477 set et_gthreads_timed 1
1478 } else {
1479 verbose "check_v3_target_gthreads_timed: compilation failed" 2
1480 }
1481 }
1482 verbose "check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1483 return $et_gthreads_timed
1484}
1485
1486
a2bb721d 1487proc check_v3_target_sleep { } {
d5be2d8e 1488 global cxxflags
1489 global DEFAULT_CXXFLAGS
a2bb721d 1490 global et_sleep
d5be2d8e 1491
1492 global tool
1493
a2bb721d 1494 if { ![info exists et_sleep_target_name] } {
1495 set et_sleep_target_name ""
d5be2d8e 1496 }
1497
1498 # If the target has changed since we set the cached value, clear it.
1499 set current_target [current_target_name]
a2bb721d 1500 if { $current_target != $et_sleep_target_name } {
1501 verbose "check_v3_target_sleep: `$et_sleep_target_name'" 2
1502 set et_sleep_target_name $current_target
1503 if [info exists et_sleep] {
1504 verbose "check_v3_target_sleep: removing cached result" 2
1505 unset et_sleep
d5be2d8e 1506 }
1507 }
1508
a2bb721d 1509 if [info exists et_sleep] {
1510 verbose "check_v3_target_sleep: using cached result" 2
d5be2d8e 1511 } else {
a2bb721d 1512 set et_sleep 0
d5be2d8e 1513
a2bb721d 1514 # Set up and preprocess a C++11 test program that depends
1515 # on the sleep facilities to be available.
1516 set src sleep[pid].cc
d5be2d8e 1517
1518 set f [open $src "w"]
1519 puts $f "#include <bits/c++config.h>"
93ed75e7 1520 puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP"
a2bb721d 1521 puts $f "# ifndef _GLIBCXX_HAVE_SLEEP"
1522 puts $f "# error No nanosleep or sleep"
1523 puts $f "# endif"
d5be2d8e 1524 puts $f "#endif"
1525 close $f
1526
1527 set cxxflags_saved $cxxflags
1528 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1529
93ed75e7 1530 set lines [v3_target_compile $src /dev/null preprocess ""]
d5be2d8e 1531 set cxxflags $cxxflags_saved
1532 file delete $src
1533
1534 if [string match "" $lines] {
93ed75e7 1535 # No error message, preprocessing succeeded.
a2bb721d 1536 set et_sleep 1
d5be2d8e 1537 } else {
a2bb721d 1538 verbose "check_v3_target_sleep: compilation failed" 2
d5be2d8e 1539 }
1540 }
a2bb721d 1541 verbose "check_v3_target_sleep: $et_sleep" 2
1542 return $et_sleep
d5be2d8e 1543}
12f258db 1544
99e43922 1545proc check_v3_target_sched_yield { } {
1546 global cxxflags
1547 global DEFAULT_CXXFLAGS
1548 global et_sched_yield
1549
1550 global tool
1551
1552 if { ![info exists et_sched_yield_target_name] } {
1553 set et_sched_yield_target_name ""
1554 }
1555
1556 # If the target has changed since we set the cached value, clear it.
1557 set current_target [current_target_name]
1558 if { $current_target != $et_sched_yield_target_name } {
1559 verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1560 set et_sched_yield_target_name $current_target
1561 if [info exists et_sched_yield] {
1562 verbose "check_v3_target_sched_yield: removing cached result" 2
1563 unset et_sched_yield
1564 }
1565 }
1566
1567 if [info exists et_sched_yield] {
1568 verbose "check_v3_target_sched_yield: using cached result" 2
1569 } else {
1570 set et_sched_yield 0
1571
93ed75e7 1572 # Set up and preprocess a C++0x test program that depends
99e43922 1573 # on the sched_yield facility to be available.
1574 set src sched_yield[pid].cc
99e43922 1575
1576 set f [open $src "w"]
1577 puts $f "#include <bits/c++config.h>"
93ed75e7 1578 puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD"
1579 puts $f "# error No sched yield"
99e43922 1580 puts $f "#endif"
1581 close $f
1582
1583 set cxxflags_saved $cxxflags
1584 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1585
93ed75e7 1586 set lines [v3_target_compile $src /dev/null preprocess ""]
99e43922 1587 set cxxflags $cxxflags_saved
1588 file delete $src
1589
1590 if [string match "" $lines] {
93ed75e7 1591 # No error message, preprocessing succeeded.
99e43922 1592 set et_sched_yield 1
1593 } else {
1594 verbose "check_v3_target_sched_yield: compilation failed" 2
1595 }
1596 }
1597 verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1598 return $et_sched_yield
1599}
1600
12f258db 1601proc check_v3_target_string_conversions { } {
1602 global cxxflags
1603 global DEFAULT_CXXFLAGS
1604 global et_string_conversions
1605
1606 global tool
1607
1608 if { ![info exists et_string_conversions_target_name] } {
1609 set et_string_conversions_target_name ""
1610 }
1611
1612 # If the target has changed since we set the cached value, clear it.
1613 set current_target [current_target_name]
1614 if { $current_target != $et_string_conversions_target_name } {
1615 verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1616 set et_string_conversions_target_name $current_target
1617 if [info exists et_string_conversions] {
1618 verbose "check_v3_target_string_conversions: removing cached result" 2
1619 unset et_string_conversions
1620 }
1621 }
1622
1623 if [info exists et_string_conversions] {
1624 verbose "check_v3_target_string_conversions: using cached result" 2
1625 } else {
1626 set et_string_conversions 0
1627
93ed75e7 1628 # Set up and preprocess a C++0x test program that depends
12f258db 1629 # on the string_conversions facilities to be available.
1630 set src string_conversions[pid].cc
12f258db 1631
1632 set f [open $src "w"]
1633 puts $f "#include <bits/c++config.h>"
bdb62e6a 1634 puts $f "#if !(_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB && _GLIBCXX_USE_C99_WCHAR) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
93ed75e7 1635 puts $f "# error No string conversions"
12f258db 1636 puts $f "#endif"
1637 close $f
1638
1639 set cxxflags_saved $cxxflags
1640 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1641
93ed75e7 1642 set lines [v3_target_compile $src /dev/null preprocess ""]
12f258db 1643 set cxxflags $cxxflags_saved
1644 file delete $src
1645
1646 if [string match "" $lines] {
93ed75e7 1647 # No error message, preprocessing succeeded.
12f258db 1648 set et_string_conversions 1
1649 } else {
1650 verbose "check_v3_target_string_conversions: compilation failed" 2
1651 }
1652 }
1653 verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1654 return $et_string_conversions
1655}
270aef91 1656
1657proc check_v3_target_swprintf { } {
1658 global cxxflags
1659 global DEFAULT_CXXFLAGS
1660 global et_swprintf
1661
1662 global tool
1663
1664 if { ![info exists et_swprintf_target_name] } {
1665 set et_swprintf_target_name ""
1666 }
1667
1668 # If the target has changed since we set the cached value, clear it.
1669 set current_target [current_target_name]
1670 if { $current_target != $et_swprintf_target_name } {
1671 verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1672 set et_swprintf_target_name $current_target
1673 if [info exists et_swprintf] {
1674 verbose "check_v3_target_swprintf: removing cached result" 2
1675 unset et_swprintf
1676 }
1677 }
1678
1679 if [info exists et_swprintf] {
1680 verbose "check_v3_target_swprintf: using cached result" 2
1681 } else {
1682 set et_swprintf 0
1683
93ed75e7 1684 # Set up and preprocess a C++0x test program that depends
270aef91 1685 # on a standard swprintf function to be available.
1686 set src swprintf[pid].cc
270aef91 1687
1688 set f [open $src "w"]
1689 puts $f "#include <bits/c++config.h>"
93ed75e7 1690 puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1691 puts $f "# error No swprintf"
270aef91 1692 puts $f "#endif"
1693 close $f
1694
1695 set cxxflags_saved $cxxflags
1696 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1697
93ed75e7 1698 set lines [v3_target_compile $src /dev/null preprocess ""]
270aef91 1699 set cxxflags $cxxflags_saved
1700 file delete $src
1701
1702 if [string match "" $lines] {
93ed75e7 1703 # No error message, preprocessing succeeded.
270aef91 1704 set et_swprintf 1
1705 } else {
1706 verbose "check_v3_target_swprintf: compilation failed" 2
1707 }
1708 }
1709 verbose "check_v3_target_swprintf: $et_swprintf" 2
1710 return $et_swprintf
1711}
16f6b489 1712
1713proc check_v3_target_binary_io { } {
1714 global cxxflags
1715 global DEFAULT_CXXFLAGS
1716 global et_binary_io
1717
1718 global tool
1719
1720 if { ![info exists et_binary_io_target_name] } {
1721 set et_binary_io_target_name ""
1722 }
1723
1724 # If the target has changed since we set the cached value, clear it.
1725 set current_target [current_target_name]
1726 if { $current_target != $et_binary_io_target_name } {
1727 verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1728 set et_binary_io_target_name $current_target
1729 if [info exists et_binary_io] {
1730 verbose "check_v3_target_binary_io: removing cached result" 2
1731 unset et_binary_io
1732 }
1733 }
1734
1735 if [info exists et_binary_io] {
1736 verbose "check_v3_target_binary_io: using cached result" 2
1737 } else {
1738 set et_binary_io 0
1739
93ed75e7 1740 # Set up and preprocess a C++0x test program that depends
16f6b489 1741 # on text and binary I/O being the same.
1742 set src binary_io[pid].cc
16f6b489 1743
1744 set f [open $src "w"]
1745 puts $f "#include <bits/c++config.h>"
93ed75e7 1746 puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1747 puts $f "# error No binary io"
16f6b489 1748 puts $f "#endif"
1749 close $f
1750
1751 set cxxflags_saved $cxxflags
1752 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1753
93ed75e7 1754 set lines [v3_target_compile $src /dev/null preprocess ""]
16f6b489 1755 set cxxflags $cxxflags_saved
1756 file delete $src
1757
1758 if [string match "" $lines] {
93ed75e7 1759 # No error message, preprocessing succeeded.
16f6b489 1760 set et_binary_io 1
1761 } else {
1762 verbose "check_v3_target_binary_io: compilation failed" 2
1763 }
1764 }
1765 verbose "check_v3_target_binary_io: $et_binary_io" 2
1766 return $et_binary_io
1767}
e63793af 1768
f4d90d64 1769proc check_v3_target_nprocs { } {
1770 global cxxflags
1771 global DEFAULT_CXXFLAGS
1772 global et_nprocs
1773
1774 global tool
1775
1776 if { ![info exists et_nprocs_target_name] } {
1777 set et_nprocs_target_name ""
1778 }
1779
1780 # If the target has changed since we set the cached value, clear it.
1781 set current_target [current_target_name]
1782 if { $current_target != $et_nprocs_target_name } {
1783 verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1784 set et_nprocs_target_name $current_target
1785 if [info exists et_nprocs] {
1786 verbose "check_v3_target_nprocs: removing cached result" 2
1787 unset et_nprocs
1788 }
1789 }
1790
1791 if [info exists et_nprocs] {
1792 verbose "check_v3_target_nprocs: using cached result" 2
1793 } else {
1794 set et_nprocs 0
1795
1796 # Set up and preprocess a C++0x test program that depends
1797 # on either get_nprocs or sysconf to be available.
1798 set src nprocs[pid].cc
1799
1800 set f [open $src "w"]
1801 puts $f "#include <bits/c++config.h>"
1802 puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
da22c41a 1803 puts $f "#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1804 puts $f "#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1805 puts $f "#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1806 puts $f "#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
f4d90d64 1807 puts $f "#else"
da22c41a 1808 puts $f "# error hardware_concurrency not implemented"
f4d90d64 1809 puts $f "#endif"
1810 close $f
1811
1812 set cxxflags_saved $cxxflags
1813 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1814
1815 set lines [v3_target_compile $src /dev/null preprocess ""]
1816 set cxxflags $cxxflags_saved
1817 file delete $src
1818
1819 if [string match "" $lines] {
1820 # No error message, preprocess succeeded.
1821 set et_nprocs 1
1822 } else {
1823 verbose "check_v3_target_nprocs: compilation failed" 2
1824 }
1825 }
1826 verbose "check_v3_target_nprocs: $et_nprocs" 2
1827 return $et_nprocs
1828}
1829
0cd8cd4b 1830proc check_v3_target_static_libstdcxx { } {
1831 global cxxflags
1832 global DEFAULT_CXXFLAGS
1833 global et_static_libstdcxx
1834
1835 global tool
1836
1837 if [info exists et_static_libstdcxx] {
1838 verbose "check_v3_target_static_libstdcxx: using cached result" 2
1839 } else {
1840 set et_static_libstdcxx 0
1841
1842 # Set up and link a C++0x test program that depends
1843 # on static linking
1844 set src static-maybe[pid].cc
1845
1846 set f [open $src "w"]
1847 puts $f "#include <iostream>"
1848 puts $f "int main() {"
1849 puts $f "int i(415);"
1850 puts $f "std::cout<< i << std::endl;"
1851 puts $f "return 0; }"
1852 puts $f ""
1853 close $f
1854
1855 set cxxflags_saved $cxxflags
1856 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -static-libstdc++"
1857
1858 set lines [v3_target_compile $src /dev/null executable ""]
1859 set cxxflags $cxxflags_saved
1860 file delete $src
1861
1862 if [string match "" $lines] {
1863 # No error message, link succeeded.
1864 set et_static_libstdcxx 1
1865 } else {
1866 verbose "check_v3_target_static_libstdcxx: compilation failed" 2
1867 }
1868 }
1869 verbose "check_v3_target_static_libstdcxx: $et_static_libstdcxx" 2
1870 return $et_static_libstdcxx
1871}
1872
011ea24c 1873proc check_v3_target_little_endian { } {
1874 global cxxflags
1875 global DEFAULT_CXXFLAGS
1876 global et_little_endian
1877
1878 global tool
1879
1880 if { ![info exists et_little_endian_target_name] } {
1881 set et_little_endian_target_name ""
1882 }
1883
1884 # If the target has changed since we set the cached value, clear it.
1885 set current_target [current_target_name]
1886 if { $current_target != $et_little_endian_target_name } {
1887 verbose "check_v3_target_little_endian: `$et_little_endian_target_name'" 2
1888 set et_little_endian_target_name $current_target
1889 if [info exists et_little_endian] {
1890 verbose "check_v3_target_little_endian: removing cached result" 2
1891 unset et_little_endian
1892 }
1893 }
1894
1895 if [info exists et_little_endian] {
1896 verbose "check_v3_target_little_endian: using cached result" 2
1897 } else {
1898 set et_little_endian 0
1899
1900 set src little_endian[pid].cc
0cd8cd4b 1901
011ea24c 1902 set f [open $src "w"]
1903 puts $f "#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__"
1904 puts $f "# error Not little endian"
1905 puts $f "#endif"
1906 close $f
1907
1908 set cxxflags_saved $cxxflags
1909 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1910
1911 set lines [v3_target_compile $src /dev/null preprocess ""]
1912 set cxxflags $cxxflags_saved
1913 file delete $src
1914
1915 if [string match "" $lines] {
1916 # No error message, preprocessing succeeded.
1917 set et_little_endian 1
1918 } else {
1919 verbose "check_v3_target_little_endian: compilation failed" 2
1920 }
1921 }
1922 verbose "check_v3_target_little_endian: $et_little_endian" 2
1923 return $et_little_endian
1924}
f4d90d64 1925
5924b28e 1926proc check_v3_target_filesystem_ts { } {
2ec816c5 1927 global cxxflags
1928 global DEFAULT_CXXFLAGS
5924b28e 1929 global et_filesystem_ts
1930 global tool
1931
1932 if { ![info exists et_filesystem_ts_target_name] } {
1933 set et_filesystem_ts_target_name ""
1934 }
1935
1936 # If the target has changed since we set the cached value, clear it.
1937 set current_target [current_target_name]
1938 if { $current_target != $et_filesystem_ts_target_name } {
1939 verbose "check_v3_target_filesystem_ts: `$et_filesystem_ts_target_name'" 2
1940 set et_filesystem_ts_target_name $current_target
1941 if [info exists et_filesystem_ts] {
1942 verbose "check_v3_target_filesystem_ts: removing cached result" 2
1943 unset et_filesystem_ts
1944 }
1945 }
1946
1947 if [info exists et_filesystem_ts] {
1948 verbose "check_v3_target_filesystem_ts: using cached result" 2
1949 } else {
1950 set et_filesystem_ts 0
1951
1952 # Set up and preprocess a C++ test program that depends
1953 # on debug mode activated.
1954 set src filesystem_ts[pid].cc
1955
1956 set f [open $src "w"]
1957 puts $f "#include <experimental/filesystem>"
1958 puts $f "#if ! __cpp_lib_experimental_filesystem"
1959 puts $f "# error No Filesystem TS support"
1960 puts $f "#endif"
1961 close $f
1962
2ec816c5 1963 set cxxflags_saved $cxxflags
1964 set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11"
1965
5924b28e 1966 set lines [v3_target_compile $src /dev/null preprocess ""]
2ec816c5 1967 set cxxflags $cxxflags_saved
5924b28e 1968 file delete $src
1969
1970 if [string match "" $lines] {
1971 # No error message, preprocessing succeeded.
1972 set et_filesystem_ts 1
1973 }
1974 }
1975 verbose "check_v3_target_filesystem_ts: $et_filesystem_ts" 2
1976 return $et_filesystem_ts
1977}
1978
e63793af 1979set additional_prunes ""
eb9bd3cc 1980
1981if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
1982 && [info procs runtest_file_p] != [list] \
1983 && [info procs gcc_parallelize_saved_runtest_file_p] == [list] } then {
1984 global gcc_runtest_parallelize_counter
1985 global gcc_runtest_parallelize_counter_minor
1986 global gcc_runtest_parallelize_enable
1987 global gcc_runtest_parallelize_dir
1988 global gcc_runtest_parallelize_last
1989
1990 set gcc_runtest_parallelize_counter 0
1991 set gcc_runtest_parallelize_counter_minor 0
1992 set gcc_runtest_parallelize_enable 1
1993 set gcc_runtest_parallelize_dir [getenv GCC_RUNTEST_PARALLELIZE_DIR]
1994 set gcc_runtest_parallelize_last 0
1995
1996 proc gcc_parallel_test_run_p { testcase } {
1997 global gcc_runtest_parallelize_counter
1998 global gcc_runtest_parallelize_counter_minor
1999 global gcc_runtest_parallelize_enable
2000 global gcc_runtest_parallelize_dir
2001 global gcc_runtest_parallelize_last
2002
2003 if { $gcc_runtest_parallelize_enable == 0 } {
2004 return 1
2005 }
2006
2007 # Only test the filesystem every 10th iteration
2008 incr gcc_runtest_parallelize_counter_minor
2009 if { $gcc_runtest_parallelize_counter_minor == 10 } {
2010 set gcc_runtest_parallelize_counter_minor 0
2011 }
2012 if { $gcc_runtest_parallelize_counter_minor != 1 } {
2013 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
2014 return $gcc_runtest_parallelize_last
2015 }
2016
2017 set path $gcc_runtest_parallelize_dir/$gcc_runtest_parallelize_counter
2018
2019 if {![catch {open $path {RDWR CREAT EXCL} 0600} fd]} {
2020 close $fd
2021 set gcc_runtest_parallelize_last 1
2022 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
2023 incr gcc_runtest_parallelize_counter
2024 return 1
2025 }
2026 set gcc_runtest_parallelize_last 0
2027 #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
2028 incr gcc_runtest_parallelize_counter
2029 return 0
2030 }
2031
2032 proc gcc_parallel_test_enable { val } {
2033 global gcc_runtest_parallelize_enable
2034 set gcc_runtest_parallelize_enable $val
2035 }
2036
2037 rename runtest_file_p gcc_parallelize_saved_runtest_file_p
2038 proc runtest_file_p { runtests testcase } {
2039 if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase] {
2040 return 0
2041 }
2042 return [gcc_parallel_test_run_p $testcase]
2043 }
2044
2045} else {
2046
2047 proc gcc_parallel_test_run_p { testcase } {
2048 return 1
2049 }
2050
2051 proc gcc_parallel_test_enable { val } {
2052 }
2053
2054}