aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/lib/libstdc++.exp
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/lib/libstdc++.exp')
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp139
1 files changed, 89 insertions, 50 deletions
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 0ac4196b7c3..2f36c7faa55 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -134,27 +134,32 @@ proc libstdc++_init { testfile } {
v3track gccdir 3
# Compute what needs to be added to the existing LD_LIBRARY_PATH.
- set ld_library_path ""
- append ld_library_path ":${gccdir}"
- set compiler ${gccdir}/g++
- if { [is_remote host] == 0 && [which $compiler] != 0 } {
- foreach i "[exec $compiler --print-multi-lib]" {
- set mldir ""
- regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
- set mldir [string trimright $mldir "\;@"]
- if { "$mldir" == "." } {
- continue
- }
- if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
- append ld_library_path ":${gccdir}/${mldir}"
- }
- }
- }
- append ld_library_path ":${blddir}/src/.libs"
+ if {$gccdir != ""} {
+ set ld_library_path ""
+ append ld_library_path ":${gccdir}"
+ set compiler ${gccdir}/g++
+ append ld_library_path ":${blddir}/src/.libs"
+
+ if { [is_remote host] == 0 && [which $compiler] != 0 } {
+ foreach i "[exec $compiler --print-multi-lib]" {
+ set mldir ""
+ regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
+ set mldir [string trimright $mldir "\;@"]
+ if { "$mldir" == "." } {
+ continue
+ }
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+ append ld_library_path ":${gccdir}/${mldir}"
+ }
+ }
+ }
- set_ld_library_path_env_vars
- if [info exists env(LD_LIBRARY_PATH)] {
- verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
+ set_ld_library_path_env_vars
+ if [info exists env(LD_LIBRARY_PATH)] {
+ verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
+ }
+ } else {
+ set compiler [transform "g++"]
}
# Do a bunch of handstands and backflips for cross compiling and
@@ -176,8 +181,16 @@ proc libstdc++_init { testfile } {
set includes [exec sh $flags_file --build-includes]
} else {
set cxx [transform "g++"]
- set cxxflags "-ggdb3"
+ set cxxflags "-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
set includes "-I${srcdir}"
+ # Guess at the location of the installed locale files.
+ # (It would be nice if "gcc --print-file-name" could find
+ # message files, but it cannot.)
+ set absolute_cxx [which $cxx]
+ if { $absolute_cxx != "" } {
+ set localedir "[file dirname $absolute_cxx]/../share/locale"
+ }
+ set cxxflags "$cxxflags -DLOCALEDIR=\"$localedir\""
}
}
@@ -242,6 +255,15 @@ proc libstdc++-dg-test { prog do_what extra_tool_flags } {
return [list $comp_output $output_file]
}
+# True if the library supports wchar_t.
+set v3-wchar_t 0
+
+# True if the library supports threads.
+set v3-threads 0
+
+# A string naming object files to be linked into all tests.
+set v3-test_objs ""
+
# Called from libstdc++-dg-test above. Calls back into system's
# target_compile to actually do the work.
proc v3_target_compile { source dest type options } {
@@ -251,6 +273,7 @@ proc v3_target_compile { source dest type options } {
global cxxflags
global includes
global blddir
+ global v3-test_objs
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
@@ -262,42 +285,58 @@ proc v3_target_compile { source dest type options } {
set cxx_final [concat $cxx_final $cxxlibglossflags]
set cxx_final [concat $cxx_final $cxxflags]
set cxx_final [concat $cxx_final $includes]
+ # Link the support objects into executables.
+ if { $type == "executable" } {
+ set cxx_final [concat $cxx_final ${v3-test_objs}]
+ }
lappend options "compiler=$cxx_final"
- # Picks up the freshly-built testsuite library corresponding to the
- # multilib under test.
- lappend options "ldflags=-L${blddir}/testsuite"
- lappend options "libs=-lv3test"
-
return [target_compile $source $dest $type $options]
}
-
-# Called once, from libstdc++/normal.exp.
-proc v3-list-tests { filename } {
+# Build the support objects linked in with the libstdc++ tests. In
+# addition, set v3-wchar_t, v3-threads, and v3-test_objs
+# appropriately.
+proc v3-build_support {} {
global srcdir
- global blddir
-
- set tests_file "${blddir}/testsuite/${filename}"
- set sfiles ""
-
- verbose -log "In v3-list-tests"
- verbose -log "blddir = ${blddir}"
- verbose -log "tests_file = $tests_file"
+ global v3-wchar_t
+ global v3-threads
+ global v3-test_objs
+
+ # Figure out whether or not the library supports certain features.
+ set v3-wchar_t 0
+ set v3-threads 0
+ set v3-test_objs ""
+
+ set config_src "config.cc"
+ set f [open $config_src "w"]
+ puts $f "#include <bits/c++config.h>"
+ close $f
+ set preprocessed [v3_target_compile $config_src "" \
+ preprocess "additional_flags=-dN"]
+ foreach l $preprocessed {
+ if { [string first "_GLIBCXX_USE_WCHAR_T" $l] != -1 } {
+ verbose -log "wchar_t support detected"
+ set v3-wchar_t 1
+ } elseif { [string first "_GLIBCXX_HAVE_GTHR_DEFAULT" $l] != -1 } {
+ verbose -log "thread support detected"
+ set v3-threads 1
+ }
+ }
- # If there is a testsuite_file, use it.
- if { [file exists $tests_file] } {
- set f [open $tests_file]
- while { ! [eof $f] } {
- set t [gets $f]
- if { [string length "$t"] != 0 } {
- lappend sfiles ${srcdir}/${t}
- }
- }
- close $f
- } else {
- verbose "cannot open $tests_file"
+ # Build the support objects.
+ set source_files \
+ [list testsuite_abi.cc testsuite_allocator.cc testsuite_hooks.cc]
+ foreach f $source_files {
+ set object_file [file rootname $f].o
+ # Compile with "-w" so that warnings issued by the compiler
+ # do not prevent compilation.
+ if { [v3_target_compile $srcdir/$f $object_file "object" \
+ [list "incdir=$srcdir" "additional_flags=-w"]]
+ != "" } {
+ error "could not compile $f"
+ }
+ append v3-test_objs "$object_file "
}
- return $sfiles
}