]>
Commit | Line | Data |
---|---|---|
fbd26352 | 1 | # Copyright (C) 2003-2019 Free Software Foundation, Inc. |
4ee9c684 | 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 | |
f63ff66b | 5 | # the Free Software Foundation; either version 3 of the License, or |
4ee9c684 | 6 | # (at your option) any later version. |
903355fc | 7 | # |
4ee9c684 | 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. | |
903355fc | 12 | # |
4ee9c684 | 13 | # You should have received a copy of the GNU General Public License |
f63ff66b | 14 | # along with GCC; see the file COPYING3. If not see |
15 | # <http://www.gnu.org/licenses/>. | |
4ee9c684 | 16 | |
17 | # This file is just 'sed -e 's/77/fortran/g' \ | |
18 | # -e 's/f2c/gfortran' g77.exp > gfortran.exp' | |
19 | # | |
20 | # with some minor modifications to make it work. | |
21 | ||
22 | # | |
23 | # gfortran support library routines | |
24 | # | |
25 | load_lib prune.exp | |
26 | load_lib gcc-defs.exp | |
0557b60a | 27 | load_lib timeout.exp |
c0e31427 | 28 | load_lib target-libpath.exp |
332c3552 | 29 | load_lib target-supports.exp |
4ee9c684 | 30 | |
31 | # | |
32 | # GFORTRAN_UNDER_TEST is the compiler under test. | |
33 | # | |
34 | ||
35 | ||
36 | set gpp_compile_options "" | |
37 | ||
38 | ||
39 | # | |
40 | # gfortran_version -- extract and print the version number of the compiler | |
41 | # | |
42 | ||
43 | proc gfortran_version { } { | |
44 | global GFORTRAN_UNDER_TEST | |
45 | ||
46 | gfortran_init | |
47 | ||
48 | # ignore any arguments after the command | |
49 | set compiler [lindex $GFORTRAN_UNDER_TEST 0] | |
50 | ||
51 | # verify that the compiler exists | |
52 | if { [is_remote host] || [which $compiler] != 0 } then { | |
53 | set tmp [remote_exec host "$compiler -v"] | |
d4213587 | 54 | set status [lindex $tmp 0] |
55 | set output [lindex $tmp 1] | |
da97e61f | 56 | regexp " version \[^\n\r\]*" $output version |
4ee9c684 | 57 | if { $status == 0 && [info exists version] } then { |
58 | if [is_remote host] { | |
59 | clone_output "$compiler $version\n" | |
60 | } else { | |
61 | clone_output "[which $compiler] $version\n" | |
62 | } | |
63 | } else { | |
64 | clone_output "Couldn't determine version of [which $compiler]\n" | |
65 | } | |
66 | } else { | |
67 | # compiler does not exist (this should have already been detected) | |
68 | warning "$compiler does not exist" | |
69 | } | |
70 | } | |
71 | ||
72 | # | |
73 | # gfortran_link_flags -- provide new version of gfortran_link_flags | |
74 | # (originally from libgloss.exp) which knows about the gcc tree structure | |
75 | # | |
76 | ||
77 | proc gfortran_link_flags { paths } { | |
4ee9c684 | 78 | global srcdir |
79 | global ld_library_path | |
80 | global GFORTRAN_UNDER_TEST | |
903355fc | 81 | global shlib_ext |
4ee9c684 | 82 | |
83 | set gccpath ${paths} | |
84 | set libio_dir "" | |
85 | set flags "" | |
f09e0522 | 86 | set ld_library_path "." |
903355fc | 87 | set shlib_ext [get_shlib_extension] |
88 | verbose "shared lib extension: $shlib_ext" | |
4ee9c684 | 89 | |
90 | if { $gccpath != "" } { | |
91 | if [file exists "${gccpath}/libgfortran/.libs/libgfortran.a"] { | |
94cd11b9 | 92 | # Some targets use libgfortran.a%s in their specs, so they need a -B option |
93 | # for uninstalled testing. | |
94 | append flags "-B${gccpath}/libgfortran/.libs " | |
4ee9c684 | 95 | append flags "-L${gccpath}/libgfortran/.libs " |
f09e0522 | 96 | append ld_library_path ":${gccpath}/libgfortran/.libs" |
4ee9c684 | 97 | } |
903355fc | 98 | if [file exists "${gccpath}/libgfortran/.libs/libgfortran.${shlib_ext}"] { |
99 | append flags "-L${gccpath}/libgfortran/.libs " | |
f09e0522 | 100 | append ld_library_path ":${gccpath}/libgfortran/.libs" |
903355fc | 101 | } |
4ee9c684 | 102 | if [file exists "${gccpath}/libgfortran/libgforbegin.a"] { |
103 | append flags "-L${gccpath}/libgfortran " | |
104 | } | |
4fd52b67 | 105 | if [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] { |
106 | append flags "-L${gccpath}/libatomic/.libs " | |
107 | append ld_library_path ":${gccpath}/libatomic/.libs" | |
108 | } | |
109 | if [file exists "${gccpath}/libatomic/libatomic.a"] { | |
110 | append flags "-L${gccpath}/libatomic " | |
111 | } | |
87969c8c | 112 | if [file exists "${gccpath}/libquadmath/.libs/libquadmath.a"] { |
113 | # Some targets use libquadmath.a%s in their specs, so they need a -B option | |
114 | # for uninstalled testing. | |
115 | append flags "-B${gccpath}/libquadmath/.libs " | |
116 | append flags "-L${gccpath}/libquadmath/.libs " | |
117 | append ld_library_path ":${gccpath}/libquadmath/.libs" | |
118 | } | |
119 | if [file exists "${gccpath}/libquadmath/.libs/libquadmath.${shlib_ext}"] { | |
120 | append flags "-L${gccpath}/libquadmath/.libs " | |
121 | append ld_library_path ":${gccpath}/libquadmath/.libs" | |
122 | } | |
4ee9c684 | 123 | if [file exists "${gccpath}/libiberty/libiberty.a"] { |
124 | append flags "-L${gccpath}/libiberty " | |
125 | } | |
f09e0522 | 126 | append ld_library_path \ |
bb508b82 | 127 | [gcc-set-multilib-library-path $GFORTRAN_UNDER_TEST ] |
4ee9c684 | 128 | } |
129 | ||
c0e31427 | 130 | set_ld_library_path_env_vars |
4ee9c684 | 131 | |
132 | return "$flags" | |
133 | } | |
134 | ||
135 | # | |
136 | # gfortran_init -- called at the start of each subdir of tests | |
137 | # | |
138 | ||
139 | proc gfortran_init { args } { | |
140 | global subdir | |
141 | global gpp_initialized | |
142 | global base_dir | |
143 | global tmpdir | |
144 | global libdir | |
d4213587 | 145 | global gluefile wrap_flags |
4ee9c684 | 146 | global objdir srcdir |
147 | global ALWAYS_GFORTRANFLAGS | |
148 | global TOOL_EXECUTABLE TOOL_OPTIONS | |
149 | global GFORTRAN_UNDER_TEST | |
150 | global TESTING_IN_BUILD_TREE | |
fb18f938 | 151 | global gcc_warning_prefix |
152 | global gcc_error_prefix | |
224d9f3d | 153 | global TEST_ALWAYS_FLAGS |
4ee9c684 | 154 | |
e899394f | 155 | # We set LC_ALL and LANG to C so that we get the same error messages as expected. |
156 | setenv LC_ALL C | |
157 | setenv LANG C | |
158 | ||
fb18f938 | 159 | set gcc_warning_prefix "\[Ww\]arning:" |
160 | set gcc_error_prefix "(Fatal )?\[Ee\]rror:" | |
161 | ||
9cf0a538 | 162 | # Many hosts now default to a non-ASCII C locale, however, so |
163 | # they can set a charset encoding here if they need. | |
164 | if { [ishost "*-*-cygwin*"] } { | |
165 | setenv LC_ALL C.ASCII | |
166 | setenv LANG C.ASCII | |
167 | } | |
168 | ||
4ee9c684 | 169 | if ![info exists GFORTRAN_UNDER_TEST] then { |
170 | if [info exists TOOL_EXECUTABLE] { | |
d4213587 | 171 | set GFORTRAN_UNDER_TEST $TOOL_EXECUTABLE |
4ee9c684 | 172 | } else { |
173 | if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } { | |
174 | set GFORTRAN_UNDER_TEST [transform gfortran] | |
175 | } else { | |
87969c8c | 176 | if [info exists TOOL_OPTIONS] { |
177 | set specpath [get_multilibs ${TOOL_OPTIONS}] | |
178 | } else { | |
179 | set specpath [get_multilibs] | |
180 | } | |
bb508b82 | 181 | set GFORTRAN_UNDER_TEST [findfile $base_dir/../../gfortran "$base_dir/../../gfortran -B$base_dir/../../ -B$specpath/libgfortran/" [findfile $base_dir/gfortran "$base_dir/gfortran -B$base_dir/" [transform gfortran]]] |
4ee9c684 | 182 | } |
183 | } | |
184 | } | |
185 | ||
186 | if ![is_remote host] { | |
187 | if { [which $GFORTRAN_UNDER_TEST] == 0 } then { | |
188 | perror "GFORTRAN_UNDER_TEST ($GFORTRAN_UNDER_TEST) does not exist" | |
189 | exit 1 | |
190 | } | |
191 | } | |
192 | if ![info exists tmpdir] { | |
193 | set tmpdir "/tmp" | |
194 | } | |
195 | ||
196 | if [info exists gluefile] { | |
197 | unset gluefile | |
198 | } | |
199 | ||
ac8cb22b | 200 | gfortran_maybe_build_wrapper "${tmpdir}/gfortran-testglue.o" |
4ee9c684 | 201 | |
202 | set ALWAYS_GFORTRANFLAGS "" | |
203 | ||
224d9f3d | 204 | # TEST_ALWAYS_FLAGS are flags that should be passed to every |
205 | # compilation. They are passed first to allow individual | |
206 | # tests to override them. | |
207 | if [info exists TEST_ALWAYS_FLAGS] { | |
208 | lappend ALWAYS_GFORTRANFLAGS "additional_flags=$TEST_ALWAYS_FLAGS" | |
209 | } | |
210 | ||
4ee9c684 | 211 | if ![is_remote host] { |
212 | if [info exists TOOL_OPTIONS] { | |
d4213587 | 213 | lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}] ]" |
4ee9c684 | 214 | } else { |
d4213587 | 215 | lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs] ]" |
4ee9c684 | 216 | } |
217 | } | |
218 | ||
219 | if [info exists TOOL_OPTIONS] { | |
d4213587 | 220 | lappend ALWAYS_GFORTRANFLAGS "additional_flags=$TOOL_OPTIONS" |
4ee9c684 | 221 | } |
222 | ||
332c3552 | 223 | # On the SPU, most of the fortran test cases exceed local store size. |
224 | # Use automatic overlay support to make them fit. | |
225 | if { [check_effective_target_spu_auto_overlay] } { | |
226 | lappend ALWAYS_GFORTRANFLAGS "ldflags=-Wl,--auto-overlay" | |
227 | lappend ALWAYS_GFORTRANFLAGS "ldflags=-Wl,--reserved-space=131072" | |
228 | } | |
229 | ||
4ee9c684 | 230 | verbose -log "ALWAYS_GFORTRANFLAGS set to $ALWAYS_GFORTRANFLAGS" |
231 | ||
232 | verbose "gfortran is initialized" 3 | |
233 | } | |
234 | ||
235 | # | |
236 | # gfortran_target_compile -- compile a source file | |
237 | # | |
238 | ||
239 | proc gfortran_target_compile { source dest type options } { | |
d4213587 | 240 | global tmpdir |
4ee9c684 | 241 | global gluefile wrap_flags |
d4213587 | 242 | global ALWAYS_GFORTRANFLAGS |
243 | global GFORTRAN_UNDER_TEST | |
47583fc8 | 244 | global flags_to_postpone |
245 | global board_info | |
4ee9c684 | 246 | |
247 | if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
248 | lappend options "libs=${gluefile}" | |
249 | lappend options "ldflags=${wrap_flags}" | |
250 | } | |
251 | ||
47583fc8 | 252 | # bind_pic_locally adds -fpie/-fPIE flags to flags_to_postpone and it is |
253 | # appended here to multilib_flags as it can be overridden by the latter | |
254 | # if it was added earlier. After the target_compile, multilib_flags is | |
255 | # restored to its orignal content. | |
256 | set tboard [target_info name] | |
257 | if {[board_info $tboard exists multilib_flags]} { | |
258 | set orig_multilib_flags "[board_info [target_info name] multilib_flags]" | |
259 | append board_info($tboard,multilib_flags) " $flags_to_postpone" | |
260 | } | |
261 | ||
d4213587 | 262 | lappend options "compiler=$GFORTRAN_UNDER_TEST" |
0557b60a | 263 | lappend options "timeout=[timeout_value]" |
4ee9c684 | 264 | |
d4213587 | 265 | set options [concat "$ALWAYS_GFORTRANFLAGS" $options] |
d947d756 | 266 | set options [dg-additional-files-options $options $source] |
47583fc8 | 267 | set return_val [target_compile $source $dest $type $options] |
268 | ||
269 | if {[board_info $tboard exists multilib_flags]} { | |
270 | set board_info($tboard,multilib_flags) $orig_multilib_flags | |
271 | set flags_to_postpone "" | |
272 | } | |
273 | ||
274 | return $return_val | |
4ee9c684 | 275 | } |