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