Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / lib / gcc.exp
blob6e3fca457639a268a47d05be6579a36a58ddd1b1
1 # Copyright (C) 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2003, 2004 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.
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.
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.
28 load_lib libgloss.exp
29 load_lib prune.exp
30 load_lib gcc-defs.exp
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 { } {
41 global GCC_UNDER_TEST
43 gcc_init
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]
50 } else {
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 \[^\n\r\]*" $output version
60 if { $status == 0 && [info exists version] } then {
61 clone_output "$compiler_name $version\n"
62 } else {
63 clone_output "Couldn't determine version of $compiler_name: $output\n"
65 } else {
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 { } {
76 default_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.
86 set gcc_initialized 0
88 proc gcc_init { args } {
89 global tmpdir
90 global libdir
91 global gluefile wrap_flags
92 global gcc_initialized
93 global GCC_UNDER_TEST
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
101 } else {
102 set GCC_UNDER_TEST "[find_gcc]"
106 if ![info exists tmpdir] then {
107 set tmpdir /tmp
110 gcc_maybe_build_wrapper "${tmpdir}/gcc-testglue.o"
114 # gcc_target_compile -- compile a source file
117 proc gcc_target_compile { source dest type options } {
118 global tmpdir
119 global gluefile wrap_flags
120 global GCC_UNDER_TEST
121 global TOOL_OPTIONS
123 if {[target_info needs_status_wrapper] != "" && \
124 [target_info needs_status_wrapper] != "0" && \
125 [info exists gluefile] } {
126 lappend options "libs=${gluefile}"
127 lappend options "ldflags=$wrap_flags"
130 if [target_info exists gcc,stack_size] {
131 lappend options "additional_flags=-DSTACK_SIZE=[target_info gcc,stack_size]"
133 if [target_info exists gcc,no_trampolines] {
134 lappend options "additional_flags=-DNO_TRAMPOLINES"
136 if [target_info exists gcc,no_label_values] {
137 lappend options "additional_flags=-DNO_LABEL_VALUES"
139 # TOOL_OPTIONS must come first, so that it doesn't override testcase
140 # specific options.
141 if [info exists TOOL_OPTIONS] {
142 set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
144 if [target_info exists gcc,timeout] {
145 lappend options "timeout=[target_info gcc,timeout]"
147 lappend options "additional_flags=-fno-show-column"
148 lappend options "compiler=$GCC_UNDER_TEST"
149 set options [dg-additional-files-options $options $source]
150 return [target_compile $source $dest $type $options]