OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [lib/] [libstdc++.exp] - Blame information for rev 424

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.