1 |
701 |
jeremybenn |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
|
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 was written by James A. Morrison (ja2morri@uwaterloo.ca)
|
19 |
|
|
# based on gcc.exp written by Rob Savoye (rob@cygnus.com).
|
20 |
|
|
|
21 |
|
|
# This file is loaded by the tool init file (eg: unix.exp). It provides
|
22 |
|
|
# default definitions for gnat_start, etc. and other supporting cast members.
|
23 |
|
|
|
24 |
|
|
load_lib prune.exp
|
25 |
|
|
load_lib gcc-defs.exp
|
26 |
|
|
load_lib gcc.exp
|
27 |
|
|
load_lib timeout.exp
|
28 |
|
|
|
29 |
|
|
#
|
30 |
|
|
# GNAT_UNDER_TEST is the compiler under test.
|
31 |
|
|
#
|
32 |
|
|
|
33 |
|
|
#
|
34 |
|
|
# default_gnat_version -- extract and print the version number of the compiler
|
35 |
|
|
#
|
36 |
|
|
|
37 |
|
|
proc default_gnat_version { } {
|
38 |
|
|
global GNAT_UNDER_TEST
|
39 |
|
|
|
40 |
|
|
gnat_init
|
41 |
|
|
|
42 |
|
|
# ignore any arguments after the command
|
43 |
|
|
set compiler [lindex $GNAT_UNDER_TEST 0]
|
44 |
|
|
|
45 |
|
|
if ![is_remote host] {
|
46 |
|
|
set compiler_name [which $compiler]
|
47 |
|
|
} else {
|
48 |
|
|
set compiler_name $compiler
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
# verify that the compiler exists
|
52 |
|
|
if { $compiler_name != 0 } then {
|
53 |
|
|
set tmp [remote_exec host "$compiler --version"]
|
54 |
|
|
set status [lindex $tmp 0]
|
55 |
|
|
set output [lindex $tmp 1]
|
56 |
|
|
regexp "^GNATMAKE (\[^\n\r\]*)" $output verline version
|
57 |
|
|
if { $status == 0 && [info exists version] } then {
|
58 |
|
|
# test_summary expects "version" as second field.
|
59 |
|
|
clone_output "$compiler_name version $version\n"
|
60 |
|
|
} else {
|
61 |
|
|
clone_output "Couldn't determine version of $compiler_name: $output\n"
|
62 |
|
|
}
|
63 |
|
|
} else {
|
64 |
|
|
# compiler does not exist (this should have already been detected)
|
65 |
|
|
warning "$compiler does not exist"
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
#
|
70 |
|
|
# gnat_version -- Call default_gnat_version, so we can override it if needed.
|
71 |
|
|
#
|
72 |
|
|
|
73 |
|
|
proc gnat_version { } {
|
74 |
|
|
default_gnat_version
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
#
|
78 |
|
|
# gnat_init -- called at the start of each .exp script.
|
79 |
|
|
#
|
80 |
|
|
|
81 |
|
|
set gnat_initialized 0
|
82 |
|
|
|
83 |
|
|
proc gnat_init { args } {
|
84 |
|
|
global rootme
|
85 |
|
|
global tmpdir
|
86 |
|
|
global libdir
|
87 |
|
|
global gluefile wrap_flags
|
88 |
|
|
global gnat_initialized
|
89 |
|
|
global GNAT_UNDER_TEST
|
90 |
|
|
global TOOL_EXECUTABLE
|
91 |
|
|
global gnat_target_current
|
92 |
|
|
|
93 |
|
|
set gnat_target_current ""
|
94 |
|
|
|
95 |
|
|
if { $gnat_initialized == 1 } { return }
|
96 |
|
|
|
97 |
|
|
if ![info exists GNAT_UNDER_TEST] then {
|
98 |
|
|
if [info exists TOOL_EXECUTABLE] {
|
99 |
|
|
set GNAT_UNDER_TEST "$TOOL_EXECUTABLE"
|
100 |
|
|
} else {
|
101 |
|
|
set GNAT_UNDER_TEST "[local_find_gnatmake]"
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
if ![info exists tmpdir] then {
|
106 |
|
|
set tmpdir /tmp
|
107 |
|
|
}
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
proc gnat_target_compile { source dest type options } {
|
111 |
|
|
global rootme
|
112 |
|
|
global tmpdir
|
113 |
|
|
global gluefile wrap_flags
|
114 |
|
|
global srcdir
|
115 |
|
|
global GNAT_UNDER_TEST
|
116 |
|
|
global TOOL_OPTIONS
|
117 |
|
|
global gnat_target_current
|
118 |
|
|
global TEST_ALWAYS_FLAGS
|
119 |
|
|
|
120 |
|
|
# dg-require-effective-target tests must be compiled as C.
|
121 |
|
|
if [ string match "*.c" $source ] then {
|
122 |
|
|
return [gcc_target_compile $source $dest $type $options]
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
# If we detect a change of target, we need to recompute both
|
126 |
|
|
# GNAT_UNDER_TEST and the appropriate RTS.
|
127 |
|
|
if { $gnat_target_current!="[current_target_name]" } {
|
128 |
|
|
set gnat_target_current "[current_target_name]"
|
129 |
|
|
if [info exists TOOL_OPTIONS] {
|
130 |
|
|
set rtsdir "[get_multilibs ${TOOL_OPTIONS}]/libada"
|
131 |
|
|
} else {
|
132 |
|
|
set rtsdir "[get_multilibs]/libada"
|
133 |
|
|
}
|
134 |
|
|
if [info exists TOOL_EXECUTABLE] {
|
135 |
|
|
set GNAT_UNDER_TEST "$TOOL_EXECUTABLE"
|
136 |
|
|
} else {
|
137 |
|
|
set GNAT_UNDER_TEST "[local_find_gnatmake]"
|
138 |
|
|
}
|
139 |
|
|
set GNAT_UNDER_TEST "$GNAT_UNDER_TEST --RTS=$rtsdir"
|
140 |
|
|
|
141 |
|
|
# gnatlink looks for system.ads itself and has no --RTS option, so
|
142 |
|
|
# specify via environment
|
143 |
|
|
setenv ADA_INCLUDE_PATH "$rtsdir/adainclude"
|
144 |
|
|
setenv ADA_OBJECTS_PATH "$rtsdir/adainclude"
|
145 |
|
|
# Always log so compilations can be repeated manually.
|
146 |
|
|
verbose -log "ADA_INCLUDE_PATH=$rtsdir/adainclude"
|
147 |
|
|
verbose -log "ADA_OBJECTS_PATH=$rtsdir/adainclude"
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
lappend options "compiler=$GNAT_UNDER_TEST -q -f"
|
151 |
|
|
lappend options "timeout=[timeout_value]"
|
152 |
|
|
|
153 |
|
|
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
|
154 |
|
|
lappend options "libs=${gluefile}"
|
155 |
|
|
lappend options "ldflags=$wrap_flags"
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
# TEST_ALWAYS_FLAGS are flags that should be passed to every
|
159 |
|
|
# compilation. They are passed first to allow individual
|
160 |
|
|
# tests to override them.
|
161 |
|
|
if [info exists TEST_ALWAYS_FLAGS] {
|
162 |
|
|
set options [concat "{additional_flags=$TEST_ALWAYS_FLAGS}" $options]
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
# TOOL_OPTIONS must come first, so that it doesn't override testcase
|
166 |
|
|
# specific options.
|
167 |
|
|
if [info exists TOOL_OPTIONS] {
|
168 |
|
|
set options [concat "additional_flags=$TOOL_OPTIONS" $options]
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
return [target_compile $source $dest $type $options]
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
# Prune messages from GNAT that aren't useful.
|
175 |
|
|
|
176 |
|
|
proc prune_gnat_output { text } {
|
177 |
|
|
#send_user "Before:$text\n"
|
178 |
|
|
regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
|
179 |
|
|
regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
|
180 |
|
|
|
181 |
|
|
# prune the output from gnatmake.
|
182 |
|
|
regsub -all "(^|\n)\[^\n\]*gnatmake: [^\n\]*" $text "" text
|
183 |
|
|
|
184 |
|
|
# It would be nice to avoid passing anything to gnat that would cause it to
|
185 |
|
|
# issue these messages (since ignoring them seems like a hack on our part),
|
186 |
|
|
# but that's too difficult in the general case. For example, sometimes
|
187 |
|
|
# you need to use -B to point gnat at crt0.o, but there are some targets
|
188 |
|
|
# that don't have crt0.o.
|
189 |
|
|
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
|
190 |
|
|
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
|
191 |
|
|
|
192 |
|
|
#send_user "After:$text\n"
|
193 |
|
|
|
194 |
|
|
return $text
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
# find_gnatmake for some version of DejaGnu will hardcode a -I...rts/ada flag
|
198 |
|
|
# which prevent multilib from working, so define a new one.
|
199 |
|
|
|
200 |
|
|
proc local_find_gnatmake {} {
|
201 |
|
|
global tool_root_dir
|
202 |
|
|
|
203 |
|
|
if ![is_remote host] {
|
204 |
|
|
set file [lookfor_file $tool_root_dir gnatmake]
|
205 |
|
|
if { $file == "" } {
|
206 |
|
|
set file [lookfor_file $tool_root_dir gcc/gnatmake]
|
207 |
|
|
}
|
208 |
|
|
if { $file != "" } {
|
209 |
|
|
set root [file dirname $file]
|
210 |
|
|
# Need to pass full --GCC, including multilib flags, to gnatlink,
|
211 |
|
|
# otherwise gcc from PATH is invoked.
|
212 |
|
|
set dest [target_info name]
|
213 |
|
|
set gnatlink_gcc "--GCC=$root/xgcc -B$root [board_info $dest multilib_flags]"
|
214 |
|
|
# Escape blanks to get them through DejaGnu's exec machinery.
|
215 |
|
|
regsub -all {\s} "$gnatlink_gcc" {\\&} gnatlink_gcc
|
216 |
|
|
set CC "$file --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs $gnatlink_gcc -margs";
|
217 |
|
|
} else {
|
218 |
|
|
set CC [transform gnatmake]
|
219 |
|
|
}
|
220 |
|
|
} else {
|
221 |
|
|
set CC [transform gnatmake]
|
222 |
|
|
}
|
223 |
|
|
return $CC
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
proc find_gnatclean {} {
|
227 |
|
|
global tool_root_dir
|
228 |
|
|
|
229 |
|
|
if ![is_remote host] {
|
230 |
|
|
set file [lookfor_file $tool_root_dir gnatclean]
|
231 |
|
|
if { $file == "" } {
|
232 |
|
|
set file [lookfor_file $tool_root_dir gcc/gnatclean]
|
233 |
|
|
}
|
234 |
|
|
if { $file != "" } {
|
235 |
|
|
set gnatclean $file;
|
236 |
|
|
} else {
|
237 |
|
|
set gnatclean [transform gnatclean]
|
238 |
|
|
}
|
239 |
|
|
} else {
|
240 |
|
|
set gnatclean [transform gnatclean]
|
241 |
|
|
}
|
242 |
|
|
return $gnatclean
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
# Local Variables:
|
246 |
|
|
# tcl-indent-level:4
|
247 |
|
|
# End:
|