]>
Commit | Line | Data |
---|---|---|
c66ce1f5 BK |
1 | # Copyright (C) 2001 Free Software Foundation, Inc. |
2 | ||
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Define libstdc++-v3 callbacks for dg.exp. | |
18 | ||
19 | load_lib dg.exp | |
20 | load_lib libgloss.exp | |
21 | ||
22 | proc libstdc++-v3-init { args } { | |
23 | global srcdir | |
24 | global outdir | |
25 | global blddir | |
26 | global cxx | |
27 | global includes | |
28 | global cxxflags | |
256e7e85 AMT |
29 | global objdir |
30 | global gluefile wrap_flags | |
ec233c75 | 31 | global ld_library_path |
c66ce1f5 BK |
32 | |
33 | set blddir [lookfor_file $outdir libstdc++-v3] | |
28e8acb6 | 34 | |
ec233c75 BK |
35 | # By default, we assume we want to run program images. |
36 | global dg-do-what-default | |
37 | set dg-do-what-default run | |
38 | ||
39 | # Copy any required data files. | |
40 | foreach tst [glob -nocomplain "$srcdir/*/*.tst"] { | |
41 | file copy -force $tst $outdir | |
42 | } | |
43 | foreach txt [glob -nocomplain "$srcdir/*/*.txt"] { | |
44 | file copy -force $txt $outdir | |
45 | } | |
46 | ||
47 | # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found. | |
e944097a | 48 | set gccpath [get_multilibs] |
ec233c75 | 49 | set ld_library_path "." |
e944097a | 50 | append ld_library_path ":${gccpath}../gcc" |
ec233c75 BK |
51 | append ld_library_path ":${blddir}/src/.libs" |
52 | ||
53 | # Do a bunch of handstands and backflips for cross compiling and | |
54 | # finding simulators... | |
28e8acb6 | 55 | if [is_remote host] { |
fe413112 | 56 | set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h] |
28e8acb6 | 57 | if { $header == "" } { |
fe413112 | 58 | verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host." |
28e8acb6 AMT |
59 | return "untested" |
60 | } | |
61 | set cxx [transform "g++"] | |
62 | set cxxflags "-ggdb3 -DDEBUG_ASSERT" | |
63 | set includes "-I./" | |
64 | } else { | |
65 | # If we find a testsuite_flags file, we're testing in the build dir. | |
66 | set flags_file "${blddir}/testsuite_flags" | |
67 | if { [file exists $flags_file] } { | |
68 | set cxx [exec sh $flags_file --build-cxx] | |
69 | set cxxflags [exec sh $flags_file --cxxflags] | |
70 | set includes [exec sh $flags_file --build-includes] | |
71 | } else { | |
72 | set cxx [transform "g++"] | |
73 | set cxxflags "-ggdb3 -DDEBUG_ASSERT" | |
74 | set includes "-I${srcdir}" | |
75 | } | |
76 | } | |
c66ce1f5 | 77 | |
256e7e85 AMT |
78 | if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } { |
79 | set gluefile ${objdir}/testglue.o; | |
80 | set result [build_wrapper $gluefile]; | |
81 | if { $result != "" } { | |
82 | set gluefile [lindex $result 0]; | |
83 | set wrap_flags [lindex $result 1]; | |
84 | } else { | |
85 | unset gluefile | |
86 | } | |
87 | } | |
c66ce1f5 BK |
88 | } |
89 | ||
90 | proc libstdc++-v3-dg-test { prog do_what extra_tool_flags } { | |
91 | # Set up the compiler flags, based on what we're going to do. | |
92 | ||
93 | switch $do_what { | |
94 | "preprocess" { | |
95 | set compile_type "preprocess" | |
96 | set output_file "[file rootname [file tail $prog]].i" | |
97 | } | |
98 | "compile" { | |
99 | set compile_type "assembly" | |
100 | set output_file "[file rootname [file tail $prog]].s" | |
101 | } | |
102 | "assemble" { | |
103 | set compile_type "object" | |
104 | set output_file "[file rootname [file tail $prog]].o" | |
105 | } | |
106 | "link" { | |
107 | set compile_type "executable" | |
256e7e85 | 108 | set output_file "./[file rootname [file tail $prog]]" |
c66ce1f5 BK |
109 | } |
110 | "run" { | |
111 | set compile_type "executable" | |
112 | # FIXME: "./" is to cope with "." not being in $PATH. | |
113 | # Should this be handled elsewhere? | |
114 | # YES. | |
256e7e85 | 115 | set output_file "./[file rootname [file tail $prog]]" |
c66ce1f5 BK |
116 | # This is the only place where we care if an executable was |
117 | # created or not. If it was, dg.exp will try to run it. | |
118 | remote_file build delete $output_file; | |
119 | } | |
120 | default { | |
121 | perror "$do_what: not a valid dg-do keyword" | |
122 | return "" | |
123 | } | |
124 | } | |
125 | set options "" | |
126 | if { $extra_tool_flags != "" } { | |
127 | lappend options "additional_flags=$extra_tool_flags" | |
128 | } | |
129 | ||
130 | set comp_output [libstdc++-v3_target_compile "$prog" "$output_file" "$compile_type" $options]; | |
131 | ||
132 | return [list $comp_output $output_file] | |
133 | } | |
134 | ||
135 | ||
136 | proc libstdc++-v3_target_compile { source dest type options } { | |
137 | global gluefile | |
138 | global wrap_flags | |
139 | global cxx | |
140 | global cxxflags | |
141 | global includes | |
142 | ||
143 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
144 | lappend options "libs=${gluefile}" | |
145 | lappend options "ldflags=${wrap_flags}" | |
146 | } | |
147 | ||
148 | set cxx_final $cxx | |
149 | set cxxlibglossflags [libgloss_link_flags] | |
150 | set cxx_final [concat $cxx_final $cxxlibglossflags] | |
151 | set cxx_final [concat $cxx_final $cxxflags] | |
152 | set cxx_final [concat $cxx_final $includes] | |
c6192d88 | 153 | |
c66ce1f5 BK |
154 | lappend options "compiler=$cxx_final"; |
155 | ||
156 | return [target_compile $source $dest $type $options] | |
157 | } | |
158 | ||
ec233c75 BK |
159 | # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but |
160 | # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH | |
161 | # (for the 64-bit ABI). The right way to do this would be to modify | |
162 | # unix.exp -- but that's not an option since it's part of DejaGNU | |
163 | # proper, so we do it here, by trickery. We really only need to do | |
164 | # this on IRIX, but it shouldn't hurt to do it anywhere else. | |
165 | proc libstdc++-v3_set_ld_library_path { name element op } { | |
166 | setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH] | |
167 | setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH] | |
c66ce1f5 BK |
168 | } |
169 | ||
ec233c75 | 170 | trace variable env(LD_LIBRARY_PATH) w libstdc++-v3_set_ld_library_path |