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