1 # Copyright
(C
) 1992-2019, 2020 Free Software Foundation
, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software
; you can redistribute it and
/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # DejaGnu is distributed in the hope that it will be useful
, but
11 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu
; if not
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 # This file was written by Rob Savoye
<rob@welcomehome.org
> and
20 # extensively modified by Bob Manson
<manson@cygnus.com
>.
22 # A hairy pattern to recognize
text.
23 set text "\[- A-Za-z0-9\.\;\"\_\:\'\`\(\)\!\#\=\+\?\&\*]"
25 # This is a collection of support procs
for the target data
26 # structures. We use a named array
, since Tcl has no real data
27 # structures. Here
's the special index words for the array:
28 # Required fields are:
29 # name - the name of the target. (mostly for error messages) This
30 # should also be the string used for this target's array.
31 # It should also be the same as the linker script so we
32 # can find them dynamically.
33 # Optional fields are
:
34 # ldflags
- the flags required to produce a fully linked executable.
35 # config
- the target canonical
for this target. This is a regexp
36 # as passed to istarget or isnative.
37 # cflags
- the flags required to produce an object file from a
39 #
connect - the connectmode
for this target. This is
for both IP and
41 # hostname
- the hostname of the target. This is
for TCP
/IP based
42 # connections
, and is also used
for versions of tip that
44 # serial
- the serial port. This is typically
/dev
/tty? or com?
:.
45 # baud
- the baud rate
for a serial port connection.
46 # netport
- the IP port.
47 # x10
- parameters
for the x10 controller
(used to reboot
)
48 # fileid
- the fileid or spawn id of of the connection.
49 # prompt
- a regexp
for matching the prompt.
50 # ioport
- the port
for I
/O
on dual port systems.
52 # there are three main arrays
, indexed in with
"target", "build", and "host".
53 # all other targets are indexed with a
name usually based
on the linker script
54 # like
"idp", or "ex93x.ld".
57 #
Set the target connection.
59 proc push_target
{ name } {
61 push_config target $
name
64 #
Set the host connection.
66 proc push_host
{ name } {
68 push_config host $
name
71 #
Set the build connection.
73 proc push_build
{ name } {
75 push_config build $
name
78 #
Set the config
for the current host or target connection.
80 proc push_config
{ type
name } {
83 verbose
"pushing config for $type, name is $name"
84 if {[info exists target_info
($type
,name)]} {
85 if { $target_info
($type
,name) == $
name } {
86 error
"pushing config for $type, '$name' twice"
89 set target_info
($type
,name) $
name
92 #
Set the current connection
for target or host.
94 proc pop_config
{ type
} {
97 if {[info exists target_info
($type
,name)]} {
98 unset target_info
($type
,name)
102 # Unset the target connection.
104 proc pop_target
{ } {
108 # Unset the host connection.
114 # Remove extraneous warnings from
TEXT.
117 #
ld.so
: warning
: /usr
/lib
/libc.so
.1.8.1 has older revision than expected
9
119 proc prune_warnings
{ text } {
122 # remove the
\r part of
"\r\n" so we don't break all the patterns
124 regsub
-all
-- "\r" $text "" text
126 # This is from sun4
's. Do it for all machines for now.
127 # The "\\1" is to try to preserve a "\n" but only if necessary.
128 if {[ishost "sparc-*-sunos*"]} {
129 regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
132 # See Brendan for the raison d'etre of this one.
133 # http
://en.wikipedia.org
/wiki
/Brendan_Kehoe
134 if {[ishost
"alpha*-*-*"]} {
135 regsub
-all
"(^|\n)(/usr/(ucb|bin)/ld.*without exceptions was\[^\n\]+\n?)" $text "\\1" text
137 if {[ishost
"hppa*-*-hpux*"]} {
138 # Ignore the compiler
's warnings about PA incompatibility.
139 regsub -all "(^|\n)\[^\n\]*PA 2.0 object file \[^\n\]* was detected. The linked output may not run on a PA 1.x system." $text "" text
141 regsub -all "(^|\n)\[^\n\]*PA 2.0 object file \[^\n\]* was detected. The linked output may not run on a PA 1.x system." $text "" text
143 # And the linker's
+vcompatwarnings verbage.
144 regsub
-all
"(^|\n)\[^\n\]*Linker features were used that may not be supported\[^\n\]*.\[^\n\]*." $text "" text
146 # Ignore these warnings
, which the HP aCC compiler seems to
147 # generate
on HP
-UX
10.30 and
11.0.
(Something is probably
148 # wrong with some
system headers
, but still...
)
150 # This particular warning always is given with a line of warning
151 #
text, followed by a source line
, followed by a line with
"^^^"
152 # underlining an offending symbol
name. Here we slurp up the
153 # warning
text and the next two lines
, assuming that they are
154 # the source line and underline chars.
156 regsub
-all
"Warning .*The linkage directive is ignored for an object or function declared static..\[^\n\]*.\[^\n\]*." $text "" text
158 # Ignore these warnings
, which I often see from the ANSI C
159 # compiler installed
on HP
-UX
11.0 machines.
(Something is
160 # probably wrong with an installation
, or perhaps NLS isn
't
161 # quite healthy yet on 11.0. In either case, it's easier to
162 #
"fix" this nit here, than it is to track down & fix the
165 # This particular warning always is given with a line of warning
166 #
text, followed by line that says
"Using internal messages".
168 regsub
-all
"Warning: Unable to open pxdb message catalog.*" $text "" text
169 regsub
-all
".* Using internal messages.*" $text "" text
171 # Another form of the
"unable to find message catalog" warning.
173 regsub
-all
"cpp: warning .*Possibly incorrect message catalog." $text "" text
175 # Another odd warning
on 11.0.
177 regsub
-all
"aCC .assigner.: Warning .*Could not find library for -l.*" $text "" text
179 # Oh heck
, just keep adding
'em here...
181 regsub -all "aCC .assigner.: Warning .*Could not satisfy instantiation request for \[^\n\]* contained in\[^\n\]*\n\t/lib/pa20_64/lib\[a-zA-Z0-9\]*.sl" $text "" text
183 # Remove the lines that are output by the HP F77 compiler to
184 # indicate the functions that are being compiled.
185 upvar compiler_type compiler_type
186 if { [info exists compiler_type] && $compiler_type eq "f77" } {
187 regsub -all "\[ \ta-zA-Z_0-9\./\]*:\[\r\n\]+" $text "" text
190 # Ignore the warnings about unknown options
191 regsub -all ".*warning \[0-9\]+: Unknown option.*ignored.*" $text "" text
196 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
197 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
199 # This is from sun4's.
Do it
for all machines
for now.
200 # The
"\\1" is to try to preserve a "\n" but only if necessary.
201 regsub
-all
"(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
203 # This happens when compiling
on Alpha OSF
/1 with cc
-g
-O.
204 regsub
-all
"(^|\n)(\n*uopt: Warning: file not optimized; use -g3 if both optimization and debug wanted\n?)+" $text "\\1" text
206 # This happens when compiling
on Alpha OSF using gas.
207 regsub
-all
"(^|\n)(/usr/.*/ld:\nWarning: Linking some objects which contain exception information sections\n\tand some which do not. This may cause fatal runtime exception handling\n\tproblems\[^\n\]*\n?)+" $text "\\1" text
209 # This happens
on SunOS with cc
-g
-O.
210 regsub
-all
"(^|\n)(cc: Warning: -O conflicts with -g. -O turned off.\n?)+" $text "\\1" text
212 # This happens when assembling code with the native HP assembler
213 regsub
-all
"(^|\n)(as:\[^\n\]*err#13.\n .warning.\[^\n\]*\n?)+" $text "\\1" text
215 # When using the HP assembler
, -g isn
't supported.
216 regsub -all "(^|\n)(cc1: warning: -g is only supported when using GAS on this processor\[^\n\]*\ncc1: warning:\[^\n\]*\n?)+" $text "\\1" text
217 regsub -all "(^|\n)(cc1plus: warning: -g is only supported when using GAS on this processor\[^\n\]*\ncc1plus: warning:\[^\n\]*\n?)+" $text "\\1" text
219 # This happens when testing across NFS.
220 regsub -all "(^|\n)((NFS|nfs) server \[^\n\]* not responding\[^\n\]*\n?)+" $text "\\1" text
221 regsub -all "(^|\n)((NFS|nfs) server \[^\n\]* (ok|is alive again)\[^\n\]*\n?)+" $text "\\1" text
223 # This happens when testing across NFS on osf4.
224 regsub -all "(^|\n)(NFS3 server \[^\n\]* not responding still trying\[^\n\]*\n?)+" $text "\\1" text
225 regsub -all "(^|\n)(NFS3 server \[^\n\]* ok\[^\n\]*\n?)+" $text "\\1" text
227 # When using the IRIX 6 o32 assembler, -g isn't supported
228 regsub
-all
"(^|\n)(cc1: warning: `-g' not supported by this configuration of GCC\[^\n\]*\n?)+" $text "\\1" text
229 regsub
-all
"(^|\n)(cc1plus: warning: `-g' not supported by this configuration of GCC\[^\n\]*\n?)+" $text "\\1" text
231 regsub
-all
"(^|\n)(cc1: warning: -mabi=32 does not support -g\[^\n\]*\n?)+" $text "\\1" text
232 regsub
-all
"(^|\n)(cc1plus: warning: -mabi=32 does not support -g\[^\n\]*\n?)+" $text "\\1" text
234 # This happens with the o32 assembler
on IRIX
6.
235 regsub
-all
"(^|\n)(as: Warning: -O3 is not supported for assembly compiles for ucode compilers; changing to -O2.\n?)+" $text "\\1" text
237 # This happens when using g
++ on a DWARF
system.
238 regsub
-all
"(^|\n)(cc1plus: warning: -g option not supported for C\\+\\+ on systems using the DWARF debugging format\n?)+" $text "\\1" text
240 # This is from sun4
's. Do it for all machines for now.
241 # The "\\1" is to try to preserve a "\n" but only if necessary.
242 regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
244 # See Brendan for the raison d'etre of this one.
245 # http
://en.wikipedia.org
/wiki
/Brendan_Kehoe
246 if {[string match
"alpha*-*-*" $host_triplet]} {
247 regsub
-all
"(^|\n)(/usr/(ucb|bin)/ld.*without exceptions was\[^\n\]+\n?)" $text "\\1" text
250 # Don
't pay attention to the AIX4 linker warnings.
251 regsub -all "(^|\n)(ld:.*WARNING: Duplicate.*ld:.*Use the -bload\[^\n\]*\n?)" $text "\\1" text
253 # Or the IRIX 6 ones.
254 regsub -all "(^|\n)(ld(|32|64): WARNING \[^\n\]*\n?)+" $text "\\1" text
255 regsub -all "(^|\n)(ld(|32|64): Giving up.*Use -wall\[^\n\]*\n?)+" $text "\\1" text
257 # Or the NetBSD ones.
258 regsub -all "(^|\n)(\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*warning: this program uses \[^\n\]*)" $text "\\1" text
259 regsub -all "(^|\n)(\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*warning: reference to compatibility \[^\n\]*)" $text "\\1" text
260 regsub -all "(^|\n)(\[^\n\]*:\[0-9\]+: warning: \[^\n\]* possibly used unsafely, use \[^\n\]*\n?)" $text "\\1" text
261 regsub -all "(^|\n)(\[^\n\]*: warning: reference to compatibility glob\[^\n\]*\n?)" $text "\\1" text
263 # Or the OpenBSD ones.
264 regsub -all "(^|\n)(\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*warning: \[^\n\]* is (often|almost always) misused, please use \[^\n\]*\n?)" $text "\\1" text
265 regsub -all "(^|\n)(\[^\n\]*: warning: \[^\n\]* is (often|almost always) misused, please use \[^\n\]*\n?)" $text "\\1" text
267 # GNU ld warns about functions marked as dangerous in GNU libc.
268 regsub -all "(^|\n)\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*is dangerous\[^\n\]*" $text "" text
269 regsub -all "(^|\n)\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*the use of \[^\n\]* is dangerous, better use \[^\n\]*" $text "" text
270 regsub -all "(^|\n)\[^\n\]*is dangerous\[^\n\]*" $text "" text
272 # Libgloss libnosys defines functions that warn when linked in
273 regsub -all "(^|\n)\[^\n\]*: In function\[^\n\]*\n\[^\n\]\[^\n\]*is not implemented and will always fail\[^\n\]*" $text "" text
274 regsub -all "(^|\n)\[^\n\]*is not implemented and will always fail\[^\n\]*" $text "" text
276 # libstdc++-v3 tests can emit cpplib warnings due to duplicate -isystem / -I flags
277 regsub -all "(^|\n)\[^\n\]*: warning: changing search order for system directory\[^\n\]*" $text "" text
278 regsub -all "(^|\n)\[^\n\]*: warning: as it has already been specified\[^\n\]*" $text "" text
280 # Cygwin cc1 warns about -fpic and -fPIC
281 regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC) ignored for target \[^\n\]*" $text "" text
283 # Ignore linker warning when searching 64bit libraries in /lib.
284 regsub -all "(^|\n)\[^\n\]*: skipping incompatible \[^\n\]* when searching for \[^\n\]*" $text "" text
286 # It might be tempting to get carried away and delete blank lines, etc.
287 # Just delete *exactly* what we're ask to
, and that
's it.
291 # Invoke the compiler. This gets interesting cause the compiler may
292 # not be on the same machine we're running DejaGnu
on.
294 proc target_compile
{source destfile type options
} {
295 set target
[target_info
name]
296 if { [info procs $
{target
}_compile
] ne
"" } {
297 return [$
{target
}_compile $source $destfile $type $options
]
299 return [default_target_compile $source $destfile $type $options
]
303 proc default_target_compile
{source destfile type options
} {
304 global target_triplet
306 global CFLAGS_FOR_TARGET
307 global LDFLAGS_FOR_TARGET
308 global compiler_flags
310 if { $destfile eq
"" && $type ne "preprocess" && $type ne "none" } {
311 error
"Must supply an output filename for the compile to default_target_compile"
317 set compiler_type
"c"
320 # linker_opts_order is one of
"sources-then-flags", "flags-then-sources".
321 # The order matters
for things like
-Wl
,--as
-needed. The default is to
322 # preserve existing behavior.
323 set linker_opts_order
"sources-then-flags"
325 set dest
[target_info
name]
327 if {[info exists CFLAGS_FOR_TARGET
]} {
328 append add_flags
" $CFLAGS_FOR_TARGET"
331 if {[info exists LDFLAGS_FOR_TARGET
]} {
332 append ldflags
" $LDFLAGS_FOR_TARGET"
335 if {[host_info
exists]} {
336 set host
[host_info
name]
344 set compiler_type
"ada"
345 if {[board_info $dest
exists adaflags
]} {
346 append add_flags
" [board_info $dest adaflags]"
348 if {[board_info $dest
exists gnatmake
]} {
349 set compiler
[board_info $dest gnatmake
]
351 set compiler
[find_gnatmake
]
356 set compiler_type
"c++"
357 if {[board_info $dest
exists cxxflags
]} {
358 append add_flags
" [board_info $dest cxxflags]"
360 append add_flags
" [g++_include_flags]"
361 if {[board_info $dest
exists c
++compiler
]} {
362 set compiler
[board_info $dest c
++compiler
]
364 set compiler
[find_g
++]
369 set compiler_type
"d"
370 if {[board_info $dest
exists dflags
]} {
371 append add_flags
" [board_info $dest dflags]"
373 if {[board_info $dest
exists dcompiler
]} {
374 set compiler
[board_info $dest dcompiler
]
376 set compiler
[find_gdc
]
381 set compiler_type
"f77"
382 if {[board_info $dest
exists f77flags
]} {
383 append add_flags
" [board_info $dest f77flags]"
385 if {[board_info $dest
exists f77compiler
]} {
386 set compiler
[board_info $dest f77compiler
]
388 set compiler
[find_g77
]
393 set compiler_type
"f90"
394 if {[board_info $dest
exists f90flags
]} {
395 append add_flags
" [board_info $dest f90flags]"
397 if {[board_info $dest
exists f90compiler
]} {
398 set compiler
[board_info $dest f90compiler
]
400 set compiler
[find_gfortran
]
405 set compiler_type
"go"
406 if {[board_info $dest
exists goflags
]} {
407 append add_flags
" [board_info $dest goflags]"
409 if {[board_info $dest
exists gocompiler
]} {
410 set compiler
[board_info $dest gocompiler
]
412 set compiler
[find_go
]
414 if {[board_info $dest
exists golinker
]} {
415 set linker
[board_info $dest golinker
]
417 set linker
[find_go_linker
]
419 if {[board_info $dest
exists golinker_opts_order
]} {
420 set linker_opts_order
[board_info $dest golinker_opts_order
]
424 if { $i eq
"rust" } {
425 set compiler_type
"rust"
426 if {[board_info $dest
exists rustflags
]} {
427 append add_flags
" [board_info $dest rustflags]"
429 if {[board_info $dest
exists rustcompiler
]} {
430 set compiler
[board_info $dest rustcompiler
]
432 set compiler
[find_rustc
]
436 if {[regexp
"^dest=" $i]} {
437 regsub
"^dest=" $i "" tmp
438 if {[board_info $tmp
exists name]} {
439 set dest
[board_info $tmp
name]
444 if {[regexp
"^compiler=" $i]} {
445 regsub
"^compiler=" $i "" tmp
448 if {[regexp
"^linker=" $i]} {
449 regsub
"^linker=" $i "" tmp
452 if {[regexp
"^early_flags=" $i]} {
453 regsub
"^early_flags=" $i "" tmp
454 append early_flags
" $tmp"
456 if {[regexp
"^additional_flags=" $i]} {
457 regsub
"^additional_flags=" $i "" tmp
458 append add_flags
" $tmp"
460 if {[regexp
"^ldflags=" $i]} {
461 regsub
"^ldflags=" $i "" tmp
462 append ldflags
" $tmp"
464 if {[regexp
"^libs=" $i]} {
465 regsub
"^libs=" $i "" tmp
468 if {[regexp
"^incdir=" $i]} {
469 regsub
"^incdir=" $i "-I" tmp
470 append add_flags
" $tmp"
472 if {[regexp
"^libdir=" $i]} {
473 regsub
"^libdir=" $i "-L" tmp
474 append add_flags
" $tmp"
476 if {[regexp
"^ldscript=" $i]} {
477 regsub
"^ldscript=" $i "" ldscript
479 if {[regexp
"^redirect=" $i]} {
480 regsub
"^redirect=" $i "" redirect
482 if {[regexp
"^optimize=" $i]} {
483 regsub
"^optimize=" $i "" optimize
485 if {[regexp
"^timeout=" $i]} {
486 regsub
"^timeout=" $i "" timeout
490 if {[board_info $host
exists cflags_for_target
]} {
491 append add_flags
" [board_info $host cflags_for_target]"
495 global CXX_FOR_TARGET
497 global F77_FOR_TARGET
498 global F90_FOR_TARGET
499 global GNATMAKE_FOR_TARGET
501 global GO_LD_FOR_TARGET
502 global RUSTC_FOR_TARGET
504 if {[info exists GNATMAKE_FOR_TARGET
]} {
505 if { $compiler_type eq
"ada" } {
506 set compiler $GNATMAKE_FOR_TARGET
510 if {[info exists CC_FOR_TARGET
]} {
511 if { $compiler eq
"" } {
512 set compiler $CC_FOR_TARGET
516 if {[info exists CXX_FOR_TARGET
]} {
517 if { $compiler_type eq
"c++" } {
518 set compiler $CXX_FOR_TARGET
522 if {[info exists D_FOR_TARGET
]} {
523 if { $compiler_type eq
"d" } {
524 set compiler $D_FOR_TARGET
528 if {[info exists F77_FOR_TARGET
]} {
529 if { $compiler_type eq
"f77" } {
530 set compiler $F77_FOR_TARGET
534 if {[info exists F90_FOR_TARGET
]} {
535 if { $compiler_type eq
"f90" } {
536 set compiler $F90_FOR_TARGET
540 if { $compiler_type eq
"go" } {
541 if {[info exists GO_FOR_TARGET
]} {
542 set compiler $GO_FOR_TARGET
544 if {[info exists GO_LD_FOR_TARGET
]} {
545 set linker $GO_LD_FOR_TARGET
549 if {[info exists RUSTC_FOR_TARGET
]} {
550 if {$compiler_type eq
"rust"} {
551 set compiler $RUSTC_FOR_TARGET
555 if { $type eq
"executable" && $linker ne "" } {
559 if { $compiler eq
"" } {
560 if { [board_info $dest
exists compiler
] } {
561 set compiler
[board_info $dest compiler
]
562 } elseif
{ $compiler_type eq
"c" } {
563 set compiler
[find_gcc
]
565 if { $compiler eq
"" } {
566 return "default_target_compile: No compiler to compile with"
570 if {![isremote host
]} {
571 if { [which $compiler
] == 0 } {
572 return "default_target_compile: Can't find $compiler."
576 if {$type eq
"object"} {
577 if {$compiler_type eq
"rust"} {
578 append add_flags
" --emit obj"
580 append add_flags
" -c"
584 if { $type eq
"preprocess" } {
585 append add_flags
" -E"
588 if { $type eq
"assembly" } {
589 if {$compiler_type eq
"rust"} {
590 append add_flags
" --emit asm"
592 append add_flags
" -S"
596 if {[board_info $dest
exists cflags
]} {
597 append add_flags
" [board_info $dest cflags]"
600 if { $type eq
"executable" } {
602 if {[board_info $dest
exists ldflags
]} {
603 append extra_ldflags
" [board_info $dest ldflags]"
605 if { $compiler_type eq
"c++" } {
606 append extra_ldflags
" [g++_link_flags]"
610 catch
"glob -nocomplain $tool_root_dir/libstdc++/libstdc++.so* $tool_root_dir/libstdc++/libstdc++.sl" tmp
612 if {[regexp
".*solaris2.*" $target_triplet]} {
614 append extra_ldflags
" -R$tool_root_dir/libstdc++"
615 } elseif
{[regexp
".*(osf|irix5|linux).*" $target_triplet]} {
617 append extra_ldflags
" -Wl,-rpath,$tool_root_dir/libstdc++"
618 } elseif
{[regexp
".*hppa.*" $target_triplet]} {
620 append extra_ldflags
" -Wl,-a,shared_archive"
624 if { $extra_ldflags ne
"" } {
625 if { $compiler_type eq
"ada" } {
626 append add_flags
" -largs $extra_ldflags -margs"
628 append add_flags
" $extra_ldflags"
633 if {![info exists ldscript
]} {
634 set ldscript
[board_info $dest ldscript
]
638 if { $i eq
"debug" } {
639 if {[board_info $dest
exists debug_flags
]} {
640 append add_flags
" [board_info $dest debug_flags]"
642 append add_flags
" -g"
647 if {[info exists optimize
]} {
648 append add_flags
" $optimize"
651 if { $type eq
"executable" } {
652 set extra_ldflags
"$ldflags"
654 if {[file
exists $x
]} {
657 append extra_ldflags
" $x"
661 if {[board_info $dest
exists libs
]} {
662 append extra_ldflags
" [board_info $dest libs]"
665 # This probably isn
't such a good idea, but it avoids nasty
666 # hackiness in the testsuites.
667 # The math library must be linked in before the C library. The C
668 # library is linked in by the linker script, so this must be before
670 if {[board_info $dest exists mathlib]} {
671 append extra_ldflags " [board_info $dest mathlib]"
673 append extra_ldflags " -lm"
676 # This must be added here.
677 append extra_ldflags " $ldscript"
679 if {[board_info $dest exists remote_link]} {
681 append extra_ldflags " -Wl,-r"
683 if {[board_info $dest exists output_format]} {
684 append extra_ldflags " -Wl,-oformat,[board_info $dest \
687 if { $extra_ldflags ne "" } {
688 if { $compiler_type eq "ada" } {
689 append add_flags " -largs $extra_ldflags -margs"
691 append add_flags " $extra_ldflags"
696 if {[board_info $dest exists multilib_flags]} {
697 set multilib_flags [board_info $dest multilib_flags]
698 if { $compiler_type eq "ada" } {
699 set add_flags "$multilib_flags -largs $multilib_flags -margs\
702 set add_flags "$multilib_flags $add_flags"
706 verbose "doing compile"
709 if {[isremote host]} {
711 set file [remote_download host $x]
713 warning "Unable to download $x to host."
714 return "Unable to download $x to host."
716 append sources " $file"
723 if {[isremote host]} {
724 append add_flags " -o a.out"
725 remote_file host delete a.out
727 if { $destfile ne "" } {
728 append add_flags " -o $destfile"
732 # This is obscure: we put SOURCES at the end when building an
733 # object, because otherwise, in some situations, libtool will
734 # become confused about the name of the actual source file.
737 set opts "$early_flags $add_flags $sources"
740 switch $linker_opts_order {
741 "flags-then-sources" {
742 set opts "$early_flags $add_flags $sources"
744 "sources-then-flags" {
745 set opts "$early_flags $sources $add_flags"
748 error "Invalid value for board_info linker_opts_order"
753 set opts "$early_flags $sources $add_flags"
757 if {[isremote host]} {
758 if {[host_info exists use_at]} {
759 set fid [open "atfile" "w"]
762 set opts "@[remote_download host atfile]"
763 remote_file build delete atfile
767 verbose "Invoking the compiler as $compiler $opts" 2
769 if {[info exists redirect]} {
770 verbose "Redirecting output to $redirect" 2
771 set status [remote_exec host "$compiler $opts" "" "" $redirect]
773 if {[info exists timeout]} {
774 verbose "Setting timeout to $timeout" 2
775 set status [remote_exec host "$compiler $opts" "" "" "" $timeout]
777 set status [remote_exec host "$compiler $opts"]
781 set compiler_flags $opts
782 if {[isremote host]} {
783 remote_upload host a.out $destfile
784 remote_file host delete a.out
786 set comp_output [prune_warnings [lindex $status 1]]
787 regsub "^\[\r\n\]+" $comp_output "" comp_output
788 if { [lindex $status 0] != 0 } {
789 verbose -log "compiler exited with status [lindex $status 0]"
791 if { [lindex $status 1] ne "" } {
792 verbose "output is:\n[lindex $status 1]" 2
794 if { [lindex $status 0] != 0 && $comp_output eq "" } {
795 set comp_output "exit status is [lindex $status 0]"
800 proc reboot_target { } {
801 set result [remote_reboot target]
802 puts "REBOOT_TARGET: \"$result\""
806 # Invoke this if you really want as to be called directly, rather than
807 # calling the compiler. FLAGS are any additional flags to pass to the
810 proc target_assemble { source destfile flags } {
811 return [default_target_assemble $source $destfile $flags]
814 proc default_target_assemble { source destfile flags } {
816 global ASFLAGS_FOR_TARGET
818 if {[info exists AS_FOR_TARGET]} {
819 set AS $AS_FOR_TARGET
821 if {![board_info target exists assembler]} {
824 set AS [board_info target assembler]
828 if {[info exists ASFLAGS_FOR_TARGET]} {
829 append flags " $ASFLAGS_FOR_TARGET"
832 if {[isremote host]} {
833 set source [remote_download host $source]
838 set status [remote_exec host "$AS $source $flags -o $dest"]
839 if {[isremote host]} {
840 remote_upload host $dest $destfile
843 set comp_output [prune_warnings [lindex $status 1]]
844 if { [lindex $status 0] != 0 } {
845 verbose -log "assembler exited with status [lindex $status 0]"
847 if { [lindex $status 1] ne "" } {
848 verbose "assembler output is:\n[lindex $status 1]" 2
853 # Invoke this if you really want ld to be called directly, rather than
854 # calling the compiler. FLAGS are any additional flags to pass to the
857 proc target_link { objects destfile flags } {
858 return [default_link target $objects $destfile $flags]
861 proc default_link { board objects destfile flags } {
863 global LDFLAGS_FOR_TARGET
865 # return -L's in ldflags
866 proc only
--Ls
{ ldflags
} {
868 set ldflags
[split $ldflags
]
869 set len
[llength $ldflags
]
870 for { set i
0 } { $i
< $len
} { incr i
} {
871 # Note
: We ignore the situation where a
-L is actually the
872 #
argument to an option.
873 set arg [lindex $ldflags $i
]
874 regsub
"^-Wl," $arg "" arg
875 if {[regexp
"^-L" $arg]} {
876 # Is the directory in the next
arg, or part of this one?
877 if { $
arg eq
"-L" } {
878 if { $i
+ 1 < $len
} {
879 append result
" -L [lindex $ldflags $i+1]"
883 append result
" $arg"
890 if {[info exists LD_FOR_TARGET
]} {
891 set LD $LD_FOR_TARGET
893 if {![board_info target
exists linker
]} {
896 set LD [board_info target linker
]
900 if {[info exists LDFLAGS_FOR_TARGET
]} {
901 append flags
" $LDFLAGS_FOR_TARGET"
904 # `ldflags
' consists of arguments to gcc (that are then
905 # passed to ld), not arguments to ld directly.
907 if {[board_info $board
exists ldflags
]} {
908 set ldflags
[board_info $board ldflags
]
909 set ldflags
[only
--Ls $ldflags
]
910 append flags
" $ldflags"
913 if {[board_info $board
exists ldscript
]} {
914 #
strip leading
-Wl
, if present
915 set ldscript
[board_info $board ldscript
]
916 regsub
"^-Wl," $ldscript "" ldscript
917 append flags
" $ldscript"
920 if {[isremote host
]} {
923 set nobjects
"$nobjects [remote_download host $x]"
925 set objects $nobjects
930 set status [remote_exec host
"$LD $objects $flags -o $dest"]
931 if {[isremote host
]} {
932 remote_upload host $dest $destfile
935 set comp_output
[prune_warnings
[lindex $
status 1]]
936 if { [lindex $
status 0] != 0 } {
937 verbose
-log "linker exited with status [lindex $status 0]"
939 if { [lindex $
status 1] ne
"" } {
940 verbose
"linker output is:\n[lindex $status 1]" 2