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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [lib/] [gfortran.exp] - Blame information for rev 774

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

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

powered by: WebSVN 2.1.0

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