]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/lib/libstdc++.exp
libstdc++.exp (check_v3_target_fileio, [...]): New.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++.exp
1 # libstdc++ "tool init file" for DejaGNU
2
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 # Free Software Foundation, Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 # Define callbacks and load other libraries. This file is loaded relatively
23 # early, and before any other file we write ourselves. "load_lib" will
24 # find anything in the DejaGNU installation tree, or in our lib directory.
25 # "load_gcc_lib" will search the core compiler's .exp collection instead.
26 #
27 # The naming rule is that dg.exp looks for "tool-" and runtest.exp looks
28 # for "tool_" when finding callbacks. Utility routines we define for
29 # our callbacks begin with "v3-".
30 #
31 # libstdc++_* callbacks we don't define, but could:
32 # ..._option_help prints additional --help output
33 # ..._option_proc (--foo) process our own options
34 # ..._init (normal.exp) called once per test file
35 # ..._finish bracketing function for libstdc++_init
36 # ...-dg-prune removing output text, see top of system dg.exp
37 #
38 # Useful hook: if ${hostname}_init exists, it will be called, almost
39 # the last thing before testing begins. This can be defined in, e.g.,
40 # ~/.dejagnurc or $DEJAGNU.
41
42 proc load_gcc_lib { filename } {
43 global srcdir
44 load_file $srcdir/../../gcc/testsuite/lib/$filename
45 }
46
47 # system routines
48 load_lib dg.exp
49 load_lib libgloss.exp
50 # compiler routines, then ours
51 load_gcc_lib target-supports.exp
52 load_gcc_lib target-supports-dg.exp
53 load_lib prune.exp
54 load_lib dg-options.exp
55 load_gcc_lib target-libpath.exp
56 load_gcc_lib wrapper.exp
57
58 # Useful for debugging. Pass the name of a variable and the verbosity
59 # threshold (number of -v's on the command line).
60 proc v3track { var n } {
61 upvar $var val
62 verbose "++ $var is $val" $n
63 }
64
65 # Called by v3-init below. "Static" to this file.
66 proc v3-copy-files {srcfiles} {
67 foreach f $srcfiles {
68 if { [catch { set symlink [file readlink $f] } x] } then {
69 remote_download target $f
70 } else {
71 if { [regexp "^/" "$symlink"] } then {
72 remote_download target $symlink
73 } else {
74 set dirname [file dirname $f]
75 remote_download target $dirname/$symlink
76 }
77 }
78 }
79 }
80
81 # Called once, during runtest.exp setup.
82 proc libstdc++_init { testfile } {
83 global env
84 global v3-sharedlib
85 global srcdir blddir objdir tool_root_dir
86 global cxx cxxflags cxxldflags
87 global includes
88 global gluefile wrap_flags
89 global ld_library_path
90 global target_triplet
91 global flags_file
92
93 # We set LC_ALL and LANG to C so that we get the same error
94 # messages as expected.
95 setenv LC_ALL C
96 setenv LANG C
97
98 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
99 set flags_file "${blddir}/scripts/testsuite_flags"
100 v3track flags_file 2
101
102 # If a test doesn't have special options, use DEFAULT_CXXFLAGS.
103 # Use this variable if the behavior
104 # 1) only applies to libstdc++ testing
105 # 2) might need to be negated
106 # In particular, some tests have to be run without precompiled
107 # headers, or without assertions.
108 global DEFAULT_CXXFLAGS
109 if ![info exists DEFAULT_CXXFLAGS] then {
110 set DEFAULT_CXXFLAGS ""
111 # Host specific goo here.
112 if { [string match "powerpc-*-darwin*" $target_triplet] } {
113 append DEFAULT_CXXFLAGS " -multiply_defined suppress"
114 }
115 }
116 v3track DEFAULT_CXXFLAGS 2
117
118 # By default, we assume we want to run program images.
119 global dg-do-what-default
120 set dg-do-what-default run
121
122 # Copy any required data files.
123 v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
124 v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
125
126 # Locate libgcc.a so we don't need to account for different values of
127 # SHLIB_EXT on different platforms
128 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
129 if {$gccdir != ""} {
130 set gccdir [file dirname $gccdir]
131 }
132 v3track gccdir 3
133
134 # Look for shared library. (ie libstdc++.so.)
135 set v3-sharedlib 0
136 set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so]
137 if {$sharedlibdir != ""} {
138 if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
139 set v3-sharedlib 1
140 verbose -log "shared library support detected"
141 }
142 }
143 v3track v3-sharedlib 3
144
145 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
146 if {$gccdir != ""} {
147 set ld_library_path ""
148 append ld_library_path ":${gccdir}"
149 set compiler ${gccdir}/g++
150 append ld_library_path ":${blddir}/src/.libs"
151
152 if { [is_remote host] == 0 && [which $compiler] != 0 } {
153 foreach i "[exec $compiler --print-multi-lib]" {
154 set mldir ""
155 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
156 set mldir [string trimright $mldir "\;@"]
157 if { "$mldir" == "." } {
158 continue
159 }
160 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
161 append ld_library_path ":${gccdir}/${mldir}"
162 }
163 }
164 }
165
166 set_ld_library_path_env_vars
167 if [info exists env(LD_LIBRARY_PATH)] {
168 verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
169 }
170 } else {
171 set compiler [transform "g++"]
172 }
173
174 # Do a bunch of handstands and backflips for cross compiling and
175 # finding simulators...
176 if [is_remote host] {
177 set header [remote_download host ${blddir}/testsuite/util/testsuite_hooks.h]
178 if { $header == "" } {
179 verbose -log "Unable to download ${blddir}/testsuite/util/testsuite_hooks.h to host."
180 return "untested"
181 }
182 set cxx [transform "g++"]
183 set cxxflags "-ggdb3"
184 set cxxldflags ""
185 set includes "-I./"
186 } else {
187 # If we find a testsuite_flags file, we're testing in the build dir.
188 if { [file exists $flags_file] } {
189 set cxx [exec sh $flags_file --build-cxx]
190 set cxxflags [exec sh $flags_file --cxxflags]
191 set cxxldflags [exec sh $flags_file --cxxldflags]
192 set includes [exec sh $flags_file --build-includes]
193 } else {
194 set cxx [transform "g++"]
195 set cxxldflags ""
196 set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
197 set includes "-I${srcdir}/util"
198 }
199 }
200
201 # Always use MO files built by this test harness.
202 set cxxflags "$cxxflags -DLOCALEDIR=\".\""
203
204 # If a PCH file is available, use it. We must delay performing
205 # this check until $cxx and such have been initialized because we
206 # perform a test compilation. (Ideally, gcc --print-file-name would
207 # list PCH files, but it does not.)
208 global PCH_CXXFLAGS
209 if ![info exists PCH_CXXFLAGS] then {
210 set src "config[pid].cc"
211 set f [open $src "w"]
212 puts $f "int main () {}"
213 close $f
214
215 set lines [v3_target_compile $src "config[pid].o" object \
216 "additional_flags=-include additional_flags=bits/stdtr1c++.h"]
217 if {$lines == "" } {
218 # set PCH_CXXFLAGS "-include bits/extc++.h"
219 # set PCH_CXXFLAGS "-include bits/stdtr1c++.h"
220 set PCH_CXXFLAGS "-include bits/stdc++.h"
221 } else {
222 set PCH_CXXFLAGS ""
223 }
224 file delete $src
225 v3track PCH_CXXFLAGS 2
226 }
227
228 libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
229 }
230
231 # Callback for cleanup routines.
232 proc libstdc++_exit { } {
233 global gluefile;
234
235 if [info exists gluefile] {
236 file_on_build delete $gluefile;
237 unset gluefile;
238 }
239 }
240
241 # Callback from system dg-test.
242 proc libstdc++-dg-test { prog do_what extra_tool_flags } {
243 # Set up the compiler flags, based on what we're going to do.
244 switch $do_what {
245 "preprocess" {
246 set compile_type "preprocess"
247 set output_file "[file rootname [file tail $prog]].i"
248 }
249 "compile" {
250 set compile_type "assembly"
251 set output_file "[file rootname [file tail $prog]].s"
252 }
253 "assemble" {
254 set compile_type "object"
255 set output_file "[file rootname [file tail $prog]].o"
256 }
257 "link" {
258 set compile_type "executable"
259 set output_file "./[file rootname [file tail $prog]].exe"
260 }
261 "run" {
262 set compile_type "executable"
263 # FIXME: "./" is to cope with "." not being in $PATH.
264 # Should this be handled elsewhere?
265 # YES.
266 set output_file "./[file rootname [file tail $prog]].exe"
267 # This is the only place where we care if an executable was
268 # created or not. If it was, dg.exp will try to run it.
269 catch { remote_file build delete $output_file }
270 }
271 default {
272 perror "$do_what: not a valid dg-do keyword"
273 return ""
274 }
275 }
276
277 # Short-circut a bunch of complicated goo here for the special
278 # case of compiling a test file as a "C" file, not as C++. Why? So
279 # -nostdc++ doesn't trip us up. So all the extra object files
280 # don't trip us up. So automatically linking in libstdc++ doesn't
281 # happen. So CXXFLAGS don't error.
282 set select_compile "v3_target_compile"
283 set options ""
284 if { $extra_tool_flags != "" } {
285 verbose -log "extra_tool_flags are:"
286 verbose -log $extra_tool_flags
287 if { [string first "-x c" $extra_tool_flags ] != -1 } {
288 verbose -log "compiling and executing as C, not C++"
289 set edit_tool_flags $extra_tool_flags
290 regsub -all ".x c" $edit_tool_flags "" edit_tool_flags
291 lappend options "additional_flags=$edit_tool_flags"
292 set select_compile "v3_target_compile_as_c"
293 } else {
294 lappend options "additional_flags=$extra_tool_flags"
295 }
296 }
297
298 # There is a libstdc++_compile made for us by default (via the tool-
299 # and-target file), but the defaults are lacking in goodness.
300 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
301 set comp_output [ prune_g++_output $comp_output ];
302
303 return [list $comp_output $output_file]
304 }
305
306 # True if the library supports wchar_t.
307 set v3-wchar_t 0
308
309 # True if the library supports threads.
310 set v3-threads 0
311
312 # True if the library supports symbol versioning.
313 set v3-symver 0
314
315 # Called from libstdc++-dg-test above. Calls back into system's
316 # target_compile to actually do the work.
317 proc v3_target_compile { source dest type options } {
318 global gluefile
319 global wrap_flags
320 global cxx
321 global cxxflags
322 global cxxldflags
323 global includes
324
325 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
326 lappend options "libs=${gluefile}"
327 lappend options "ldflags=${wrap_flags}"
328 }
329
330 set cxx_final $cxx
331 set cxxlibglossflags [libgloss_link_flags]
332 set cxx_final [concat $cxx_final $cxxlibglossflags]
333 set cxx_final [concat $cxx_final $cxxflags]
334 set cxx_final [concat $cxx_final $includes]
335
336 # Flag setting based on type argument.
337 if { $type == "executable" } {
338 # Link the support objects into executables.
339 set cxx_final [concat $cxx_final $cxxldflags]
340 lappend options "additional_flags=./libtestc++.a"
341 } else {
342 if { $type == "sharedlib" } {
343 # Don't link in anything.
344 set type "executable"
345 }
346 }
347
348 lappend options "compiler=$cxx_final"
349 lappend options "timeout=600"
350
351 return [target_compile $source $dest $type $options]
352 }
353
354
355 # Called from libstdc++-dg-test above, but only for "C" compilation.
356 # Calls back into system's target_compile to actually do the work.
357 proc v3_target_compile_as_c { source dest type options } {
358 global gluefile
359 global wrap_flags
360 global includes
361 global flags_file
362 global blddir
363
364 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
365 lappend options "libs=${gluefile}"
366 lappend options "ldflags=${wrap_flags}"
367 }
368
369 set tname [target_info name]
370 set cc [board_info $tname compiler]
371 set cc_final $cc
372 set cxxlibglossflags [libgloss_link_flags]
373 set cc_final [concat $cc_final $cxxlibglossflags]
374 set cc_final [concat $cc_final $includes]
375 regsub -all ".nostdinc.." $cc_final "" cc_final
376
377 # This is needed for "C" tests, as this type of test may need the
378 # C++ includes. And if we're not testing in the build directory,
379 # the includes variable is not likely to include the necessary info.
380 if { ![file exists $flags_file] } {
381 set version [exec ${cc} -dumpversion]
382 set machine [exec ${cc} -dumpmachine]
383 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname [exec ${cc} --print-prog-name=cc1]]]]]]
384 set includesbase "${comp_base_dir}/include/c++/${version}"
385 set includestarget "${includesbase}/${machine}"
386 set cc_final [concat $cc_final "-I$includesbase -I$includestarget"]
387
388 set libsup "${comp_base_dir}/lib"
389 } else {
390 set libsup "${blddir}/libsupc++/.libs"
391 }
392
393 set cc_final [concat $cc_final "-L$libsup"]
394
395 lappend options "compiler=$cc_final"
396 lappend options "timeout=600"
397
398 return [target_compile $source $dest $type $options]
399 }
400
401 # Build the support objects linked in with the libstdc++ tests. In
402 # addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
403 proc v3-build_support { } {
404 global srcdir
405 global v3-wchar_t
406 global v3-threads
407 global v3-symver
408 global v3-sharedlib
409
410 # Figure out whether or not the library supports certain features.
411 set v3-wchar_t 0
412 set v3-threads 0
413 set v3-symver 0
414 set libtest_objs ""
415
416 set config_src "config.cc"
417 set f [open $config_src "w"]
418 puts $f "#include <bits/c++config.h>"
419 puts $f "#include <bits/gthr.h>"
420 close $f
421 set preprocessed [v3_target_compile $config_src "" \
422 preprocess "additional_flags=-dN"]
423 if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
424 verbose -log "wchar_t support detected"
425 set v3-wchar_t 1
426 }
427 if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
428 verbose -log "symbol versioning support detected"
429 set v3-symver 1
430 }
431 if { [string first "__GTHREADS" $preprocessed] != -1 } {
432 verbose -log "thread support detected"
433 set v3-threads 1
434 }
435
436 # Try to build the MO files that are used by some of the locale
437 # tests. If we can't build them, that's OK; it just means that
438 # those tests will fail.
439 foreach lang [list "fr" "de"] {
440 catch {
441 file mkdir "$lang/LC_MESSAGES"
442 remote_exec "build" "msgfmt" "-o $lang/LC_MESSAGES/libstdc++.mo $srcdir/../po/$lang.po"
443 if [is_remote host] {
444 remote_exec "host" "mkdir" "-p $lang/LC_MESSAGES"
445 remote_download "host" "$lang/LC_MESSAGES/libstdc++.mo" "$lang/LC_MESSAGES/libstdc++.mo"
446 }
447 }
448 }
449
450 # Build the support objects.
451 set source_files [list testsuite_abi.cc testsuite_allocator.cc \
452 testsuite_character.cc testsuite_hooks.cc \
453 rng/twister_rand_gen.cc io/verified_cmd_line_input.cc \
454 io/prog_bar.cc performance/time/elapsed_timer.cc ]
455 foreach f $source_files {
456 set obj [file rootname $f].o
457 set object_file [file tail $obj]
458 # Compile with "-w" so that warnings issued by the compiler
459 # do not prevent compilation.
460 if { [v3_target_compile $srcdir/util/$f $object_file "object" \
461 [list "incdir=$srcdir" "additional_flags=-w"]]
462 != "" } {
463 error "could not compile $f"
464 }
465 append libtest_objs "$object_file "
466 }
467
468 # Collect into libtestc++.a
469 set ar [transform "ar"]
470 set arcommand "$ar -rc ./libtestc++.a ${libtest_objs}"
471 set result [lindex [local_exec "$arcommand" "" "" 300] 0]
472 verbose "link result is $result"
473 if { $result == 0 } {
474 set ranlib [transform "ranlib"]
475 set ranlibcommand "$ranlib ./libtestc++.a"
476 set result [lindex [local_exec "$ranlibcommand" "" "" 300] 0]
477 if { $result != 0 } {
478 error "could not link libtestc++.a"
479 }
480 }
481
482 # Build any shared objects needed for regression testing.
483 if { ${v3-sharedlib} == 1 } {
484 set source_files [list testsuite_shared.cc]
485 foreach f $source_files {
486 set object_file [file rootname $f].so
487 # Compile with "-w" so that warnings issued by the compiler
488 # do not prevent compilation.
489 if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
490 [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
491 != "" } {
492 error "could not compile $f"
493 }
494 }
495 }
496 }
497
498 proc check_v3_target_fileio { } {
499 global et_fileio_saved
500 global et_fileio_target_name
501 global tool
502
503 if { ![info exists et_fileio_target_name] } {
504 set et_fileio_target_name ""
505 }
506
507 # If the target has changed since we set the cached value, clear it.
508 set current_target [current_target_name]
509 if { $current_target != $et_fileio_target_name } {
510 verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
511 set et_fileio_target_name $current_target
512 if [info exists et_fileio_saved] {
513 verbose "check_v3_target_fileio: removing cached result" 2
514 unset et_fileio_saved
515 }
516 }
517
518 if [info exists et_fileio_saved] {
519 verbose "check_v3_target_fileio: using cached result" 2
520 } else {
521 set et_fileio_saved 0
522
523 # Set up, compile, and execute a C++ test program that tries to use
524 # the file functions
525 set src fileio[pid].cc
526 set exe fileio[pid].x
527
528 set f [open $src "w"]
529 puts $f "#include <sys/types.h>"
530 puts $f "#include <sys/stat.h>"
531 puts $f "#include <fcntl.h>"
532 puts $f "#include <unistd.h>"
533 puts $f "#include <errno.h>"
534 puts $f "using namespace std;"
535 puts $f "int main ()"
536 puts $f "{"
537 puts $f " int fd = open (\".\", O_RDONLY);"
538 puts $f " if (fd == -1)"
539 puts $f " {"
540 puts $f " int err = errno;"
541 puts $f " if (err == EIO || err == ENOSYS)"
542 puts $f " return 1;"
543 puts $f " }"
544 puts $f " else"
545 puts $f " close (fd);"
546 puts $f " return 0;"
547 puts $f "}"
548 close $f
549
550 set lines [v3_target_compile $src $exe executable ""]
551 file delete $src
552
553 if [string match "" $lines] {
554 # No error message, compilation succeeded.
555 set result [${tool}_load "./$exe" "" ""]
556 set status [lindex $result 0]
557 remote_file build delete $exe
558
559 verbose "check_v3_target_fileio: status is <$status>" 2
560
561 if { $status == "pass" } {
562 set et_fileio_saved 1
563 }
564 } else {
565 verbose "check_v3_target_fileio: compilation failed" 2
566 }
567 }
568 return $et_fileio_saved
569 }
570
571 proc check_v3_target_sharedlib { } {
572 global v3-sharedlib
573 return ${v3-sharedlib}
574 }
575
576 proc check_v3_target_time { } {
577 global et_time_saved
578 global et_time_target_name
579 global tool
580
581 if { ![info exists et_time_target_name] } {
582 set et_time_target_name ""
583 }
584
585 # If the target has changed since we set the cached value, clear it.
586 set current_target [current_target_name]
587 if { $current_target != $et_time_target_name } {
588 verbose "check_v3_target_time: `$et_time_target_name'" 2
589 set et_time_target_name $current_target
590 if [info exists et_time_saved] {
591 verbose "check_v3_target_time: removing cached result" 2
592 unset et_time_saved
593 }
594 }
595
596 if [info exists et_time_saved] {
597 verbose "check_v3_target_time: using cached result" 2
598 } else {
599 set et_time_saved 0
600
601 # Set up and compile a C++ test program that tries to use
602 # the time function
603 set src time[pid].cc
604 set exe time[pid].x
605
606 set f [open $src "w"]
607 puts $f "#include <time.h>"
608 puts $f "using namespace std;"
609 puts $f "int main ()"
610 puts $f "{"
611 puts $f " time (0);"
612 puts $f "}"
613 close $f
614
615 set lines [v3_target_compile $src $exe executable ""]
616 file delete $src
617
618 if [string match "" $lines] {
619 # No error message, compilation succeeded.
620 verbose "check_v3_target_time: compilation succeeded" 2
621 remote_file build delete $exe
622 set et_time_saved 1
623 } else {
624 verbose "check_v3_target_time: compilation failed" 2
625 }
626 }
627 return $et_time_saved
628 }
629
630 proc check_v3_target_namedlocale { } {
631 global et_namedlocale_saved
632 global et_namedlocale_target_name
633 global tool
634
635 if { ![info exists et_namedlocale_target_name] } {
636 set et_namedlocale_target_name ""
637 }
638
639 # If the target has changed since we set the cached value, clear it.
640 set current_target [current_target_name]
641 if { $current_target != $et_namedlocale_target_name } {
642 verbose "check_v3_target_namedlocale: `$et_namedlocale_target_name'" 2
643 set et_namedlocale_target_name $current_target
644 if [info exists et_namedlocale_saved] {
645 verbose "check_v3_target_namedlocale: removing cached result" 2
646 unset et_namedlocale_saved
647 }
648 }
649
650 if [info exists et_namedlocale_saved] {
651 verbose "check_v3_target_namedlocale: using cached result" 2
652 } else {
653 set et_namedlocale_saved 0
654
655 # Set up, compile, and execute a C++ test program that tries to use
656 # all the required named locales.
657 set src nlocale[pid].cc
658 set exe nlocale[pid].x
659
660 set f [open $src "w"]
661 puts $f "#include <locale>"
662 puts $f "using namespace std;"
663 puts $f "int main ()"
664 puts $f "{"
665 puts $f " try"
666 puts $f " {"
667 puts $f " locale(\"\");"
668 puts $f " locale(\"de_DE\");"
669 puts $f " locale(\"de_DE.ISO-8859-15@euro\");"
670 puts $f " locale(\"de_DE@euro\");"
671 puts $f " locale(\"en_HK\");"
672 puts $f " locale(\"en_PH\");"
673 puts $f " locale(\"en_US\");"
674 puts $f " locale(\"en_US.ISO-8859-1\");"
675 puts $f " locale(\"en_US.ISO-8859-15\");"
676 puts $f " locale(\"en_US.UTF-8\");"
677 puts $f " locale(\"es_ES\");"
678 puts $f " locale(\"es_MX\");"
679 puts $f " locale(\"fr_FR\");"
680 puts $f " locale(\"fr_FR@euro\");"
681 puts $f " locale(\"is_IS\");"
682 puts $f " locale(\"is_IS.UTF-8\");"
683 puts $f " locale(\"it_IT\");"
684 puts $f " locale(\"ja_JP.eucjp\");"
685 puts $f " locale(\"se_NO.UTF-8\");"
686 puts $f " locale(\"ta_IN\");"
687 puts $f " locale(\"zh_TW\");"
688 puts $f " return 0;"
689 puts $f " }"
690 puts $f " catch(...)"
691 puts $f " {"
692 puts $f " return 1;"
693 puts $f " }"
694 puts $f "}"
695 close $f
696
697 set lines [v3_target_compile $src $exe executable ""]
698 file delete $src
699
700 if [string match "" $lines] {
701 # No error message, compilation succeeded.
702 set result [${tool}_load "./$exe" "" ""]
703 set status [lindex $result 0]
704 remote_file build delete $exe
705
706 verbose "check_v3_target_namedlocale: status is <$status>" 2
707
708 if { $status == "pass" } {
709 set et_namedlocale_saved 1
710 }
711 } else {
712 verbose "check_v3_target_namedlocale: compilation failed" 2
713 }
714 }
715 return $et_namedlocale_saved
716 }
717
718 proc check_v3_target_debug_mode { } {
719 global cxxflags
720 global et_debug_mode
721
722 global tool
723
724 if { ![info exists et_debug_mode_target_name] } {
725 set et_debug_mode_target_name ""
726 }
727
728 # If the target has changed since we set the cached value, clear it.
729 set current_target [current_target_name]
730 if { $current_target != $et_debug_mode_target_name } {
731 verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2
732 set et_debug_mode_target_name $current_target
733 if [info exists et_debug_mode] {
734 verbose "check_v3_target_debug_mode: removing cached result" 2
735 unset et_debug_mode
736 }
737 }
738
739 if [info exists et_debug_mode] {
740 verbose "check_v3_target_debug_mode: using cached result" 2
741 } else {
742 set et_debug_mode 0
743
744 # Set up, compile, and execute a C++ test program that depends
745 # on debug mode working.
746 set src debug_mode[pid].cc
747 set exe debug_mode[pid].exe
748
749 set f [open $src "w"]
750 puts $f "#include <string>"
751 puts $f "using namespace std;"
752 puts $f "int main()"
753 puts $f "{ return 0; }"
754 close $f
755
756 set cxxflags_saved $cxxflags
757 set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG"
758 set lines [v3_target_compile $src $exe executable ""]
759 set cxxflags $cxxflags_saved
760 file delete $src
761
762 if [string match "" $lines] {
763 # No error message, compilation succeeded.
764 set et_debug_mode 1
765 }
766 }
767 verbose "check_v3_target_debug_mode: $et_debug_mode" 2
768 return $et_debug_mode
769 }