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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [lib/] [libstdc++.exp] - Blame information for rev 830

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
# libstdc++ "tool init file" for DejaGNU
2
 
3
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4
# 2009, 2010, 2011
5
# Free Software Foundation, Inc.
6
#
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
9
# the Free Software Foundation; either version 3 of the License, or
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
18
# along with this program; see the file COPYING3.  If not see
19
# .
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 scanasm.exp
56
load_gcc_lib target-libpath.exp
57
load_gcc_lib timeout.exp
58
load_gcc_lib timeout-dg.exp
59
load_gcc_lib wrapper.exp
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
}
67
 
68
# Called by v3-init below.  "Static" to this file.
69
proc v3-copy-files {srcfiles} {
70
    foreach f $srcfiles {
71
        if { [catch { set symlink [file readlink $f] } x] } then {
72
            remote_download target $f
73
        } else {
74
            if { [regexp "^/" "$symlink"] } then {
75
                remote_download target $symlink
76
            } else {
77
                set dirname [file dirname $f]
78
                remote_download target $dirname/$symlink
79
            }
80
        }
81
    }
82
}
83
 
84
# Called once, during runtest.exp setup.
85
proc libstdc++_init { testfile } {
86
    global env
87
    global v3-sharedlib v3-libgomp
88
    global srcdir blddir objdir tool_root_dir
89
    global cc cxx cxxflags cxxpchflags cxxldflags
90
    global includes
91
    global gluefile wrap_flags
92
    global ld_library_path
93
    global target_triplet
94
    global flags_file
95
    global tool_timeout
96
    global DEFAULT_CXXFLAGS
97
    global STATIC_LIBCXXFLAGS
98
 
99
    # We set LC_ALL and LANG to C so that we get the same error
100
    # messages as expected.
101
    setenv LC_ALL C
102
    setenv LANG C
103
 
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
 
111
    set blddir [lookfor_file [get_multilibs] libstdc++-v3]
112
    set flags_file "${blddir}/scripts/testsuite_flags"
113
    set shlib_ext [get_shlib_extension]
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.
122
 
123
    if ![info exists DEFAULT_CXXFLAGS] then {
124
        set DEFAULT_CXXFLAGS ""
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
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.
137
    v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
138
    v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
139
 
140
    set ld_library_path_tmp ""
141
 
142
    # Locate libgcc.a so we don't need to account for different values of
143
    # SHLIB_EXT on different platforms
144
    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
145
    if {$gccdir != ""} {
146
        set gccdir [file dirname $gccdir]
147
        append ld_library_path_tmp ":${gccdir}"
148
    }
149
    v3track gccdir 3
150
 
151
    # Locate libgomp. This is only required for parallel mode.
152
    set v3-libgomp 0
153
    set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
154
    if {$libgompdir != ""} {
155
        set v3-libgomp 1
156
        set libgompdir [file dirname $libgompdir]
157
        append ld_library_path_tmp ":${libgompdir}"
158
        verbose -log "libgomp support detected"
159
    }
160
    v3track libgompdir 3
161
 
162
    # Locate libstdc++ shared library. (ie libstdc++.so.)
163
    set v3-sharedlib 0
164
    set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
165
    if {$sharedlibdir != ""} {
166
        if { [string match "*-*-linux*" $target_triplet] && [isnative] } {
167
            set v3-sharedlib 1
168
            verbose -log "shared library support detected"
169
        }
170
    }
171
    v3track v3-sharedlib 3
172
 
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
 
182
    # Compute what needs to be added to the existing LD_LIBRARY_PATH.
183
    if {$gccdir != ""} {
184
        set compiler ${gccdir}/g++
185
        set ld_library_path ${ld_library_path_tmp}
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
 
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++"]
208
    }
209
 
210
    # Set the default timeout for v3 tests.
211
    set tool_timeout 600
212
 
213
    # Default settings.
214
    set cxx [transform "g++"]
215
    set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
216
    set cxxpchflags ""
217
    set cxxldflags ""
218
    set cc [transform "gcc"]
219
    # Locate testsuite_hooks.h and other testsuite headers.
220
    set includes "-I${srcdir}/util"
221
    # Adapt the defaults for special circumstances.
222
    if [is_remote host] {
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" \
228
                          "${srcdir}/util/*.tcc" \
229
                          "${srcdir}/util/*.hpp" \
230
                          "${srcdir}/util/*/*.h" \
231
                          "${srcdir}/util/*/*.cc" \
232
                          "${srcdir}/util/*/*.tcc" \
233
                          "${srcdir}/util/*/*.hpp" \
234
                          "${srcdir}/util/*/*/*.h" \
235
                          "${srcdir}/util/*/*/*.cc" \
236
                          "${srcdir}/util/*/*/*.tcc" \
237
                          "${srcdir}/util/*/*/*.hpp" \
238
                          "${srcdir}/util/*/*/*/*.h" \
239
                          "${srcdir}/util/*/*/*/*.cc" \
240
                          "${srcdir}/util/*/*/*/*.tcc" \
241
                          "${srcdir}/util/*/*/*/*.hpp" \
242
                          "${srcdir}/util/*/*/*/*/*.h" \
243
                          "${srcdir}/util/*/*/*/*/*.cc" \
244
                          "${srcdir}/util/*/*/*/*/*.tcc" \
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"]
251
            # Download the file.
252
            set result [remote_download host $src $dst]
253
            if { $result == "" } {
254
                verbose -log "Unable to download ${srcdir}/${src} to host."
255
                return "untested"
256
            }
257
        }
258
        set includes "-Iutil"
259
    } elseif { [file exists $flags_file] } {
260
        # If we find a testsuite_flags file, we're testing in the build dir.
261
        set cxx [exec sh $flags_file --build-cxx]
262
        set cxxflags [exec sh $flags_file --cxxflags]
263
        set cxxpchflags [exec sh $flags_file --cxxpchflags]
264
        set cxxldflags [exec sh $flags_file --cxxldflags]
265
        set cc [exec sh $flags_file --build-cc]
266
        set includes [exec sh $flags_file --build-includes]
267
    }
268
    append cxxflags " "
269
    append cxxflags [getenv CXXFLAGS]
270
    v3track cxxflags 2
271
 
272
    # Always use MO files built by this test harness.
273
    set cxxflags "$cxxflags -DLOCALEDIR=\".\""
274
    set ccflags "$cxxflags -DLOCALEDIR=\".\""
275
 
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.)
280
    if { $cxxpchflags != "" } {
281
        set src "config[pid].cc"
282
        set f [open $src "w"]
283
        puts $f "int main () {}"
284
        close $f
285
 
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.
289
        set lines [v3_target_compile $src "config[pid].o" object \
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
        }
296
        file delete $src
297
     }
298
    v3track cxxpchflags 2
299
 
300
    global PCH_CXXFLAGS
301
    if ![info exists PCH_CXXFLAGS] then {
302
        set PCH_CXXFLAGS $cxxpchflags
303
        v3track PCH_CXXFLAGS 2
304
    }
305
 
306
    libstdc++_maybe_build_wrapper "${objdir}/testglue.o" "-fexceptions"
307
}
308
 
309
# Callback for cleanup routines.
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
 
319
# Callback from system dg-test.
320
proc libstdc++-dg-test { prog do_what extra_tool_flags } {
321
    # Set up the compiler flags, based on what we're going to do.
322
    switch $do_what {
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.
347
            catch { remote_file build delete $output_file }
348
        }
349
        default {
350
            perror "$do_what: not a valid dg-do keyword"
351
            return ""
352
        }
353
    }
354
 
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.
360
    set select_compile "v3_target_compile"
361
    set options ""
362
    if { $extra_tool_flags != "" } {
363
        verbose -log "extra_tool_flags are:"
364
        verbose -log $extra_tool_flags
365
        if { [string first "-x c" $extra_tool_flags ] != -1 } {
366
            verbose -log "compiling and executing as C, not C++"
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"
370
            set select_compile "v3_target_compile_as_c"
371
        } else {
372
            lappend options "additional_flags=$extra_tool_flags"
373
        }
374
    }
375
 
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.
378
    set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options];
379
 
380
    return [list $comp_output $output_file]
381
}
382
 
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 } {
390
        global additional_prunes
391
        global errorInfo
392
 
393
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
394
            set saved_info $errorInfo
395
            set additional_prunes ""
396
            unset_timeout_vars
397
            error $errmsg $saved_info
398
        }
399
        set additional_prunes ""
400
        unset_timeout_vars
401
    }
402
}
403
 
404
# True if the library supports wchar_t.
405
set v3-wchar_t 0
406
 
407
# True if the library supports threads.
408
set v3-threads 0
409
 
410
# True if the library supports symbol versioning.
411
set v3-symver 0
412
 
413
# Called from libstdc++-dg-test above.  Calls back into system's
414
# target_compile to actually do the work.
415
proc v3_target_compile { source dest type options } {
416
    global gluefile
417
    global wrap_flags
418
    global cxx
419
    global cxxflags
420
    global cxxldflags
421
    global includes
422
    global STATIC_LIBCXXFLAGS
423
 
424
    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
425
        lappend options "libs=${gluefile}"
426
        lappend options "ldflags=${wrap_flags}"
427
    }
428
 
429
    set cxx_final $cxx
430
    set cxxlibglossflags  [libgloss_link_flags]
431
    set cxx_final [concat $cxx_final $cxxlibglossflags]
432
    set cxx_final [concat $cxx_final $STATIC_LIBCXXFLAGS]
433
    set cxx_final [concat $cxx_final $cxxflags]
434
    set cxx_final [concat $cxx_final $includes]
435
 
436
    # Flag setting based on type argument.
437
    if { $type == "executable" } {
438
        # Link the support objects into executables.
439
        lappend options "additional_flags=./libtestc++.a $cxxldflags"
440
    } else {
441
        if { $type == "sharedlib" } {
442
            # Don't link in anything.
443
            set type "executable"
444
        }
445
    }
446
 
447
    lappend options "compiler=$cxx_final"
448
    lappend options "timeout=[timeout_value]"
449
 
450
    return [target_compile $source $dest $type $options]
451
}
452
 
453
 
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
460
    global flags_file
461
    global blddir
462
    global cc
463
    global cxxflags
464
    global STATIC_LIBCXXFLAGS
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]
472
    set cc_final $cc
473
    set cxxlibglossflags [libgloss_link_flags]
474
    set cc_final [concat $cc_final $cxxlibglossflags]
475
    set cc_final [concat $cc_final $STATIC_LIBCXXFLAGS]
476
    set cc_final [concat $cc_final $cxxflags]
477
    set cc_final [concat $cc_final $includes]
478
    regsub -all {\s[-]nostdinc[+][+]} $cc_final "" cc_final
479
 
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,
482
    # the includes variable is not likely to include the necessary
483
    # info.
484
    if { ![file exists $flags_file] } {
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.
488
        set version [remote_exec host ${cc} -dumpversion]
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]]
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]]]]]
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.
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"]
506
 
507
        set libdir "-L${comp_base_dir}/lib"
508
    } else {
509
        set libdir "-L${blddir}/libsupc++/.libs"
510
        set libdir [concat $libdir "-L${blddir}/src/.libs"]
511
    }
512
 
513
    set cc_final [concat $cc_final "$libdir"]
514
 
515
    lappend options "compiler=$cc_final"
516
    lappend options "timeout=[timeout_value]"
517
 
518
    return [target_compile $source $dest $type $options]
519
}
520
 
521
# Build the support objects linked in with the libstdc++ tests.  In
522
# addition, set v3-wchar_t, v3-threads, and v3-symver appropriately.
523
proc v3-build_support { } {
524
    global env
525
    global srcdir
526
    global v3-wchar_t
527
    global v3-threads
528
    global v3-symver
529
    global v3-sharedlib
530
 
531
    # Figure out whether or not the library supports certain features.
532
    set v3-wchar_t 0
533
    set v3-threads 0
534
    set v3-symver 0
535
    set libtest_objs ""
536
 
537
    set config_src "config.cc"
538
    set config_out "config.ii"
539
    set f [open $config_src "w"]
540
    puts $f "#include "
541
    puts $f "#include "
542
    close $f
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
547
    if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
548
        verbose -log "wchar_t support detected"
549
        set v3-wchar_t 1
550
    }
551
    if { [string first "_GLIBCXX_SYMVER" $preprocessed] != -1 } {
552
        verbose -log "symbol versioning support detected"
553
        set v3-symver 1
554
    }
555
    if { [string first "__GTHREADS" $preprocessed] != -1 } {
556
        verbose -log "thread support detected"
557
        set v3-threads 1
558
    }
559
 
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
 
574
    # Build the support objects.
575
    set source_files [list testsuite_abi.cc testsuite_allocator.cc \
576
                          testsuite_character.cc testsuite_hooks.cc \
577
                          io/verified_cmd_line_input.cc \
578
                          io/prog_bar.cc performance/time/elapsed_timer.cc ]
579
    foreach f $source_files {
580
        set obj [file rootname $f].o
581
        set object_file [file tail $obj]
582
        # Compile with "-w" so that warnings issued by the compiler
583
        # do not prevent compilation.
584
        if { [v3_target_compile $srcdir/util/$f $object_file "object" \
585
                  [list "incdir=$srcdir" "additional_flags=-w"]]
586
             != "" } {
587
            error "could not compile $f"
588
        }
589
        append libtest_objs "$object_file "
590
    }
591
 
592
    # Collect into libtestc++.a
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"
602
    if  [info exists env(AR)] {
603
        set ar $env(AR)
604
    } else {
605
        set ar [transform "ar"]
606
    }
607
    set arargs "-rc ./libtestc++.a ${libtest_objs}"
608
    verbose -log "$ar $arargs"
609
    set result [lindex [remote_exec host "$ar" "$arargs"] 0]
610
    verbose "link result is $result"
611
    if { $result == 0 } {
612
        if  [info exists env(RANLIB)] {
613
            set ranlib $env(RANLIB)
614
        } else {
615
            set ranlib [transform "ranlib"]
616
        }
617
        set ranlibargs "./libtestc++.a"
618
        verbose -log "$ranlib $ranlibargs"
619
        set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
620
        if { $result != 0 } {
621
            error "could not link libtestc++.a"
622
        }
623
    }
624
 
625
    # Build any shared objects needed for regression testing.
626
    if { ${v3-sharedlib} == 1 } {
627
        set source_files [list testsuite_shared.cc]
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.
632
            if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \
633
             [list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
634
                 != "" } {
635
                error "could not compile $f"
636
            }
637
        }
638
    }
639
}
640
 
641
proc check_v3_target_fileio { } {
642
    global et_fileio_saved
643
    global et_fileio_target_name
644
    global tool
645
    global srcdir
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
671
        set testfile "cin_unget-1.txt"
672
        v3-copy-files "$srcdir/data/$testfile"
673
 
674
        set f [open $src "w"]
675
        puts $f "#include "
676
        puts $f "#include "
677
        puts $f "#include "
678
        puts $f "#include "
679
        puts $f "#include "
680
        puts $f "#include "
681
        puts $f "using namespace std;"
682
        puts $f "int main ()"
683
        puts $f "{"
684
        puts $f "  int fd  = open (\"$testfile\", O_RDONLY);"
685
        puts $f "  int ret = 0;"
686
        puts $f "  char buf\[10\];"
687
        puts $f "  if (fd == -1)"
688
        puts $f "    ret = 1;"
689
        puts $f "  else"
690
        puts $f "  {"
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)"
700
        puts $f "      ret = 1;"
701
        puts $f "    close (fd);"
702
        puts $f "  }"
703
        puts $f "  return ret;"
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
 
728
# Eventually we want C90/C99 determining and switching from this.
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.
756
        # For math bits, could use check_effective_target_c99_math.
757
        set src fileio[pid].cc
758
        set exe fileio[pid].x
759
 
760
        set f [open $src "w"]
761
        puts $f "#include "
762
        puts $f "#include "
763
        puts $f "int main ()"
764
        puts $f "{"
765
        puts $f "  float f = 45.55;"
766
        puts $f "  int i = std::tr1::isnan(f);"
767
        puts $f "  "
768
        puts $f "  using std::wctomb;"
769
        puts $f "  return i;"
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
 
794
proc check_v3_target_sharedlib { } {
795
    global v3-sharedlib
796
    return ${v3-sharedlib}
797
}
798
 
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
827
 
828
        set f [open $src "w"]
829
        puts $f "#include "
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
 
837
        set lines [v3_target_compile $src /dev/null executable ""]
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
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
 
851
proc check_v3_target_namedlocale { args } {
852
    global et_namedlocale
853
    global tool
854
 
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 "
866
      puts $f "#include "
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 ""]
884
      file delete $src
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
902
}
903
 
904
proc check_v3_target_debug_mode { } {
905
    global et_debug_mode
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
 
928
        # Set up and preprocess a C++ test program that depends
929
        # on debug mode activated.
930
        set src debug_mode[pid].cc
931
 
932
        set f [open $src "w"]
933
        puts $f "#ifndef _GLIBCXX_DEBUG"
934
        puts $f "#  error No debug mode"
935
        puts $f "#endif"
936
        close $f
937
 
938
        set lines [v3_target_compile $src /dev/null preprocess ""]
939
        file delete $src
940
 
941
        if [string match "" $lines] {
942
            # No error message, preprocessing succeeded.
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
}
949
 
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
 
974
        # Set up and preprocess a C++ test program that depends
975
        # on profile mode activated.
976
        set src profile_mode[pid].cc
977
 
978
        set f [open $src "w"]
979
        puts $f "#ifndef _GLIBCXX_PROFILE"
980
        puts $f "#  error No profile mode"
981
        puts $f "#endif"
982
        close $f
983
 
984
        set lines [v3_target_compile $src /dev/null preprocess ""]
985
        file delete $src
986
 
987
        if [string match "" $lines] {
988
            # No error message, preprocessing succeeded.
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
 
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
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"
1028
        close $f
1029
 
1030
        set lines [v3_target_compile $src /dev/null preprocess ""]
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
 
1042
proc check_v3_target_parallel_mode { } {
1043
    global cxxflags
1044
    global v3-libgomp
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
 
1069
        # If 'make check-parallel' is running the test succeeds.
1070
        if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
1071
            set et_parallel_mode 1
1072
        }
1073
    }
1074
    verbose "check_v3_target_parallel_mode: $et_parallel_mode" 2
1075
    return $et_parallel_mode
1076
}
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
 
1105
        # Set up and preprocess a C++0x test program that depends
1106
        # on the C99 stdint facilities to be available.
1107
        set src cstdint[pid].cc
1108
 
1109
        set f [open $src "w"]
1110
        puts $f "#include "
1111
        puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1"
1112
        puts $f "#  error No C99 stdint"
1113
        puts $f "#endif"
1114
        close $f
1115
 
1116
        set cxxflags_saved $cxxflags
1117
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1118
 
1119
        set lines [v3_target_compile $src /dev/null preprocess ""]
1120
        set cxxflags $cxxflags_saved
1121
        file delete $src
1122
 
1123
        if [string match "" $lines] {
1124
            # No error message, preprocess succeeded.
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
}
1133
 
1134
proc check_v3_target_cmath { } {
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
 
1161
        # Set up and preprocess a C++0x test program that depends
1162
        # on the C99 math facilities to be available.
1163
        set src c99_math[pid].cc
1164
 
1165
        set f [open $src "w"]
1166
        puts $f "#include "
1167
        puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1"
1168
        puts $f "#  error No C99 math"
1169
        puts $f "#endif"
1170
        close $f
1171
 
1172
        set cxxflags_saved $cxxflags
1173
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1174
 
1175
        set lines [v3_target_compile $src /dev/null preprocess ""]
1176
        set cxxflags $cxxflags_saved
1177
        file delete $src
1178
 
1179
        if [string match "" $lines] {
1180
            # No error message, preprocess succeeded.
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
 
1190
proc check_v3_target_atomic_builtins { } {
1191
    global cxxflags
1192
    global DEFAULT_CXXFLAGS
1193
    global et_atomic_builtins
1194
 
1195
    global tool
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
 
1217
        # Set up and preprocess a C++0x test program that depends
1218
        # on the atomic builtin facilities to be available.
1219
        set src atomic_builtins[pid].cc
1220
 
1221
        set f [open $src "w"]
1222
        puts $f "#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2"
1223
        puts $f "#  error No atomic bool"
1224
        puts $f "#endif"
1225
        puts $f "#if __GCC_ATOMIC_INT_LOCK_FREE < 2"
1226
        puts $f "#  error No atomic int"
1227
        puts $f "#endif"
1228
        close $f
1229
 
1230
        set cxxflags_saved $cxxflags
1231
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++0x"
1232
 
1233
        set lines [v3_target_compile $src /dev/null preprocess ""]
1234
        set cxxflags $cxxflags_saved
1235
        file delete $src
1236
 
1237
        if [string match "" $lines] {
1238
            # No error message, preprocess succeeded.
1239
            set et_atomic_builtins 1
1240
        } else {
1241
            verbose "check_v3_target_atomic_builtins: compilation failed" 2
1242
        }
1243
    }
1244
    verbose "check_v3_target_atomic_builtins: $et_atomic_builtins" 2
1245
    return $et_atomic_builtins
1246
}
1247
 
1248
proc check_v3_target_gthreads { } {
1249
    global cxxflags
1250
    global DEFAULT_CXXFLAGS
1251
    global et_gthreads
1252
 
1253
    global tool
1254
 
1255
    if { ![info exists et_gthreads_target_name] } {
1256
        set et_gthreads_target_name ""
1257
    }
1258
 
1259
    # If the target has changed since we set the cached value, clear it.
1260
    set current_target [current_target_name]
1261
    if { $current_target != $et_gthreads_target_name } {
1262
        verbose "check_v3_target_gthreads: `$et_gthreads_target_name'" 2
1263
        set et_gthreads_target_name $current_target
1264
        if [info exists et_gthreads] {
1265
            verbose "check_v3_target_gthreads: removing cached result" 2
1266
            unset et_gthreads
1267
        }
1268
    }
1269
 
1270
    if [info exists et_gthreads] {
1271
        verbose "check_v3_target_gthreads: using cached result" 2
1272
    } else {
1273
        set et_gthreads 0
1274
 
1275
        # Set up and preprocess a C++0x test program that depends
1276
        # on the gthreads facilities to be available.
1277
        set src gthreads[pid].cc
1278
 
1279
        set f [open $src "w"]
1280
        puts $f "#include "
1281
        puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1282
        puts $f "#  error No gthread"
1283
        puts $f "#endif"
1284
        close $f
1285
 
1286
        set cxxflags_saved $cxxflags
1287
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1288
 
1289
        set lines [v3_target_compile $src /dev/null preprocess ""]
1290
        set cxxflags $cxxflags_saved
1291
        file delete $src
1292
 
1293
        if [string match "" $lines] {
1294
            # No error message, preprocessing succeeded.
1295
            set et_gthreads 1
1296
        } else {
1297
            verbose "check_v3_target_gthreads: compilation failed" 2
1298
        }
1299
    }
1300
    verbose "check_v3_target_gthreads: $et_gthreads" 2
1301
    return $et_gthreads
1302
}
1303
 
1304
proc check_v3_target_gthreads_timed { } {
1305
    global cxxflags
1306
    global DEFAULT_CXXFLAGS
1307
    global et_gthreads_timed
1308
 
1309
    global tool
1310
 
1311
    if { ![info exists et_gthreads_timed_target_name] } {
1312
        set et_gthreads_timed_target_name ""
1313
    }
1314
 
1315
    # If the target has changed since we set the cached value, clear it.
1316
    set current_target [current_target_name]
1317
    if { $current_target != $et_gthreads_timed_target_name } {
1318
        verbose "check_v3_target_gthreads_timed: `$et_gthreads_timed_target_name'" 2
1319
        set et_gthreads_timed_target_name $current_target
1320
        if [info exists et_gthreads_timed] {
1321
            verbose "check_v3_target_gthreads_timed: removing cached result" 2
1322
            unset et_gthreads_timed
1323
        }
1324
    }
1325
 
1326
    if [info exists et_gthreads_timed] {
1327
        verbose "check_v3_target_gthreads_timed: using cached result" 2
1328
    } else {
1329
        set et_gthreads_timed 0
1330
 
1331
        # Set up and preprocess a C++0x test program that depends
1332
        # on the gthreads timed mutex facilities to be available.
1333
        set src gthreads_timed[pid].cc
1334
 
1335
        set f [open $src "w"]
1336
        puts $f "#include "
1337
        puts $f "#ifndef _GLIBCXX_HAS_GTHREADS"
1338
        puts $f "#  error No gthread"
1339
        puts $f "#endif"
1340
        puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK"
1341
        puts $f "#  error No gthread timed mutexes"
1342
        puts $f "#endif"
1343
        close $f
1344
 
1345
        set cxxflags_saved $cxxflags
1346
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1347
 
1348
        set lines [v3_target_compile $src /dev/null preprocess ""]
1349
        set cxxflags $cxxflags_saved
1350
        file delete $src
1351
 
1352
        if [string match "" $lines] {
1353
            # No error message, preprocessing succeeded.
1354
            set et_gthreads_timed 1
1355
        } else {
1356
            verbose "check_v3_target_gthreads_timed: compilation failed" 2
1357
        }
1358
    }
1359
    verbose "check_v3_target_gthreads_timed: $et_gthreads_timed" 2
1360
    return $et_gthreads_timed
1361
}
1362
 
1363
 
1364
proc check_v3_target_nanosleep { } {
1365
    global cxxflags
1366
    global DEFAULT_CXXFLAGS
1367
    global et_nanosleep
1368
 
1369
    global tool
1370
 
1371
    if { ![info exists et_nanosleep_target_name] } {
1372
        set et_nanosleep_target_name ""
1373
    }
1374
 
1375
    # If the target has changed since we set the cached value, clear it.
1376
    set current_target [current_target_name]
1377
    if { $current_target != $et_nanosleep_target_name } {
1378
        verbose "check_v3_target_nanosleep: `$et_nanosleep_target_name'" 2
1379
        set et_nanosleep_target_name $current_target
1380
        if [info exists et_nanosleep] {
1381
            verbose "check_v3_target_nanosleep: removing cached result" 2
1382
            unset et_nanosleep
1383
        }
1384
    }
1385
 
1386
    if [info exists et_nanosleep] {
1387
        verbose "check_v3_target_nanosleep: using cached result" 2
1388
    } else {
1389
        set et_nanosleep 0
1390
 
1391
        # Set up and preprocess a C++0x test program that depends
1392
        # on the nanosleep facilities to be available.
1393
        set src nanosleep[pid].cc
1394
 
1395
        set f [open $src "w"]
1396
        puts $f "#include "
1397
        puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP"
1398
        puts $f "#  error No nanosleep"
1399
        puts $f "#endif"
1400
        close $f
1401
 
1402
        set cxxflags_saved $cxxflags
1403
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1404
 
1405
        set lines [v3_target_compile $src /dev/null preprocess ""]
1406
        set cxxflags $cxxflags_saved
1407
        file delete $src
1408
 
1409
        if [string match "" $lines] {
1410
            # No error message, preprocessing succeeded.
1411
            set et_nanosleep 1
1412
        } else {
1413
            verbose "check_v3_target_nanosleep: compilation failed" 2
1414
        }
1415
    }
1416
    verbose "check_v3_target_nanosleep: $et_nanosleep" 2
1417
    return $et_nanosleep
1418
}
1419
 
1420
proc check_v3_target_sched_yield { } {
1421
    global cxxflags
1422
    global DEFAULT_CXXFLAGS
1423
    global et_sched_yield
1424
 
1425
    global tool
1426
 
1427
    if { ![info exists et_sched_yield_target_name] } {
1428
        set et_sched_yield_target_name ""
1429
    }
1430
 
1431
    # If the target has changed since we set the cached value, clear it.
1432
    set current_target [current_target_name]
1433
    if { $current_target != $et_sched_yield_target_name } {
1434
        verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
1435
        set et_sched_yield_target_name $current_target
1436
        if [info exists et_sched_yield] {
1437
            verbose "check_v3_target_sched_yield: removing cached result" 2
1438
            unset et_sched_yield
1439
        }
1440
    }
1441
 
1442
    if [info exists et_sched_yield] {
1443
        verbose "check_v3_target_sched_yield: using cached result" 2
1444
    } else {
1445
        set et_sched_yield 0
1446
 
1447
        # Set up and preprocess a C++0x test program that depends
1448
        # on the sched_yield facility to be available.
1449
        set src sched_yield[pid].cc
1450
 
1451
        set f [open $src "w"]
1452
        puts $f "#include "
1453
        puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD"
1454
        puts $f "#  error No sched yield"
1455
        puts $f "#endif"
1456
        close $f
1457
 
1458
        set cxxflags_saved $cxxflags
1459
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1460
 
1461
        set lines [v3_target_compile $src /dev/null preprocess ""]
1462
        set cxxflags $cxxflags_saved
1463
        file delete $src
1464
 
1465
        if [string match "" $lines] {
1466
            # No error message, preprocessing succeeded.
1467
            set et_sched_yield 1
1468
        } else {
1469
            verbose "check_v3_target_sched_yield: compilation failed" 2
1470
        }
1471
    }
1472
    verbose "check_v3_target_sched_yield: $et_sched_yield" 2
1473
    return $et_sched_yield
1474
}
1475
 
1476
proc check_v3_target_string_conversions { } {
1477
    global cxxflags
1478
    global DEFAULT_CXXFLAGS
1479
    global et_string_conversions
1480
 
1481
    global tool
1482
 
1483
    if { ![info exists et_string_conversions_target_name] } {
1484
        set et_string_conversions_target_name ""
1485
    }
1486
 
1487
    # If the target has changed since we set the cached value, clear it.
1488
    set current_target [current_target_name]
1489
    if { $current_target != $et_string_conversions_target_name } {
1490
        verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2
1491
        set et_string_conversions_target_name $current_target
1492
        if [info exists et_string_conversions] {
1493
            verbose "check_v3_target_string_conversions: removing cached result" 2
1494
            unset et_string_conversions
1495
        }
1496
    }
1497
 
1498
    if [info exists et_string_conversions] {
1499
        verbose "check_v3_target_string_conversions: using cached result" 2
1500
    } else {
1501
        set et_string_conversions 0
1502
 
1503
        # Set up and preprocess a C++0x test program that depends
1504
        # on the string_conversions facilities to be available.
1505
        set src string_conversions[pid].cc
1506
 
1507
        set f [open $src "w"]
1508
        puts $f "#include "
1509
        puts $f "#if !defined(_GLIBCXX_USE_C99) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1510
        puts $f "#  error No string conversions"
1511
        puts $f "#endif"
1512
        close $f
1513
 
1514
        set cxxflags_saved $cxxflags
1515
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1516
 
1517
        set lines [v3_target_compile $src /dev/null preprocess ""]
1518
        set cxxflags $cxxflags_saved
1519
        file delete $src
1520
 
1521
        if [string match "" $lines] {
1522
            # No error message, preprocessing succeeded.
1523
            set et_string_conversions 1
1524
        } else {
1525
            verbose "check_v3_target_string_conversions: compilation failed" 2
1526
        }
1527
    }
1528
    verbose "check_v3_target_string_conversions: $et_string_conversions" 2
1529
    return $et_string_conversions
1530
}
1531
 
1532
proc check_v3_target_swprintf { } {
1533
    global cxxflags
1534
    global DEFAULT_CXXFLAGS
1535
    global et_swprintf
1536
 
1537
    global tool
1538
 
1539
    if { ![info exists et_swprintf_target_name] } {
1540
        set et_swprintf_target_name ""
1541
    }
1542
 
1543
    # If the target has changed since we set the cached value, clear it.
1544
    set current_target [current_target_name]
1545
    if { $current_target != $et_swprintf_target_name } {
1546
        verbose "check_v3_target_swprintf: `$et_swprintf_target_name'" 2
1547
        set et_swprintf_target_name $current_target
1548
        if [info exists et_swprintf] {
1549
            verbose "check_v3_target_swprintf: removing cached result" 2
1550
            unset et_swprintf
1551
        }
1552
    }
1553
 
1554
    if [info exists et_swprintf] {
1555
        verbose "check_v3_target_swprintf: using cached result" 2
1556
    } else {
1557
        set et_swprintf 0
1558
 
1559
        # Set up and preprocess a C++0x test program that depends
1560
        # on a standard swprintf function to be available.
1561
        set src swprintf[pid].cc
1562
 
1563
        set f [open $src "w"]
1564
        puts $f "#include "
1565
        puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)"
1566
        puts $f "#  error No swprintf"
1567
        puts $f "#endif"
1568
        close $f
1569
 
1570
        set cxxflags_saved $cxxflags
1571
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1572
 
1573
        set lines [v3_target_compile $src /dev/null preprocess ""]
1574
        set cxxflags $cxxflags_saved
1575
        file delete $src
1576
 
1577
        if [string match "" $lines] {
1578
            # No error message, preprocessing succeeded.
1579
            set et_swprintf 1
1580
        } else {
1581
            verbose "check_v3_target_swprintf: compilation failed" 2
1582
        }
1583
    }
1584
    verbose "check_v3_target_swprintf: $et_swprintf" 2
1585
    return $et_swprintf
1586
}
1587
 
1588
proc check_v3_target_binary_io { } {
1589
    global cxxflags
1590
    global DEFAULT_CXXFLAGS
1591
    global et_binary_io
1592
 
1593
    global tool
1594
 
1595
    if { ![info exists et_binary_io_target_name] } {
1596
        set et_binary_io_target_name ""
1597
    }
1598
 
1599
    # If the target has changed since we set the cached value, clear it.
1600
    set current_target [current_target_name]
1601
    if { $current_target != $et_binary_io_target_name } {
1602
        verbose "check_v3_target_binary_io: `$et_binary_io_target_name'" 2
1603
        set et_binary_io_target_name $current_target
1604
        if [info exists et_binary_io] {
1605
            verbose "check_v3_target_binary_io: removing cached result" 2
1606
            unset et_binary_io
1607
        }
1608
    }
1609
 
1610
    if [info exists et_binary_io] {
1611
        verbose "check_v3_target_binary_io: using cached result" 2
1612
    } else {
1613
        set et_binary_io 0
1614
 
1615
        # Set up and preprocess a C++0x test program that depends
1616
        # on text and binary I/O being the same.
1617
        set src binary_io[pid].cc
1618
 
1619
        set f [open $src "w"]
1620
        puts $f "#include "
1621
        puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)"
1622
        puts $f "#  error No binary io"
1623
        puts $f "#endif"
1624
        close $f
1625
 
1626
        set cxxflags_saved $cxxflags
1627
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1628
 
1629
        set lines [v3_target_compile $src /dev/null preprocess ""]
1630
        set cxxflags $cxxflags_saved
1631
        file delete $src
1632
 
1633
        if [string match "" $lines] {
1634
            # No error message, preprocessing succeeded.
1635
            set et_binary_io 1
1636
        } else {
1637
            verbose "check_v3_target_binary_io: compilation failed" 2
1638
        }
1639
    }
1640
    verbose "check_v3_target_binary_io: $et_binary_io" 2
1641
    return $et_binary_io
1642
}
1643
 
1644
proc check_v3_target_nprocs { } {
1645
    global cxxflags
1646
    global DEFAULT_CXXFLAGS
1647
    global et_nprocs
1648
 
1649
    global tool
1650
 
1651
    if { ![info exists et_nprocs_target_name] } {
1652
        set et_nprocs_target_name ""
1653
    }
1654
 
1655
    # If the target has changed since we set the cached value, clear it.
1656
    set current_target [current_target_name]
1657
    if { $current_target != $et_nprocs_target_name } {
1658
        verbose "check_v3_target_nprocs: `$et_nprocs_target_name'" 2
1659
        set et_nprocs_target_name $current_target
1660
        if [info exists et_nprocs] {
1661
            verbose "check_v3_target_nprocs: removing cached result" 2
1662
            unset et_nprocs
1663
        }
1664
    }
1665
 
1666
    if [info exists et_nprocs] {
1667
        verbose "check_v3_target_nprocs: using cached result" 2
1668
    } else {
1669
        set et_nprocs 0
1670
 
1671
        # Set up and preprocess a C++0x test program that depends
1672
        # on either get_nprocs or sysconf to be available.
1673
        set src nprocs[pid].cc
1674
 
1675
        set f [open $src "w"]
1676
        puts $f "#include "
1677
        puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)"
1678
        puts $f "#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)"
1679
        puts $f "#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)"
1680
        puts $f "#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)"
1681
        puts $f "#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)"
1682
        puts $f "#else"
1683
        puts $f "#  error hardware_concurrency not implemented"
1684
        puts $f "#endif"
1685
        close $f
1686
 
1687
        set cxxflags_saved $cxxflags
1688
        set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
1689
 
1690
        set lines [v3_target_compile $src /dev/null preprocess ""]
1691
        set cxxflags $cxxflags_saved
1692
        file delete $src
1693
 
1694
        if [string match "" $lines] {
1695
            # No error message, preprocess succeeded.
1696
            set et_nprocs 1
1697
        } else {
1698
            verbose "check_v3_target_nprocs: compilation failed" 2
1699
        }
1700
    }
1701
    verbose "check_v3_target_nprocs: $et_nprocs" 2
1702
    return $et_nprocs
1703
}
1704
 
1705
 
1706
set additional_prunes ""

powered by: WebSVN 2.1.0

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