1 # Copyright
(C
) 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2003 Free Software Foundation
, Inc.
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.
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.
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
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # This file was written by Rob Savoye
(rob@cygnus.com
)
18 # Currently maintained by Doug Evans
(dje@cygnus.com
)
20 # This file is loaded by the tool init file
(eg
: unix.exp
). It provides
21 # default definitions
for gcc_start
, etc. and other supporting cast members.
23 # These globals are used by gcc_start
if no compiler arguments are provided.
24 # They are also used by the various testsuites to
define the environment
:
25 # where to find stdio.h
, libc.a
, etc.
27 # we want to use libgloss so we can
get find_gcc.
33 # GCC_UNDER_TEST is the compiler under test.
37 # default_gcc_version
-- extract and print the version number of the compiler
40 proc default_gcc_version
{ } {
45 # ignore
any arguments after the command
46 set compiler
[lindex $GCC_UNDER_TEST
0]
48 if ![is_remote host
] {
49 set compiler_name
[which $compiler
];
51 set compiler_name $compiler
;
54 # verify that the compiler
exists
55 if { $compiler_name
!= 0 } then {
56 set tmp
[remote_exec host
"$compiler -v"]
57 set status [lindex $tmp
0];
58 set output
[lindex $tmp
1];
59 regexp
"version.*$" $output version
60 if { $
status == 0 && [info exists version
] } then {
61 clone_output
"$compiler_name $version\n"
63 clone_output
"Couldn't determine version of $compiler_name: $output\n"
66 # compiler does not exist
(this should have already been detected
)
67 warning
"$compiler does not exist"
72 # gcc_version
-- Call default_gcc_version
, so we can override it
if needed.
75 proc gcc_version
{ } {
80 # gcc_init
-- called at the start of each .exp script.
82 # There currently isn
't much to do, but always using it allows us to
83 # make some enhancements without having to go back and rewrite the scripts.
88 proc gcc_init { args } {
91 global gluefile wrap_flags
92 global gcc_initialized
94 global TOOL_EXECUTABLE
96 if { $gcc_initialized == 1 } { return; }
98 if ![info exists GCC_UNDER_TEST] {
99 if [info exists TOOL_EXECUTABLE] {
100 set GCC_UNDER_TEST $TOOL_EXECUTABLE;
102 set GCC_UNDER_TEST "[find_gcc]"
106 if ![info exists tmpdir] then {
109 if {[target_info needs_status_wrapper] != "" && \
110 [target_info needs_status_wrapper] != "0" && \
111 ![info exists gluefile]} {
112 set gluefile ${tmpdir}/gcc-testglue.o;
113 set result [build_wrapper $gluefile];
114 if { $result != "" } {
115 set gluefile [lindex $result 0];
116 set wrap_flags [lindex $result 1];
124 # gcc_target_compile -- compile a source file
127 proc gcc_target_compile { source dest type options } {
129 global gluefile wrap_flags;
130 global GCC_UNDER_TEST
133 if {[target_info needs_status_wrapper] != "" && \
134 [target_info needs_status_wrapper] != "0" && \
135 [info exists gluefile] } {
136 lappend options "libs=${gluefile}"
137 lappend options "ldflags=$wrap_flags"
140 if [target_info exists gcc,stack_size] {
141 lappend options "additional_flags=-DSTACK_SIZE=[target_info gcc,stack_size]"
143 if [target_info exists gcc,no_trampolines] {
144 lappend options "additional_flags=-DNO_TRAMPOLINES"
146 if [target_info exists gcc,no_label_values] {
147 lappend options "additional_flags=-DNO_LABEL_VALUES"
149 # TOOL_OPTIONS must come first, so that it doesn't override testcase
151 if [info exists TOOL_OPTIONS
] {
152 set options
[concat
"additional_flags=$TOOL_OPTIONS" $options];
154 if [target_info
exists gcc
,timeout
] {
155 lappend options
"timeout=[target_info gcc,timeout]"
157 lappend options
"compiler=$GCC_UNDER_TEST"
158 set options
[dg
-additional
-files
-options $options $source
]
159 return [target_compile $source $dest $type $options
]