Add tests for mixed C/C++ unit test library usage
[dejagnu.git] / lib / libgloss.exp
blob8e8a9ce676b706248cc3fa63a91e87263dcd170a
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>.
21 # this contains a list of gcc options and their respective directories.
23 # Find the pieces of libgloss for testing the GNU development tools
24 # needed to link a set of object files into an executable.
25 # This usually means setting the -L and -B paths correctly.
27 proc libgloss_link_flags { args } {
28 global target_cpu
29 global srcdir
31 # libgloss doesn't work native
32 if {[isnative]} {
33 return ""
36 # if we're on a remote host, we can't search for the file, so we can only
37 # use an installed compiler, so we don't add any paths here.
38 if {[isremote host]} {
39 return ""
42 set gccpath "[get_multilibs]"
44 # map the target_cpu to the proper libgloss directory. unfortunately, these
45 # directory names are hardcoded into libgloss.
46 switch -glob -- $target_cpu {
47 "sparc86x" {
48 set cpu sparc
50 "sparclite" {
51 set cpu sparc
53 "sparclet" {
54 set cpu sparc
56 "sparc64*" {
57 set cpu sparc
59 "hppa*" {
60 set cpu pa
62 "mips*" {
63 set cpu mips
65 "powerpc*" {
66 set cpu rs6000
68 "d10v*" {
69 set cpu libnosys
71 "xscale*" {
72 set cpu arm
74 "aarch64*" {
75 set cpu aarch64
77 default {
78 set cpu $target_cpu
82 set gloss_srcdir ""
83 # look for the libgloss srcdir sp we can find the linker scripts
84 set gloss_srcdir [lookfor_file $srcdir libgloss/$cpu]
86 # set the proper paths for gcc if the target subdir exists, else assume we
87 # have no libgloss support for this target.
88 if { $gloss_srcdir eq "" } {
89 return ""
91 if {[file exists [file join $gccpath libgloss $cpu]]} {
92 verbose "Libgloss path is $gccpath/libgloss/$cpu" 2
93 return "-B$gccpath/libgloss/$cpu/ -L$gccpath/libgloss/$cpu -L$gloss_srcdir"
94 } else {
95 verbose -log "No libgloss support for this target." 2
96 return ""
100 # There aren't any, but we'll be orthogonal here.
102 proc libgloss_include_flags { args } {
103 return ""
106 # Find the newlib libraries in the current source tree.
108 proc newlib_link_flags { args } {
109 global tool_root_dir
111 # libgloss doesn't work native
112 if {[isnative]} {
113 return ""
116 # if we're on a remote host, we can't search for the file, so we can only
117 # use an installed compiler, so we don't add any paths here.
118 if {[isremote host]} {
119 return ""
122 set ld_script_path [lookfor_file $tool_root_dir "ld/ldscripts"]
123 if { $ld_script_path ne "" } {
124 set result "-L[file dirname $ld_script_path]"
125 } else {
126 set result ""
129 set gccpath "[get_multilibs]"
131 verbose "Looking for $gccpath/newlib"
132 if {[file exists [file join $gccpath newlib]]} {
133 verbose "Newlib path is $gccpath/newlib"
134 return "$result -B$gccpath/newlib/ -L$gccpath/newlib"
135 } else {
136 verbose "No newlib support for this target"
137 return $result
141 proc newlib_include_flags { args } {
142 global srcdir
144 if {[isnative]} {
145 return ""
148 if {[isremote host]} {
149 return ""
152 set gccpath "[get_multilibs]"
154 if {[file exists [file join $gccpath newlib]]} {
155 verbose "Newlib path is $gccpath/newlib"
157 set newlib_dir [lookfor_file $srcdir newlib/libc/include/assert.h]
158 if { $newlib_dir ne "" } {
159 set newlib_dir [file dirname $newlib_dir]
161 # Note - we use -isystem rather than -I because newlib contains
162 # system header files. This is especially important for the
163 # limits.h header which makes use of the #include_next directive.
164 # #include_next will generate error messages from GCC if compiling
165 # in strict ANSI mode or if another limits.h header cannot be found.
166 # When it is included via -isystem these things do not happen.
167 return " -isystem $gccpath/newlib/targ-include -isystem $newlib_dir"
168 } else {
169 verbose "No newlib support for this target"
173 proc libio_include_flags { args } {
174 global srcdir
175 global tool_root_dir
177 if {[isremote host]} {
178 return ""
181 set gccpath "[get_multilibs]"
183 if { $gccpath eq "" } {
184 set gccpath $tool_root_dir
187 set libio_bin_dir [lookfor_file $gccpath libio/_G_config.h]
189 # linux doesn't build _G_config.h and the test above fails, so
190 # we search for iostream.list too.
191 if { $libio_bin_dir eq "" } {
192 set libio_bin_dir [lookfor_file $gccpath libio/iostream.list]
195 set libio_src_dir [lookfor_file $srcdir libio/Makefile.in]
196 if { $libio_bin_dir ne "" && $libio_src_dir ne "" } {
197 set libio_src_dir [file dirname $libio_src_dir]
198 set libio_bin_dir [file dirname $libio_bin_dir]
199 # Note - unlike the newlib_include_flags proc above we use the -I
200 # switch to specify the include paths. This is because these headers
201 # are not system headers, and if -isystem were to be used GCC would
202 # generate an implicit extern "C" { ... } surrounding them. This
203 # will break targets which do not define NO_IMPLICIT_EXTERN_C.
204 return " -I$libio_src_dir -I$libio_bin_dir"
205 } else {
206 return ""
210 proc libio_link_flags { args } {
211 if {[isremote host]} {
212 return ""
215 set gccpath "[get_multilibs]"
217 set libio_dir [lookfor_file $gccpath libio/libio.a]
218 if { $libio_dir ne "" } {
219 return "-L[file dirname $libio_dir]"
220 } else {
221 return ""
225 proc g++_include_flags { args } {
226 global srcdir
227 global target_alias
229 if {[isremote host]} {
230 return ""
233 set gccpath [get_multilibs]
234 set libio_dir ""
235 set flags ""
237 set dir [lookfor_file $srcdir libg++]
238 if { $dir ne "" } {
239 # See comment in libio_include_flags about using -I.
240 append flags " -I$dir -I$dir/src"
243 set dir [lookfor_file $srcdir libstdc++-v3]
244 if { $dir ne "" } {
245 append flags " -I$dir/include -I$dir/include/std -I$dir/include/c_std -I$dir/libsupc++"
248 set dir [lookfor_file $gccpath libstdc++-v3]
249 if { $dir ne "" } {
250 append flags " -I$dir/include -I$dir/include/$target_alias"
253 set dir [lookfor_file $srcdir libstdc++]
254 if { $dir ne "" } {
255 append flags " -I$dir -I$dir/stl"
258 return $flags
261 proc g++_link_flags { args } {
262 global srcdir
263 global ld_library_path
265 set gccpath [get_multilibs]
266 set libio_dir ""
267 set flags ""
268 set ld_library_path "."
270 if { $gccpath ne "" } {
271 if {[file exists [file join $gccpath lib libstdc++.a]]} {
272 append ld_library_path ":$gccpath/lib"
274 if {[file exists [file join $gccpath libg++ libg++.a]]} {
275 append flags "-L$gccpath/libg++ "
276 append ld_library_path ":$gccpath/libg++"
278 if {[file exists [file join $gccpath libstdc++ libstdc++.a]]} {
279 append flags "-L$gccpath/libstdc++ "
280 append ld_library_path ":$gccpath/libstdc++"
282 if {[file exists [file join $gccpath libstdc++-v3 src .libs libstdc++.a]]} {
283 append flags "-L$gccpath/libstdc++-v3/src/.libs "
284 append ld_library_path ":$gccpath/libstdc++-v3/src/.libs"
286 if {[file exists [file join $gccpath libiberty libiberty.a]]} {
287 append flags "-L$gccpath/libiberty "
289 if {[file exists [file join $gccpath librx librx.a]]} {
290 append flags "-L$gccpath/librx "
292 } else {
293 global tool_root_dir
295 set libgpp [lookfor_file $tool_root_dir libg++]
296 if { $libgpp ne "" } {
297 append flags "-L$libgpp "
298 append ld_library_path ":$libgpp"
300 set libstdcpp [lookfor_file $tool_root_dir libstdc++]
301 if { $libstdcpp ne "" } {
302 append flags "-L$libstdcpp "
303 append ld_library_path ":$libstdcpp"
305 set libiberty [lookfor_file $tool_root_dir libiberty]
306 if { $libiberty ne "" } {
307 append flags "-L$libiberty "
309 set librx [lookfor_file $tool_root_dir librx]
310 if { $librx ne "" } {
311 append flags "-L$librx "
314 return $flags
317 proc libstdc++_include_flags { args } {
318 global srcdir
319 global target_alias
321 if {[isremote host]} {
322 return ""
325 set gccpath [get_multilibs]
326 set libio_dir ""
327 set flags ""
329 set dir [lookfor_file $srcdir libstdc++-v3]
330 if { $dir ne "" } {
331 # See comment in libio_include_flags about using -I.
332 append flags " -I$dir/include -I$dir/include/std -I$dir/include/c_std -I$dir/libsupc++"
335 set gccpath [get_multilibs]
337 set dir [lookfor_file $gccpath libstdc++-v3]
338 if { $dir ne "" } {
339 append flags " -I$dir/include -I$dir/include/$target_alias"
342 set dir [lookfor_file $srcdir libstdc++]
343 if { $dir ne "" } {
344 append flags " -I$dir -I$dir/stl"
347 return $flags
350 proc libstdc++_link_flags { args } {
351 global srcdir
352 global ld_library_path
354 set gccpath [get_multilibs]
355 set libio_dir ""
356 set flags ""
358 if { $gccpath ne "" } {
359 if {[file exists [file join $gccpath libstdc++ libstdc++.a]]} {
360 append flags "-L$gccpath/libstdc++ "
361 append ld_library_path ":$gccpath/libstdc++"
363 if {[file exists [file join $gccpath libiberty libiberty.a]]} {
364 append flags "-L$gccpath/libiberty "
366 if {[file exists [file join $gccpath librx librx.a]]} {
367 append flags "-L$gccpath/librx "
369 } else {
370 global tool_root_dir
372 set libstdcpp [lookfor_file $tool_root_dir libstdc++]
373 if { $libstdcpp ne "" } {
374 append flags "-L$libstdcpp "
375 append ld_library_path ":$libstdcpp"
377 set libiberty [lookfor_file $tool_root_dir libiberty]
378 if { $libiberty ne "" } {
379 append flags "-L$libiberty "
381 set librx [lookfor_file $tool_root_dir librx]
382 if { $librx ne "" } {
383 append flags "-L$librx "
386 return $flags
389 # Get the list of directories and -m options for gcc. This is kinda bogus that
390 # generic testing software needs support for gcc hardwired in, but to make
391 # testing the GNU tools work right, there didn't seem to be any other way.
393 proc get_multilibs { args } {
394 global target_alias
395 global board
396 global board_info
398 # if we're on a remote host, we can't search for the file, so we can only
399 # use an installed compiler, so we don't add any paths here.
400 if {[isremote host]} {
401 return ""
404 if {[info exists board]} {
405 set target_board $board
406 } else {
407 set target_board [target_info name]
410 if { [llength $args] == 0 } {
411 if {[board_info $target_board exists multitop]} {
412 return "[board_info $target_board multitop]"
415 set board_info($target_board,multitop) ""
418 if { [board_info $target_board exists compiler] } {
419 set compiler [board_info $target_board compiler]
420 } else {
421 set compiler [find_gcc]
424 if { $compiler eq "" } {
425 return ""
428 foreach x $compiler {
429 if {[regexp "^-B" $x]} {
430 regsub "^-B" $x "" comp_base_dir
431 set comp_base_dir [file dirname $comp_base_dir]
432 break
436 regexp "/.* " $compiler compiler
437 set compiler [string trimright $compiler " "]
438 verbose "compiler is $compiler"
440 if { [which $compiler] == 0 } {
441 return ""
444 if { [llength $args] > 0 } {
445 set mopts [lindex $args 0]
446 } else {
447 if { [board_info $target_board exists multilib_flags] } {
448 set mopts [board_info $target_board multilib_flags]
449 } else {
450 set mopts ""
454 set default_multilib [exec $compiler --print-multi-lib]
455 set default_multilib [lindex $default_multilib 0]
456 set extra [string trimleft $default_multilib ".;@@"]
458 # extract the options and their directory names as know by gcc
459 foreach i "[exec $compiler --print-multi-lib]" {
460 if {$extra ne ""} {
461 # string trimright would do the wrong thing if we included
462 # the leading @@ in $extra
463 set i [string trimright $i $extra]
464 set i [string trimright $i "@@"]
466 set opts ""
467 set dir ""
468 regexp -- "\[a-z0-9=/\.-\]*;" $i dir
469 set dir [string trimright $dir "\;@"]
470 regexp -- "\;@*\[\@a-zA-Z0-9=/\.-\]*" $i opts
471 set opts [split [string trimleft $opts "\;@@"] "@@"]
472 lappend multilibs "$dir {$opts }"
474 # If args contains arguments don't use the first one as
475 # multilib option unless it qualifies as a multilib option.
476 if { [llength $args] > 0 } {
477 set override_opt [lindex $args 0]
478 foreach j $opts {
479 if {$j == $override_opt} {
480 set mopts $override_opt
486 regsub "^-" $mopts "" moptions
487 regsub -all " -" $moptions " " dirty_moptions
488 set moptions ""
489 foreach x [split $dirty_moptions " "] {
490 if { $x ne "" && [lsearch -exact $moptions $x] < 0 } {
491 lappend moptions $x
495 if {![info exists comp_base_dir]} {
496 set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname [exec $compiler --print-prog-name=cc1]]]]]]
499 # search for the top level multilib directory
500 set multitop [lookfor_file $comp_base_dir $target_alias]
501 if { $multitop eq "" } {
502 set multitop [lookfor_file $comp_base_dir "libraries"]
503 if { $multitop eq "" } {
504 set multitop "[lookfor_file $comp_base_dir gcc/xgcc]"
505 if { $multitop ne "" } {
506 set multitop [file dirname [file dirname $multitop]]
507 } else {
508 return ""
513 set gccpath [eval exec $compiler --print-multi-directory $mopts]
514 set gccpath [lindex $gccpath 0]
515 if { $gccpath ne "" } {
516 verbose "GCC path is $gccpath"
517 if { [llength $args] == 0 } {
518 set board_info($target_board,multitop) $multitop/$gccpath
520 return $multitop/$gccpath
523 # extract the MULTILIB_MATCHES from dumpspecs
524 set multimatches ""
525 set lines [split [exec $compiler -dumpspecs] "\n"]
526 for {set i 0} {$i <= [llength $lines] - 1} {incr i 1} {
527 if {"*multilib_matches:" eq "[lindex $lines $i]"} {
528 set multimatches [lindex $lines [expr {$i + 1}]]
529 break
532 # if we find some
533 if {$multimatches ne ""} {
534 # Split it into a list of pairs. If an moptions are the first
535 # of a pair, then replace it with the second. If an moption
536 # is not in multimatches, we assume it's not a multilib option
538 set splitmatches [split $multimatches ";"]
539 set multimatches ""
540 foreach i $splitmatches {
541 lappend multimatches [split $i " "]
543 verbose "multimatches: $multimatches" 3
545 verbose "options before multimatches: $moptions" 3
546 set toptions $moptions
547 set moptions ""
548 foreach i $toptions {
549 foreach j $multimatches {
550 verbose "comparing [lindex $j 0] == $i" 3
551 if {[lindex $j 0] == $i} {
552 lappend moptions [lindex $j 1]
556 verbose "options after multimatches: $moptions" 3
559 # make a list of -m<foo> options from the various compiler config variables
560 set gccpath ""
562 # compare the lists of gcc options with the list of support multilibs
563 verbose "Supported multilibs are: $multilibs" 3
564 set best 0
565 foreach i $multilibs {
566 set hits 0
567 set opts [lindex $i 1]
568 if { [llength $opts] <= [llength $moptions] } {
569 foreach j $moptions {
570 # see if all the -m<foo> options match any of the multilibs
571 verbose "Looking in $i for $j" 3
572 if { [lsearch -exact $opts $j] >= 0 } {
573 incr hits
577 if { $hits > $best } {
578 verbose "[lindex $i 0] is better, using as gcc path" 2
579 set gccpath "[lindex $i 0]"
580 set best $hits
584 if {![info exists multitop]} {
585 return ""
588 verbose "gccpath is $gccpath" 3
590 if {[file exists [file join $multitop $gccpath]]} {
591 verbose "GCC path is $multitop/$gccpath" 3
592 if { [llength $args] == 0 } {
593 set board_info($target_board,multitop) $multitop/$gccpath
595 return $multitop/$gccpath
596 } else {
597 verbose "GCC path is $multitop" 3
598 if { [llength $args] == 0 } {
599 set board_info($target_board,multitop) $multitop
601 return $multitop
605 proc find_binutils_prog { name } {
606 global tool_root_dir
608 if {![isremote host]} {
610 set file [lookfor_file $tool_root_dir $name]
611 if { $file eq "" } {
612 set file [lookfor_file $tool_root_dir $name-new]
614 if { $file eq "" } {
615 set file [lookfor_file $tool_root_dir binutils/$name]
617 if { $file eq "" } {
618 set file [lookfor_file $tool_root_dir binutils/$name-new]
620 if { $file ne "" } {
621 set NAME $file
622 } else {
623 set NAME [transform $name]
625 } else {
626 set NAME [transform $name]
628 return $NAME
631 proc find_gcc {} {
632 global tool_root_dir
634 if {![isremote host]} {
635 set file [lookfor_file $tool_root_dir xgcc]
636 if { $file eq "" } {
637 set file [lookfor_file $tool_root_dir gcc/xgcc]
639 if { $file ne "" } {
640 set CC "$file -B[file dirname $file]/"
641 } else {
642 set CC [transform gcc]
644 } else {
645 set CC [transform gcc]
647 return $CC
650 proc find_gcj {} {
651 global tool_root_dir
653 if {![isremote host]} {
654 set file [lookfor_file $tool_root_dir gcj]
655 if { $file eq "" } {
656 set file [lookfor_file $tool_root_dir gcc/gcj]
658 if { $file ne "" } {
659 set CC "$file -B[file dirname $file]/"
660 } else {
661 set CC [transform gcj]
663 } else {
664 set CC [transform gcj]
666 return $CC
669 proc find_g++ {} {
670 global tool_root_dir
672 if {![isremote host]} {
673 set file [lookfor_file $tool_root_dir xg++]
674 if { $file eq "" } {
675 set file [lookfor_file $tool_root_dir gcc/xg++]
677 if { $file eq "" } {
678 set file [lookfor_file $tool_root_dir g++]
680 if { $file ne "" } {
681 set CC "$file -B[file dirname $file]/"
682 } else {
683 set CC [transform g++]
685 } else {
686 set CC [transform g++]
688 return $CC
691 proc find_gdc {} {
692 global tool_root_dir
694 if {![isremote host]} {
695 set file [lookfor_file $tool_root_dir gdc]
696 if { $file eq "" } {
697 set file [lookfor_file $tool_root_dir gcc/gdc]
699 if { $file ne "" } {
700 set CC "$file -B[file dirname $file]/"
701 } else {
702 set CC [transform gdc]
704 } else {
705 set CC [transform gdc]
707 return $CC
710 proc find_g77 {} {
711 global tool_root_dir
713 if {![isremote host]} {
714 set file [lookfor_file $tool_root_dir g77]
715 if { $file eq "" } {
716 set file [lookfor_file $tool_root_dir gcc/g77]
718 if { $file ne "" } {
719 set CC "$file -B[file dirname $file]/"
720 } else {
721 set CC [transform g77]
723 } else {
724 set CC [transform g77]
726 return $CC
729 proc find_gfortran {} {
730 global tool_root_dir
732 if {![isremote host]} {
733 set file [lookfor_file $tool_root_dir gfortran]
734 if { $file eq "" } {
735 set file [lookfor_file $tool_root_dir gcc/gfortran]
737 if { $file ne "" } {
738 set CC "$file -B[file dirname $file]/"
739 } else {
740 set CC [transform gfortran]
742 } else {
743 set CC [transform gfortran]
745 return $CC
748 proc find_gnatmake {} {
749 global tool_root_dir
751 if {![isremote host]} {
752 set file [lookfor_file $tool_root_dir gnatmake]
753 if { $file eq "" } {
754 set file [lookfor_file $tool_root_dir gcc/gnatmake]
756 if { $file ne "" } {
757 set root [file dirname $file]
758 set CC "$file -I$root/ada/rts --GCC=$root/xgcc --GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink -cargs -B$root -largs --GCC=$root/xgcc -B$root -margs"
759 } else {
760 set CC [transform gnatmake]
762 } else {
763 set CC [transform gnatmake]
765 return $CC
768 proc find_go {} {
769 global tool_root_dir
771 set GO ""
773 if {![is_remote host]} {
774 set file [lookfor_file $tool_root_dir gccgo]
775 if { $file ne "" } {
776 set root [file dirname $file]
777 set GO "$file -B$root/gcc/"
781 if { $GO eq "" } {
782 set GO [transform gccgo]
785 return $GO
788 proc find_go_linker {} {
789 return [find_go]
792 proc find_rustc {} {
793 global tool_root_dir
794 if {![is_remote host]} {
795 set rustc [lookfor_file $tool_root_dir rustc]
796 if {$rustc eq ""} {
797 set rustc rustc
799 } else {
800 set rustc ""
802 if {$rustc ne ""} {
803 append rustc " --color never"
805 return $rustc
808 proc find_nm {} {
809 global tool_root_dir
811 set NM ""
812 if {![isremote host]} {
813 set NM [lookfor_file $tool_root_dir nm-new]
814 if {$NM eq ""} {
815 set NM [lookfor_file $tool_root_dir binutils/nm-new]
818 if { $NM eq ""} {
819 set NM [transform nm]
821 return $NM
824 proc process_multilib_options { args } {
825 global board
826 global board_variant_list
827 global is_gdb_remote
829 set is_gdb_remote 0
831 if {[board_info $board exists multilib_flags]} {
832 return
834 eval add_multilib_option $args
836 set multilib_flags ""
838 foreach x $board_variant_list {
839 regsub -all "^\[ \t\]*" $x "" x
840 regsub -all "\[ \t\]*$" $x "" x
842 if { $x eq "" } {
843 continue
845 switch -glob -- $x {
846 "aout" {
847 set_board_info obj_format "a.out"
849 "elf" {
850 set_board_info obj_format "elf"
852 "pe" {
853 set_board_info obj_format "pe"
855 "ecoff" {
856 set_board_info obj_format "ecoff"
858 "stabs" {
859 set_board_info debug_flags "-gstabs"
861 "dwarf2" {
862 set_board_info debug_flags "-gdwarf2"
864 "gdb:*=*" {
865 regsub "^gdb:\[^=\]*=(.*)$" $x "\\1" value
866 regsub "^gdb:(\[^=\]*)=.*$" $x "\\1" variable
867 set_board_info $variable $value
869 "gdb*remote" {
870 set is_gdb_remote 1
872 "little*endian" -
873 "el" -
874 "EL" {
875 append multilib_flags " -EL"
877 "big*endian" -
878 "eb" -
879 "EB" {
880 append multilib_flags " -EB"
882 "soft*float" {
883 append multilib_flags " -msoft-float"
885 "-*" {
886 append multilib_flags " $x"
888 default {
889 append multilib_flags " -m$x"
893 set_board_info multilib_flags $multilib_flags
896 proc add_multilib_option { args } {
897 global board_variant_list
899 if {![info exists board_variant_list]} {
900 set board_variant_list ""
902 set board_variant_list [concat $args $board_variant_list]
905 proc find_gas { } {
906 global tool_root_dir
908 set AS ""
910 if {![isremote host]} {
911 set AS [lookfor_file $tool_root_dir as-new]
912 if { $AS eq "" } {
913 set AS [lookfor_file $tool_root_dir gas/as-new]
916 if { $AS eq "" } {
917 set AS [transform as]
919 return $AS
922 proc find_ld { } {
923 global tool_root_dir
925 set LD ""
927 if {![isremote host]} {
928 set LD [lookfor_file $tool_root_dir ld-new]
929 if { $LD eq "" } {
930 set LD [lookfor_file $tool_root_dir ld/ld-new]
933 if { $LD eq "" } {
934 set LD [transform ld]
936 return $LD
939 proc build_wrapper { gluefile } {
940 global libdir
941 global tool
943 if {[target_info exists wrap_m68k_aout]} {
944 set flags "additional_flags=-DWRAP_M68K_AOUT"
945 set result ""
946 } elseif {[target_info exists uses_underscores]} {
947 set flags "additional_flags=-DUNDERSCORES"
948 set result "-Wl,-wrap,_exit -Wl,-wrap,__exit -Wl,-wrap,_main -Wl,-wrap,_abort"
950 } else {
951 set flags ""
952 if {[target_info exists is_vxworks]} {
953 set flags "additional_flags=-DVXWORKS"
954 set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort"
955 } else {
956 set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort"
959 if {[target_info exists wrap_compile_flags]} {
960 lappend flags "additional_flags=[target_info wrap_compile_flags]"
962 if { [target_compile $libdir/testglue.c $gluefile object $flags] eq "" } {
963 set gluefile [remote_download host $gluefile ${tool}_tg.o]
964 return [list $gluefile $result]
965 } else {
966 return ""
971 proc winsup_include_flags { args } {
972 global srcdir
974 if {[isnative]} {
975 return ""
978 if {[isremote host]} {
979 return ""
982 set gccpath "[get_multilibs]"
984 if {[file exists [file join $gccpath winsup]]} {
985 verbose "Winsup path is $gccpath/winsup"
987 set winsup_dir [lookfor_file $srcdir winsup/include/windows.h]
988 if { $winsup_dir ne "" } {
989 set winsup_dir [file dirname $winsup_dir]
990 # See comment in libio_include_flags about using -I.
991 return " -I$winsup_dir"
994 verbose "No winsup support for this target"
998 # Find the winsup libraries in the current source tree.
1000 proc winsup_link_flags { args } {
1001 # libgloss doesn't work native
1002 if {[isnative]} {
1003 return ""
1006 # if we're on a remote host, we can't search for the file, so we can only
1007 # use an installed compiler, so we don't add any paths here.
1008 if {[isremote host]} {
1009 return ""
1012 set gccpath "[get_multilibs]"
1014 verbose "Looking for $gccpath/winsup"
1015 if {[file exists [file join $gccpath winsup]]} {
1016 verbose "Winsup path is $gccpath/newlib"
1017 return "-B$gccpath/winsup/ -L$gccpath/winsup"
1018 } else {
1019 verbose "No winsup support for this target"
1020 return ""