]>
Commit | Line | Data |
---|---|---|
7a938933 ILT |
1 | # Copyright (C) 2009 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 3 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 GCC; see the file COPYING3. If not see | |
15 | # <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # | |
18 | # go support library routines | |
19 | # | |
20 | load_lib prune.exp | |
21 | load_lib gcc-defs.exp | |
22 | load_lib target-libpath.exp | |
23 | ||
24 | # | |
25 | # GOC_UNDER_TEST is the compiler under test. | |
26 | # | |
27 | ||
28 | ||
29 | set gpp_compile_options "" | |
30 | ||
31 | ||
32 | # | |
33 | # go_version -- extract and print the version number of the compiler | |
34 | # | |
35 | ||
36 | proc go_version { } { | |
37 | global GOC_UNDER_TEST | |
38 | ||
39 | go_init | |
40 | ||
41 | # ignore any arguments after the command | |
42 | set compiler [lindex $GOC_UNDER_TEST 0] | |
43 | ||
44 | # verify that the compiler exists | |
45 | if { [is_remote host] || [which $compiler] != 0 } then { | |
46 | set tmp [remote_exec host "$compiler -v"] | |
47 | set status [lindex $tmp 0] | |
48 | set output [lindex $tmp 1] | |
49 | regexp " version \[^\n\r\]*" $output version | |
50 | if { $status == 0 && [info exists version] } then { | |
51 | if [is_remote host] { | |
52 | clone_output "$compiler $version\n" | |
53 | } else { | |
54 | clone_output "[which $compiler] $version\n" | |
55 | } | |
56 | } else { | |
57 | clone_output "Couldn't determine version of [which $compiler]\n" | |
58 | } | |
59 | } else { | |
60 | # compiler does not exist (this should have already been detected) | |
61 | warning "$compiler does not exist" | |
62 | } | |
63 | } | |
64 | ||
65 | # | |
66 | # go_include_flags -- include flags for the gcc tree structure | |
67 | # | |
68 | ||
69 | proc go_include_flags { paths } { | |
70 | global srcdir | |
71 | global TESTING_IN_BUILD_TREE | |
72 | ||
73 | set flags "" | |
74 | ||
75 | if { [is_remote host] || ![info exists TESTING_IN_BUILD_TREE] } { | |
76 | return "${flags}" | |
77 | } | |
78 | ||
79 | set gccpath ${paths} | |
80 | ||
81 | if { $gccpath != "" } { | |
82 | if [file exists "${gccpath}/libgo/os.gox"] { | |
83 | append flags "-I${gccpath}/libgo " | |
84 | } | |
85 | } | |
86 | } | |
87 | ||
88 | # | |
89 | # go_link_flags -- linker flags for the gcc tree structure | |
90 | # | |
91 | ||
92 | proc go_link_flags { paths } { | |
93 | global srcdir | |
94 | global ld_library_path | |
95 | global GOC_UNDER_TEST | |
96 | global shlib_ext | |
97 | ||
98 | set gccpath ${paths} | |
99 | set libio_dir "" | |
100 | set flags "" | |
101 | set ld_library_path "." | |
102 | set shlib_ext [get_shlib_extension] | |
103 | verbose "shared lib extension: $shlib_ext" | |
104 | ||
105 | if { $gccpath != "" } { | |
106 | if [file exists "${gccpath}/libgo/libgobegin.a"] { | |
107 | append flags "-L${gccpath}/libgo " | |
108 | } | |
109 | if { [file exists "${gccpath}/libgo/.libs/libgo.a"] \ | |
110 | || [file exists "${gccpath}/libgo/.libs/libgo.${shlib_ext}"] } { | |
111 | append flags "-L${gccpath}/libgo/.libs " | |
112 | append ld_library_path ":${gccpath}/libgo/.libs" | |
113 | } | |
114 | if [file exists "${gccpath}/libiberty/libiberty.a"] { | |
115 | append flags "-L${gccpath}/libiberty " | |
116 | } | |
117 | append ld_library_path \ | |
118 | [gcc-set-multilib-library-path $GOC_UNDER_TEST] | |
119 | } | |
120 | ||
121 | set_ld_library_path_env_vars | |
122 | ||
123 | return "$flags" | |
124 | } | |
125 | ||
126 | # | |
127 | # go_init -- called at the start of each subdir of tests | |
128 | # | |
129 | ||
130 | proc go_init { args } { | |
131 | global subdir | |
132 | global gpp_initialized | |
133 | global base_dir | |
134 | global tmpdir | |
135 | global libdir | |
136 | global gluefile wrap_flags | |
137 | global objdir srcdir | |
138 | global ALWAYS_GOCFLAGS | |
139 | global TOOL_EXECUTABLE TOOL_OPTIONS | |
140 | global GOC_UNDER_TEST | |
141 | global TESTING_IN_BUILD_TREE | |
142 | ||
143 | # We set LC_ALL and LANG to C so that we get the same error messages as expected. | |
144 | setenv LC_ALL C | |
145 | setenv LANG C | |
146 | ||
147 | if ![info exists GOC_UNDER_TEST] then { | |
148 | if [info exists TOOL_EXECUTABLE] { | |
149 | set GOC_UNDER_TEST $TOOL_EXECUTABLE | |
150 | } else { | |
151 | if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } { | |
152 | set GOC_UNDER_TEST [transform gccgo] | |
153 | } else { | |
154 | set GOC_UNDER_TEST [findfile $base_dir/../../gccgo "$base_dir/../../gccgo -B$base_dir/../../" [findfile $base_dir/gccgo "$base_dir/gccgo -B$base_dir/" [transform gccgo]]] | |
155 | } | |
156 | } | |
157 | } | |
158 | ||
159 | if ![is_remote host] { | |
160 | if { [which $GOC_UNDER_TEST] == 0 } then { | |
161 | perror "GOC_UNDER_TEST ($GOC_UNDER_TEST) does not exist" | |
162 | exit 1 | |
163 | } | |
164 | } | |
165 | if ![info exists tmpdir] { | |
166 | set tmpdir "/tmp" | |
167 | } | |
168 | ||
169 | if [info exists gluefile] { | |
170 | unset gluefile | |
171 | } | |
172 | ||
173 | go_maybe_build_wrapper "${tmpdir}/go-testglue.o" | |
174 | ||
175 | set ALWAYS_GOCFLAGS "" | |
176 | ||
177 | if ![is_remote host] { | |
178 | if [info exists TOOL_OPTIONS] { | |
179 | lappend ALWAYS_GOCFLAGS "additional_flags=[go_include_flags [get_multilibs ${TOOL_OPTIONS}] ]" | |
180 | lappend ALWAYS_GOCFLAGS "ldflags=[go_link_flags [get_multilibs ${TOOL_OPTIONS}] ]" | |
181 | } else { | |
182 | lappend ALWAYS_GOCFLAGS "additional_flags=[go_include_flags [get_multilibs] ]" | |
183 | lappend ALWAYS_GOCFLAGS "ldflags=[go_link_flags [get_multilibs] ]" | |
184 | } | |
185 | } | |
186 | ||
187 | if [info exists TOOL_OPTIONS] { | |
188 | lappend ALWAYS_GOCFLAGS "additional_flags=$TOOL_OPTIONS" | |
189 | } | |
190 | ||
191 | verbose -log "ALWAYS_GOCFLAGS set to $ALWAYS_GOCFLAGS" | |
192 | ||
193 | verbose "go is initialized" 3 | |
194 | } | |
195 | ||
196 | # | |
197 | # go_target_compile -- compile a source file | |
198 | # | |
199 | ||
200 | proc go_target_compile { source dest type options } { | |
201 | global tmpdir | |
202 | global gluefile wrap_flags | |
203 | global ALWAYS_GOCFLAGS | |
204 | global GOC_UNDER_TEST | |
205 | ||
206 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
207 | lappend options "libs=${gluefile}" | |
208 | lappend options "ldflags=${wrap_flags}" | |
209 | } | |
210 | ||
211 | lappend options "compiler=$GOC_UNDER_TEST" | |
212 | ||
213 | set options [concat "$ALWAYS_GOCFLAGS" $options] | |
214 | set options [dg-additional-files-options $options $source] | |
215 | return [target_compile $source $dest $type $options] | |
216 | } |