1 # Copyright
(C
) 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2007
2 # Free Software Foundation
, Inc.
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.
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.
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 #
<http
://www.gnu.org
/licenses
/>.
18 # This file was written by Rob Savoye
(rob@cygnus.com
)
19 # Currently maintained by Doug Evans
(dje@cygnus.com
)
21 # This file is loaded by the tool init file
(eg
: unix.exp
). It provides
22 # default definitions
for gcc_start
, etc. and other supporting cast members.
24 # These globals are used by gcc_start
if no compiler arguments are provided.
25 # They are also used by the various testsuites to
define the environment
:
26 # where to find stdio.h
, libc.a
, etc.
28 # we want to use libgloss so we can
get find_gcc.
34 # GCC_UNDER_TEST is the compiler under test.
38 # default_gcc_version
-- extract and print the version number of the compiler
41 proc default_gcc_version
{ } {
46 # ignore
any arguments after the command
47 set compiler
[lindex $GCC_UNDER_TEST
0]
49 if ![is_remote host
] {
50 set compiler_name
[which $compiler
]
52 set compiler_name $compiler
55 # verify that the compiler
exists
56 if { $compiler_name
!= 0 } then {
57 set tmp
[remote_exec host
"$compiler -v"]
58 set status [lindex $tmp
0]
59 set output
[lindex $tmp
1]
60 regexp
" version \[^\n\r\]*" $output version
61 if { $
status == 0 && [info exists version
] } then {
62 clone_output
"$compiler_name $version\n"
64 clone_output
"Couldn't determine version of $compiler_name: $output\n"
67 # compiler does not exist
(this should have already been detected
)
68 warning
"$compiler does not exist"
73 # gcc_version
-- Call default_gcc_version
, so we can override it
if needed.
76 proc gcc_version
{ } {
81 # gcc_init
-- called at the start of each .exp script.
83 # There currently isn
't much to do, but always using it allows us to
84 # make some enhancements without having to go back and rewrite the scripts.
89 proc gcc_init { args } {
92 global gluefile wrap_flags
93 global gcc_initialized
95 global TOOL_EXECUTABLE
96 global gcc_warning_prefix
97 global gcc_error_prefix
99 if { $gcc_initialized == 1 } { return; }
101 if ![info exists GCC_UNDER_TEST] {
102 if [info exists TOOL_EXECUTABLE] {
103 set GCC_UNDER_TEST $TOOL_EXECUTABLE
105 set GCC_UNDER_TEST "[find_gcc]"
109 if ![info exists tmpdir] then {
113 set gcc_warning_prefix "warning:"
114 set gcc_error_prefix "error:"
116 gcc_maybe_build_wrapper "${tmpdir}/gcc-testglue.o"
120 # gcc_target_compile -- compile a source file
123 proc gcc_target_compile { source dest type options } {
125 global gluefile wrap_flags
126 global GCC_UNDER_TEST
129 if {[target_info needs_status_wrapper] != "" && \
130 [target_info needs_status_wrapper] != "0" && \
131 [info exists gluefile] } {
132 lappend options "libs=${gluefile}"
133 lappend options "ldflags=$wrap_flags"
136 if [target_info exists gcc,stack_size] {
137 lappend options "additional_flags=-DSTACK_SIZE=[target_info gcc,stack_size]"
139 if [target_info exists gcc,no_trampolines] {
140 lappend options "additional_flags=-DNO_TRAMPOLINES"
142 if [target_info exists gcc,no_label_values] {
143 lappend options "additional_flags=-DNO_LABEL_VALUES"
145 # TOOL_OPTIONS must come first, so that it doesn't override testcase
147 if [info exists TOOL_OPTIONS
] {
148 set options
[concat
"{additional_flags=$TOOL_OPTIONS}" $options]
150 if [target_info
exists gcc
,timeout
] {
151 lappend options
"timeout=[target_info gcc,timeout]"
153 lappend options
"additional_flags=-fno-show-column"
154 lappend options
"compiler=$GCC_UNDER_TEST"
155 set options
[dg
-additional
-files
-options $options $source
]
156 return [target_compile $source $dest $type $options
]