Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2004-2020 Free Software Foundation, Inc. |
4e5106e6 | 2 | # Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. |
42159ca5 TT |
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 this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | load_lib libgloss.exp | |
18 | ||
19 | # FIXME:brobecker/2004-03-31: | |
20 | # The following functions should eventually be part of dejagnu. Even after | |
21 | # these functions becomes available in dejagnu, we will keep for a while | |
22 | # a copy here in order to avoid increasing the dejagnu version | |
23 | # requirement. | |
24 | ||
25 | proc gdb_find_gnatmake {} { | |
26 | global tool_root_dir | |
27 | ||
28 | set root "$tool_root_dir/gcc" | |
29 | set GM "" | |
30 | ||
31 | if ![is_remote host] { | |
32 | set file [lookfor_file $root gnatmake] | |
33 | if { $file != "" } { | |
34 | set GM "$file -I$root/ada/rts --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --GCC=$root/xgcc -margs"; | |
35 | } | |
36 | } | |
37 | ||
38 | if {$GM == ""} { | |
39 | set GM [transform gnatmake] | |
40 | } | |
41 | ||
42 | return $GM | |
43 | } | |
44 | ||
24f75ead IB |
45 | proc gdb_find_gdc {} { |
46 | global tool_root_dir | |
47 | print "Tool Root: $tool_root_dir" | |
48 | ||
49 | if {![is_remote host]} { | |
50 | set file [lookfor_file $tool_root_dir gdc] | |
51 | if { $file == "" } { | |
52 | set file [lookfor_file $tool_root_dir gcc/gdc] | |
53 | } | |
54 | if { $file != "" } { | |
55 | set CC "$file -B[file dirname $file]/" | |
56 | } else { | |
57 | set CC [transform gdc] | |
58 | } | |
59 | } else { | |
60 | set CC [transform gdc] | |
61 | } | |
62 | print "CC: $CC" | |
63 | return $CC | |
64 | } | |
65 | ||
42159ca5 TT |
66 | proc gdb_find_gfortran {} { |
67 | global tool_root_dir | |
68 | ||
69 | if {![is_remote host]} { | |
70 | set file [lookfor_file $tool_root_dir gfortran] | |
71 | if { $file == "" } { | |
72 | set file [lookfor_file $tool_root_dir gcc/gfortran] | |
73 | } | |
74 | if { $file != "" } { | |
75 | set CC "$file -B[file dirname $file]/" | |
76 | } else { | |
77 | set CC [transform gfortran] | |
78 | } | |
79 | } else { | |
80 | set CC [transform gfortran] | |
81 | } | |
82 | return $CC | |
83 | } | |
84 | ||
a766d390 DE |
85 | proc gdb_find_go {} { |
86 | global tool_root_dir | |
87 | ||
88 | set GO "" | |
89 | ||
90 | if {![is_remote host]} { | |
91 | set file [lookfor_file $tool_root_dir gccgo] | |
92 | if { $file != "" } { | |
93 | set root [file dirname $file] | |
94 | set GO "$file -B$root/gcc/" | |
95 | } | |
96 | } | |
97 | ||
98 | if { $GO == "" } { | |
99 | set GO [transform gccgo] | |
100 | } | |
101 | ||
102 | return $GO | |
103 | } | |
104 | ||
105 | proc gdb_find_go_linker {} { | |
106 | return [find_go] | |
107 | } | |
108 | ||
67218854 TT |
109 | proc gdb_find_rustc {} { |
110 | global tool_root_dir | |
111 | if {![is_remote host]} { | |
112 | set rustc [lookfor_file $tool_root_dir rustc] | |
113 | if {$rustc == ""} { | |
114 | set rustc rustc | |
115 | } | |
116 | } else { | |
117 | set rustc "" | |
118 | } | |
119 | if {$rustc != ""} { | |
120 | append rustc " --color never" | |
121 | } | |
122 | return $rustc | |
123 | } | |
124 | ||
5922befa LM |
125 | proc gdb_find_hipcc {} { |
126 | global tool_root_dir | |
127 | if {![is_remote host]} { | |
128 | set hipcc [lookfor_file $tool_root_dir hipcc] | |
129 | if {$hipcc == ""} { | |
130 | set hipcc [lookfor_file /opt/rocm/bin hipcc] | |
131 | } | |
132 | } else { | |
133 | set hipcc "" | |
134 | } | |
135 | return $hipcc | |
136 | } | |
137 | ||
f61d5529 DE |
138 | proc gdb_find_ldd {} { |
139 | global LDD_FOR_TARGET | |
140 | if [info exists LDD_FOR_TARGET] { | |
141 | set ldd $LDD_FOR_TARGET | |
142 | } else { | |
143 | set ldd "ldd" | |
144 | } | |
145 | return $ldd | |
146 | } | |
147 | ||
4fa7d390 DE |
148 | proc gdb_find_objcopy {} { |
149 | global OBJCOPY_FOR_TARGET | |
150 | if [info exists OBJCOPY_FOR_TARGET] { | |
151 | set objcopy $OBJCOPY_FOR_TARGET | |
152 | } else { | |
153 | set objcopy [transform objcopy] | |
154 | } | |
155 | return $objcopy | |
156 | } | |
157 | ||
c74f7d1c JT |
158 | # find target objdump |
159 | proc gdb_find_objdump {} { | |
160 | global OBJDUMP_FOR_TARGET | |
161 | if [info exists OBJDUMP_FOR_TARGET] { | |
162 | set objdump $OBJDUMP_FOR_TARGET | |
163 | } else { | |
164 | set objdump [transform objdump] | |
165 | } | |
166 | return $objdump | |
167 | } | |
168 | ||
4fa7d390 DE |
169 | proc gdb_find_readelf {} { |
170 | global READELF_FOR_TARGET | |
171 | if [info exists READELF_FOR_TARGET] { | |
172 | set readelf $READELF_FOR_TARGET | |
173 | } else { | |
174 | set readelf [transform readelf] | |
175 | } | |
176 | return $readelf | |
177 | } | |
178 | ||
57e5e645 SDJ |
179 | proc gdb_find_eu-unstrip {} { |
180 | global EU_UNSTRIP_FOR_TARGET | |
181 | if [info exists EU_UNSTRIP_FOR_TARGET] { | |
182 | set eu_unstrip $EU_UNSTRIP_FOR_TARGET | |
183 | } else { | |
184 | set eu_unstrip [transform eu-unstrip] | |
185 | } | |
186 | return $eu_unstrip | |
187 | } | |
188 | ||
42159ca5 TT |
189 | proc gdb_default_target_compile {source destfile type options} { |
190 | global target_triplet | |
191 | global tool_root_dir | |
192 | global CFLAGS_FOR_TARGET | |
193 | global compiler_flags | |
194 | ||
195 | if { $destfile == "" && $type != "preprocess" && $type != "none" } { | |
196 | error "Must supply an output filename for the compile to default_target_compile" | |
197 | } | |
198 | ||
6ebea266 | 199 | set early_flags "" |
42159ca5 TT |
200 | set add_flags "" |
201 | set libs "" | |
202 | set compiler_type "c" | |
203 | set compiler "" | |
a766d390 DE |
204 | set linker "" |
205 | # linker_opts_order is one of "sources-then-flags", "flags-then-sources". | |
6ebea266 DE |
206 | # The order matters for things like -Wl,--as-needed. The default is to |
207 | # preserve existing behavior. | |
a766d390 | 208 | set linker_opts_order "sources-then-flags" |
42159ca5 TT |
209 | set ldflags "" |
210 | set dest [target_info name] | |
211 | ||
212 | if {[info exists CFLAGS_FOR_TARGET]} { | |
213 | append add_flags " $CFLAGS_FOR_TARGET" | |
214 | } | |
215 | ||
216 | if {[info exists target_info(host,name)]} { | |
217 | set host [host_info name] | |
218 | } else { | |
219 | set host "unix" | |
220 | } | |
221 | ||
222 | foreach i $options { | |
223 | ||
224 | if { $i == "ada" } { | |
225 | set compiler_type "ada" | |
226 | if {[board_info $dest exists adaflags]} { | |
227 | append add_flags " [target_info adaflags]" | |
228 | } | |
229 | if {[board_info $dest exists gnatmake]} { | |
230 | set compiler [target_info gnatmake] | |
231 | } else { | |
232 | set compiler [find_gnatmake] | |
233 | } | |
234 | } | |
235 | ||
236 | if { $i == "c++" } { | |
237 | set compiler_type "c++" | |
238 | if {[board_info $dest exists cxxflags]} { | |
239 | append add_flags " [target_info cxxflags]" | |
240 | } | |
241 | append add_flags " [g++_include_flags]" | |
242 | if {[board_info $dest exists c++compiler]} { | |
243 | set compiler [target_info c++compiler] | |
244 | } else { | |
245 | set compiler [find_g++] | |
246 | } | |
247 | } | |
248 | ||
24f75ead IB |
249 | if { $i == "d" } { |
250 | set compiler_type "d" | |
251 | if {[board_info $dest exists dflags]} { | |
252 | append add_flags " [target_info dflags]" | |
253 | } | |
254 | if {[board_info $dest exists dcompiler]} { | |
255 | set compiler [target_info dcompiler] | |
256 | } else { | |
257 | set compiler [find_gdc] | |
258 | } | |
259 | } | |
260 | ||
42159ca5 TT |
261 | if { $i == "f77" } { |
262 | set compiler_type "f77" | |
263 | if {[board_info $dest exists f77flags]} { | |
264 | append add_flags " [target_info f77flags]" | |
265 | } | |
266 | if {[board_info $dest exists f77compiler]} { | |
267 | set compiler [target_info f77compiler] | |
268 | } else { | |
269 | set compiler [find_g77] | |
270 | } | |
271 | } | |
272 | ||
273 | if { $i == "f90" } { | |
274 | set compiler_type "f90" | |
275 | if {[board_info $dest exists f90flags]} { | |
276 | append add_flags " [target_info f90flags]" | |
277 | } | |
278 | if {[board_info $dest exists f90compiler]} { | |
279 | set compiler [target_info f90compiler] | |
280 | } else { | |
281 | set compiler [find_gfortran] | |
282 | } | |
283 | } | |
284 | ||
a766d390 DE |
285 | if { $i == "go" } { |
286 | set compiler_type "go" | |
287 | if {[board_info $dest exists goflags]} { | |
288 | append add_flags " [target_info goflags]" | |
289 | } | |
290 | if {[board_info $dest exists gocompiler]} { | |
291 | set compiler [target_info gocompiler] | |
292 | } else { | |
293 | set compiler [find_go] | |
294 | } | |
295 | if {[board_info $dest exists golinker]} { | |
296 | set linker [target_info golinker] | |
297 | } else { | |
298 | set linker [find_go_linker] | |
299 | } | |
300 | if {[board_info $dest exists golinker_opts_order]} { | |
301 | set linker_opts_order [target_info golinker_opts_order] | |
302 | } | |
303 | } | |
304 | ||
67218854 TT |
305 | if { $i == "rust" } { |
306 | set compiler_type "rust" | |
307 | if {[board_info $dest exists rustflags]} { | |
308 | append add_flags " [target_info rustflags]" | |
309 | } | |
310 | if {[board_info $dest exists rustflags]} { | |
311 | set compiler [target_info rustflags] | |
312 | } else { | |
313 | set compiler [find_rustc] | |
314 | } | |
315 | } | |
316 | ||
5922befa LM |
317 | if { $i == "hip" } { |
318 | set compiler_type "hip" | |
319 | if {[board_info $dest exists hipflags]} { | |
320 | append add_flags " [target_info hipflags]" | |
321 | } | |
322 | if {[board_info $dest exists hipcompiler]} { | |
323 | set compiler [target_info hipcompiler] | |
324 | } else { | |
325 | set compiler [find_hipcc] | |
326 | } | |
327 | } | |
328 | ||
42159ca5 TT |
329 | if {[regexp "^dest=" $i]} { |
330 | regsub "^dest=" $i "" tmp | |
331 | if {[board_info $tmp exists name]} { | |
332 | set dest [board_info $tmp name] | |
333 | } else { | |
334 | set dest $tmp | |
335 | } | |
336 | } | |
337 | if {[regexp "^compiler=" $i]} { | |
338 | regsub "^compiler=" $i "" tmp | |
339 | set compiler $tmp | |
340 | } | |
6ebea266 DE |
341 | if {[regexp "^early_flags=" $i]} { |
342 | regsub "^early_flags=" $i "" tmp | |
343 | append early_flags " $tmp" | |
344 | } | |
42159ca5 TT |
345 | if {[regexp "^additional_flags=" $i]} { |
346 | regsub "^additional_flags=" $i "" tmp | |
347 | append add_flags " $tmp" | |
348 | } | |
349 | if {[regexp "^ldflags=" $i]} { | |
350 | regsub "^ldflags=" $i "" tmp | |
351 | append ldflags " $tmp" | |
352 | } | |
353 | if {[regexp "^libs=" $i]} { | |
354 | regsub "^libs=" $i "" tmp | |
355 | append libs " $tmp" | |
356 | } | |
357 | if {[regexp "^incdir=" $i]} { | |
358 | regsub "^incdir=" $i "-I" tmp | |
359 | append add_flags " $tmp" | |
360 | } | |
361 | if {[regexp "^libdir=" $i]} { | |
362 | regsub "^libdir=" $i "-L" tmp | |
363 | append add_flags " $tmp" | |
364 | } | |
365 | if {[regexp "^ldscript=" $i]} { | |
366 | regsub "^ldscript=" $i "" ldscript | |
367 | } | |
368 | if {[regexp "^redirect=" $i]} { | |
369 | regsub "^redirect=" $i "" redirect | |
370 | } | |
371 | if {[regexp "^optimize=" $i]} { | |
372 | regsub "^optimize=" $i "" optimize | |
373 | } | |
374 | if {[regexp "^timeout=" $i]} { | |
375 | regsub "^timeout=" $i "" timeout | |
376 | } | |
377 | } | |
378 | ||
379 | if {[board_info $host exists cflags_for_target]} { | |
380 | append add_flags " [board_info $host cflags_for_target]" | |
381 | } | |
382 | ||
383 | global CC_FOR_TARGET | |
384 | global CXX_FOR_TARGET | |
24f75ead | 385 | global D_FOR_TARGET |
42159ca5 TT |
386 | global F77_FOR_TARGET |
387 | global F90_FOR_TARGET | |
388 | global GNATMAKE_FOR_TARGET | |
a766d390 DE |
389 | global GO_FOR_TARGET |
390 | global GO_LD_FOR_TARGET | |
67218854 | 391 | global RUSTC_FOR_TARGET |
5922befa | 392 | global HIPCC_FOR_TARGET |
42159ca5 TT |
393 | |
394 | if {[info exists GNATMAKE_FOR_TARGET]} { | |
395 | if { $compiler_type == "ada" } { | |
396 | set compiler $GNATMAKE_FOR_TARGET | |
397 | } | |
398 | } | |
399 | ||
400 | if {[info exists CC_FOR_TARGET]} { | |
401 | if { $compiler == "" } { | |
402 | set compiler $CC_FOR_TARGET | |
403 | } | |
404 | } | |
405 | ||
406 | if {[info exists CXX_FOR_TARGET]} { | |
407 | if { $compiler_type == "c++" } { | |
408 | set compiler $CXX_FOR_TARGET | |
409 | } | |
410 | } | |
411 | ||
24f75ead IB |
412 | if {[info exists D_FOR_TARGET]} { |
413 | if { $compiler_type == "d" } { | |
414 | set compiler $D_FOR_TARGET | |
415 | } | |
416 | } | |
417 | ||
42159ca5 TT |
418 | if {[info exists F77_FOR_TARGET]} { |
419 | if { $compiler_type == "f77" } { | |
420 | set compiler $F77_FOR_TARGET | |
421 | } | |
422 | } | |
423 | ||
424 | if {[info exists F90_FOR_TARGET]} { | |
425 | if { $compiler_type == "f90" } { | |
426 | set compiler $F90_FOR_TARGET | |
427 | } | |
428 | } | |
429 | ||
a766d390 DE |
430 | if { $compiler_type == "go" } { |
431 | if {[info exists GO_FOR_TARGET]} { | |
432 | set compiler $GO_FOR_TARGET | |
433 | } | |
434 | if {[info exists GO_LD_FOR_TARGET]} { | |
435 | set linker $GO_LD_FOR_TARGET | |
436 | } | |
437 | } | |
438 | ||
67218854 TT |
439 | if {[info exists RUSTC_FOR_TARGET]} { |
440 | if {$compiler_type == "rust"} { | |
441 | set compiler $RUSTC_FOR_TARGET | |
442 | } | |
443 | } | |
444 | ||
5922befa LM |
445 | if {[info exists HIPCC_FOR_TARGET]} { |
446 | if {$compiler_type == "hip"} { | |
447 | set compiler $HIPCC_FOR_TARGET | |
448 | } | |
449 | } | |
450 | ||
a766d390 DE |
451 | if { $type == "executable" && $linker != "" } { |
452 | set compiler $linker | |
453 | } | |
454 | ||
42159ca5 TT |
455 | if { $compiler == "" } { |
456 | set compiler [board_info $dest compiler] | |
457 | if { $compiler == "" } { | |
458 | return "default_target_compile: No compiler to compile with" | |
459 | } | |
460 | } | |
461 | ||
462 | if {![is_remote host]} { | |
463 | if { [which $compiler] == 0 } { | |
464 | return "default_target_compile: Can't find $compiler." | |
465 | } | |
466 | } | |
467 | ||
468 | if {$type == "object"} { | |
67218854 TT |
469 | if {$compiler_type == "rust"} { |
470 | append add_flags "--emit obj" | |
471 | } else { | |
472 | append add_flags " -c" | |
473 | } | |
42159ca5 TT |
474 | } |
475 | ||
476 | if { $type == "preprocess" } { | |
477 | append add_flags " -E" | |
478 | } | |
479 | ||
480 | if { $type == "assembly" } { | |
481 | append add_flags " -S" | |
482 | } | |
483 | ||
484 | if {[board_info $dest exists cflags]} { | |
485 | append add_flags " [board_info $dest cflags]" | |
486 | } | |
487 | ||
488 | if { $type == "executable" } { | |
489 | if {[board_info $dest exists ldflags]} { | |
490 | append add_flags " [board_info $dest ldflags]" | |
491 | } | |
492 | if { $compiler_type == "c++" } { | |
493 | append add_flags " [g++_link_flags]" | |
494 | } | |
495 | if {[isnative]} { | |
496 | # This is a lose. | |
497 | catch "glob -nocomplain $tool_root_dir/libstdc++/libstdc++.so* $tool_root_dir/libstdc++/libstdc++.sl" tmp | |
498 | if { ${tmp} != "" } { | |
499 | if {[regexp ".*solaris2.*" $target_triplet]} { | |
500 | # Solaris 2 | |
501 | append add_flags " -R$tool_root_dir/libstdc++" | |
502 | } elseif {[regexp ".*(osf|irix5|linux).*" $target_triplet]} { | |
503 | # OSF/1 or IRIX 5 | |
504 | append add_flags " -Wl,-rpath,$tool_root_dir/libstdc++" | |
42159ca5 TT |
505 | } |
506 | } | |
507 | } | |
508 | } | |
509 | ||
510 | if {![info exists ldscript]} { | |
511 | set ldscript [board_info $dest ldscript] | |
512 | } | |
513 | ||
514 | foreach i $options { | |
515 | if { $i == "debug" } { | |
516 | if {[board_info $dest exists debug_flags]} { | |
517 | append add_flags " [board_info $dest debug_flags]" | |
518 | } else { | |
519 | append add_flags " -g" | |
520 | } | |
521 | } | |
522 | } | |
523 | ||
524 | if {[info exists optimize]} { | |
525 | append add_flags " $optimize" | |
526 | } | |
527 | ||
528 | if { $type == "executable" } { | |
529 | append add_flags " $ldflags" | |
530 | foreach x $libs { | |
531 | if {[file exists $x]} { | |
532 | append source " $x" | |
533 | } else { | |
534 | append add_flags " $x" | |
535 | } | |
536 | } | |
537 | ||
538 | if {[board_info $dest exists libs]} { | |
539 | append add_flags " [board_info $dest libs]" | |
540 | } | |
541 | ||
542 | # This probably isn't such a good idea, but it avoids nasty | |
543 | # hackiness in the testsuites. | |
544 | # The math library must be linked in before the C library. The C | |
545 | # library is linked in by the linker script, so this must be before | |
546 | # the linker script. | |
547 | if {[board_info $dest exists mathlib]} { | |
548 | append add_flags " [board_info $dest mathlib]" | |
549 | } else { | |
550 | append add_flags " -lm" | |
551 | } | |
552 | ||
553 | # This must be added here. | |
554 | append add_flags " $ldscript" | |
555 | ||
556 | if {[board_info $dest exists remote_link]} { | |
557 | # Relink option. | |
558 | append add_flags " -Wl,-r" | |
559 | } | |
560 | if {[board_info $dest exists output_format]} { | |
561 | append add_flags " -Wl,-oformat,[board_info $dest output_format]" | |
562 | } | |
563 | } | |
564 | ||
565 | if {[board_info $dest exists multilib_flags]} { | |
566 | append add_flags " [board_info $dest multilib_flags]" | |
567 | } | |
568 | ||
569 | verbose "doing compile" | |
570 | ||
571 | set sources "" | |
572 | if {[is_remote host]} { | |
573 | foreach x $source { | |
574 | set file [remote_download host $x] | |
575 | if { $file == "" } { | |
576 | warning "Unable to download $x to host." | |
577 | return "Unable to download $x to host." | |
578 | } else { | |
579 | append sources " $file" | |
580 | } | |
581 | } | |
582 | } else { | |
583 | set sources $source | |
584 | } | |
585 | ||
586 | if {[is_remote host]} { | |
1f74d3b5 YQ |
587 | append add_flags " -o " [file tail $destfile] |
588 | remote_file host delete [file tail $destfile] | |
42159ca5 TT |
589 | } else { |
590 | if { $destfile != "" } { | |
591 | append add_flags " -o $destfile" | |
592 | } | |
593 | } | |
594 | ||
595 | # This is obscure: we put SOURCES at the end when building an | |
596 | # object, because otherwise, in some situations, libtool will | |
597 | # become confused about the name of the actual source file. | |
a766d390 DE |
598 | switch $type { |
599 | "object" { | |
6ebea266 | 600 | set opts "$early_flags $add_flags $sources" |
a766d390 DE |
601 | } |
602 | "executable" { | |
603 | switch $linker_opts_order { | |
604 | "flags-then-sources" { | |
6ebea266 | 605 | set opts "$early_flags $add_flags $sources" |
a766d390 DE |
606 | } |
607 | "sources-then-flags" { | |
6ebea266 | 608 | set opts "$early_flags $sources $add_flags" |
a766d390 DE |
609 | } |
610 | default { | |
611 | error "Invalid value for board_info linker_opts_order" | |
612 | } | |
613 | } | |
614 | } | |
615 | default { | |
6ebea266 | 616 | set opts "$early_flags $sources $add_flags" |
a766d390 | 617 | } |
42159ca5 TT |
618 | } |
619 | ||
620 | if {[is_remote host]} { | |
621 | if {[host_info exists use_at]} { | |
622 | set fid [open "atfile" "w"] | |
623 | puts $fid "$opts" | |
624 | close $fid | |
625 | set opts "@[remote_download host atfile]" | |
626 | remote_file build delete atfile | |
627 | } | |
628 | } | |
629 | ||
630 | verbose "Invoking the compiler as $compiler $opts" 2 | |
631 | ||
632 | if {[info exists redirect]} { | |
633 | verbose "Redirecting output to $redirect" 2 | |
634 | set status [remote_exec host "$compiler $opts" "" "" $redirect] | |
635 | } else { | |
636 | if {[info exists timeout]} { | |
637 | verbose "Setting timeout to $timeout" 2 | |
638 | set status [remote_exec host "$compiler $opts" "" "" "" $timeout] | |
639 | } else { | |
640 | set status [remote_exec host "$compiler $opts"] | |
641 | } | |
642 | } | |
643 | ||
644 | set compiler_flags $opts | |
645 | if {[is_remote host]} { | |
1f74d3b5 YQ |
646 | remote_upload host [file tail $destfile] $destfile |
647 | remote_file host delete [file tail $destfile] | |
42159ca5 TT |
648 | } |
649 | set comp_output [prune_warnings [lindex $status 1]] | |
650 | regsub "^\[\r\n\]+" $comp_output "" comp_output | |
651 | if { [lindex $status 0] != 0 } { | |
652 | verbose -log "compiler exited with status [lindex $status 0]" | |
653 | } | |
654 | if { [lindex $status 1] != "" } { | |
655 | verbose -log "output is:\n[lindex $status 1]" 2 | |
656 | } | |
657 | if { [lindex $status 0] != 0 && "${comp_output}" == "" } { | |
658 | set comp_output "exit status is [lindex $status 0]" | |
659 | } | |
660 | return ${comp_output} | |
661 | } | |
662 | ||
663 | # See if the version of dejaGNU being used to run the testsuite is | |
664 | # recent enough to contain support for building Ada programs or not. | |
665 | # If not, then use the functions above in place of the ones provided | |
666 | # by dejaGNU. This is only temporary (brobecker/2004-03-31). | |
667 | ||
668 | set use_gdb_compile 0 | |
669 | if {[info procs find_gnatmake] == ""} { | |
670 | rename gdb_find_gnatmake find_gnatmake | |
671 | set use_gdb_compile 1 | |
672 | } | |
673 | ||
674 | if {[info procs find_gfortran] == ""} { | |
675 | rename gdb_find_gfortran find_gfortran | |
676 | set use_gdb_compile 1 | |
677 | } | |
678 | ||
a766d390 DE |
679 | if {[info procs find_go_linker] == ""} { |
680 | rename gdb_find_go find_go | |
681 | rename gdb_find_go_linker find_go_linker | |
bb2af9cc | 682 | set use_gdb_compile 1 |
a766d390 DE |
683 | } |
684 | ||
24f75ead IB |
685 | if {[info procs find_gdc] == ""} { |
686 | rename gdb_find_gdc find_gdc | |
687 | set use_gdb_compile 1 | |
688 | } | |
689 | ||
67218854 TT |
690 | if {[info procs find_rustc] == ""} { |
691 | rename gdb_find_rustc find_rustc | |
692 | set use_gdb_compile 1 | |
693 | } | |
694 | ||
5922befa LM |
695 | if {[info procs find_hipcc] == ""} { |
696 | rename gdb_find_hipcc find_hipcc | |
697 | set use_gdb_compile 1 | |
698 | } | |
699 | ||
42159ca5 TT |
700 | if {$use_gdb_compile} { |
701 | catch {rename default_target_compile {}} | |
702 | rename gdb_default_target_compile default_target_compile | |
703 | } | |
9cc8e32c JK |
704 | |
705 | ||
706 | # Provide 'lreverse' missing in Tcl before 7.5. | |
707 | ||
708 | if {[info procs lreverse] == ""} { | |
709 | proc lreverse { arg } { | |
710 | set retval {} | |
711 | while { [llength $retval] < [llength $arg] } { | |
712 | lappend retval [lindex $arg end-[llength $retval]] | |
713 | } | |
714 | return $retval | |
715 | } | |
716 | } | |
49b4de64 JK |
717 | |
718 | # Various ccache versions provide incorrect debug info such as ignoring | |
719 | # different current directory, breaking GDB testsuite. | |
720 | set env(CCACHE_DISABLE) 1 | |
721 | unset -nocomplain env(CCACHE_NODISABLE) |