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