OSDN Git Service

2e91a161eeb84772651e65fe3b82237d15217b7d
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / target-supports.exp
1 #   Copyright (C) 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
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 2 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, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile some code and return the messages printed by the compiler.
23 #
24 # BASENAME is a basename to use for temporary files.
25 # TYPE is the type of compilation to perform (see target_compile).
26 # CONTENTS gives the contents of the input file.
27 # The rest is optional:
28 # OPTIONS: additional compiler options to use.
29 proc get_compiler_messages {basename type contents args} {
30     global tool
31
32     if { [llength $args] > 0 } {
33         set options "additional_flags=[lindex $args 0]"
34     } else {
35         set options ""
36     }
37
38     set src ${basename}[pid].c
39     switch $type {
40         assembly { set output ${basename}[pid].s }
41         object { set output ${basename}[pid].o }
42     }
43     set f [open $src "w"]
44     puts $f $contents
45     close $f
46     set lines [${tool}_target_compile $src $output $type "$options"]
47     file delete $src
48     remote_file build delete $output
49
50     return $lines
51 }
52
53 proc current_target_name { } {
54     global target_info
55     if [info exists target_info(target,name)] {
56         set answer $target_info(target,name)
57     } else {
58         set answer ""
59     }
60     return $answer
61 }
62
63 ###############################
64 # proc check_weak_available { }
65 ###############################
66
67 # weak symbols are only supported in some configs/object formats
68 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
69
70 proc check_weak_available { } {
71     global target_triplet
72     global target_cpu
73
74     # All mips targets should support it
75
76     if { [ string first "mips" $target_cpu ] >= 0 } {
77         return 1
78     }
79
80     # All solaris2 targets should support it
81
82     if { [regexp ".*-solaris2.*" $target_triplet] } {
83         return 1
84     }
85
86     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
87
88     if { [regexp "alpha.*osf.*" $target_triplet] } {
89         return 1
90     }
91
92     # Windows targets Cygwin and MingW32 support it
93
94     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
95         return 1
96     }
97
98     # HP-UX 10.X doesn't support it
99
100     if { [regexp "hppa.*hpux10" $target_triplet] } {
101         return 0
102     }
103
104     # ELF and ECOFF support it. a.out does with gas/gld but may also with
105     # other linkers, so we should try it
106
107     set objformat [gcc_target_object_format]
108
109     switch $objformat {
110         elf      { return 1 }
111         ecoff    { return 1 }
112         a.out    { return 1 }
113         mach-o   { return 1 }
114         som      { return 1 }
115         unknown  { return -1 }
116         default  { return 0 }
117     }
118 }
119
120 ###############################
121 # proc check_visibility_available { what_kind }
122 ###############################
123
124 # The visibility attribute is only support in some object formats
125 # This proc returns 1 if it is supported, 0 if not.
126 # The argument is the kind of visibility, default/protected/hidden/internal.
127
128 proc check_visibility_available { what_kind } {
129     global visibility_available_saved
130     global tool
131     global target_triplet
132
133     # On NetWare, support makes no sense.
134     if { [string match "*-*-netware*" $target_triplet] } {
135         return 0
136     }
137
138     if [string match "" $what_kind] { set what_kind "hidden" }
139
140     if { [info exists visibility_available_saved] } {
141         verbose "Saved result is <$visibility_available_saved>" 1
142         if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
143             return 1
144         } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
145             return 0
146         }
147     }
148
149     set lines [get_compiler_messages visibility object "
150         void f() __attribute__((visibility(\"$what_kind\")));
151         void f() {}
152     "]
153     if [string match "" $lines] then {
154         set answer 1
155         lappend visibility_available_saved $what_kind
156     } else {
157         set answer 0
158         lappend visibility_available_saved "!$what_kind"
159     }
160     return $answer
161 }
162
163 ###############################
164 # proc check_alias_available { }
165 ###############################
166
167 # Determine if the target toolchain supports the alias attribute.
168
169 # Returns 2 if the target supports aliases.  Returns 1 if the target
170 # only supports weak aliased.  Returns 0 if the target does not
171 # support aliases at all.  Returns -1 if support for aliases could not
172 # be determined.
173
174 proc check_alias_available { } {
175     global alias_available_saved
176     global tool
177
178     if [info exists alias_available_saved] {
179         verbose "check_alias_available  returning saved $alias_available_saved" 2
180     } else {
181         set src alias[pid].c
182         set obj alias[pid].o
183         verbose "check_alias_available  compiling testfile $src" 2
184         set f [open $src "w"]
185         # Compile a small test program.  The definition of "g" is
186         # necessary to keep the Solaris assembler from complaining
187         # about the program.
188         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
189         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
190         close $f
191         set lines [${tool}_target_compile $src $obj object ""]
192         file delete $src
193         remote_file build delete $obj
194
195         if [string match "" $lines] then {
196             # No error messages, everything is OK.
197             set alias_available_saved 2
198         } else {
199             if [regexp "alias definitions not supported" $lines] {
200                 verbose "check_alias_available  target does not support aliases" 2
201
202                 set objformat [gcc_target_object_format]
203
204                 if { $objformat == "elf" } {
205                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
206                     set alias_available_saved -1
207                 } else {
208                     set alias_available_saved 0
209                 }
210             } else {
211                 if [regexp "only weak aliases are supported" $lines] {
212                 verbose "check_alias_available  target supports only weak aliases" 2
213                 set alias_available_saved 1
214                 } else {
215                     set alias_available_saved -1
216                 }
217             }
218         }
219
220         verbose "check_alias_available  returning $alias_available_saved" 2
221     }
222
223     return $alias_available_saved
224 }
225
226 # Returns true if --gc-sections is supported on the target.
227
228 proc check_gc_sections_available { } {
229     global gc_sections_available_saved
230     global tool
231
232     if {![info exists gc_sections_available_saved]} {
233         # Some targets don't support gc-sections despite whatever's
234         # advertised by ld's options.
235         if { [istarget alpha*-*-*]
236              || [istarget ia64-*-*] } {
237             set gc_sections_available_saved 0
238             return 0
239         }
240
241         # Check if the ld used by gcc supports --gc-sections.
242         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
243         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
244         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
245         set ld_output [remote_exec host "$gcc_ld" "--help"]
246         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
247             set gc_sections_available_saved 1
248         } else {
249             set gc_sections_available_saved 0
250         }
251     }
252     return $gc_sections_available_saved
253 }
254
255 # Return true if profiling is supported on the target.
256
257 proc check_profiling_available { test_what } {
258     global profiling_available_saved
259
260     verbose "Profiling argument is <$test_what>" 1
261
262     # These conditions depend on the argument so examine them before
263     # looking at the cache variable.
264
265     # Support for -p on solaris2 relies on mcrt1.o which comes with the
266     # vendor compiler.  We cannot reliably predict the directory where the
267     # vendor compiler (and thus mcrt1.o) is installed so we can't
268     # necessarily find mcrt1.o even if we have it.
269     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
270         return 0
271     }
272
273     # Support for -p on irix relies on libprof1.a which doesn't appear to
274     # exist on any irix6 system currently posting testsuite results.
275     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
276     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
277     if { [istarget mips*-*-irix*]
278     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
279         return 0
280     }
281
282     # Now examine the cache variable.
283     if {![info exists profiling_available_saved]} {
284         # Some targets don't have any implementation of __bb_init_func or are
285         # missing other needed machinery.
286         if { [istarget mmix-*-*]
287              || [istarget arm*-*-eabi*]
288              || [istarget arm*-*-elf]
289              || [istarget arm*-*-symbianelf*]
290              || [istarget powerpc-*-eabi*]
291              || [istarget strongarm*-*-elf]
292              || [istarget xscale*-*-elf]
293              || [istarget cris-*-*]
294              || [istarget h8300-*-*]
295              || [istarget mips*-*-elf]
296              || [istarget xtensa-*-elf]
297              || [istarget *-*-windiss] } {
298             set profiling_available_saved 0
299         } else {
300             set profiling_available_saved 1
301         }
302     }
303
304     return $profiling_available_saved
305 }
306
307 # Return 1 if target has packed layout of structure members by
308 # default, 0 otherwise.  Note that this is slightly different than
309 # whether the target has "natural alignment": both attributes may be
310 # false.
311
312 proc check_effective_target_default_packed { } {
313     global et_default_packed_saved
314     global et_default_packed_target_name
315
316     if { ![info exists et_default_packed_target_name] } {
317         set et_default_packed_target_name ""
318     }
319
320     # If the target has changed since we set the cached value, clear it.
321     set current_target [current_target_name]
322     if { $current_target != $et_default_packed_target_name } {
323         verbose "check_effective_target_default_packed: `$et_default_packed_target_name'" 2
324         set et_default_packed_target_name $current_target
325         if [info exists et_default_packed_saved] {
326             verbose "check_effective_target_default_packed: removing cached result" 2
327             unset et_default_packed_saved
328         }
329     }
330
331     if [info exists et_default_packed_saved] {
332         verbose "check_effective_target_default_packed: using cached result" 2
333     } else {
334         verbose "check_effective_target_default_packed: compiling source" 2
335
336         set et_default_packed_saved \
337             [string match "" [get_compiler_messages default_packed assembly {
338             struct x { char a; long b; } c;
339             int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
340         } ]]
341
342     }
343     verbose "check_effective_target_default_packed: returning $et_default_packed_saved" 2
344     return $et_default_packed_saved
345 }
346
347 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
348 # documentation, where the test also comes from.
349
350 proc check_effective_target_pcc_bitfield_type_matters { } {
351     global et_pcc_bitfield_type_matters_saved
352     global et_pcc_bitfield_type_matters_target_name
353
354     if { ![info exists et_pcc_bitfield_type_matters_target_name] } {
355         set et_pcc_bitfield_type_matters_target_name ""
356     }
357
358     # If the target has changed since we set the cached value, clear it.
359     set current_target [current_target_name]
360     if { $current_target != $et_pcc_bitfield_type_matters_target_name } {
361         verbose "check_effective_target_pcc_bitfield_type_matters: `$et_pcc_bitfield_type_matters_target_name'" 2
362         set et_pcc_bitfield_type_matters_target_name $current_target
363         if [info exists et_pcc_bitfield_type_matters_saved] {
364             verbose "check_effective_target_pcc_bitfield_type_matters: removing cached result" 2
365             unset et_pcc_bitfield_type_matters_saved
366         }
367     }
368
369     if [info exists et_pcc_bitfield_type_matters_saved] {
370         verbose "check_effective_target_pcc_bitfield_type_matters: using cached result" 2
371     } else {
372         verbose "check_effective_target_pcc_bitfield_type_matters: compiling source" 2
373
374         # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
375         # bitfields, but let's stick to the example code from the docs.
376         set et_pcc_bitfield_type_matters_saved \
377             [string match "" [get_compiler_messages pcc_bitfield_type_matters assembly {
378             struct foo1 { char x; char :0; char y; };
379             struct foo2 { char x; int :0; char y; };
380             int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
381         } ]]
382     }
383     verbose "check_effective_target_pcc_bitfield_type_matters: returning $et_pcc_bitfield_type_matters_saved" 2
384     return $et_pcc_bitfield_type_matters_saved
385 }
386
387 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
388 #
389 # This won't change for different subtargets so cache the result.
390
391 proc check_effective_target_tls {} {
392     global et_tls_saved
393
394     if [info exists et_tls_saved] {
395         verbose "check_effective_target_tls: using cached result" 2
396     } else {
397         set et_tls_saved 1
398
399         set src tls[pid].c
400         set asm tls[pid].S
401         verbose "check_effective_target_tls: compiling testfile $src" 2
402         set f [open $src "w"]
403         # Compile a small test program.
404         puts $f "__thread int i;\n"
405         close $f
406
407         # Test for thread-local data supported by the platform.
408         set comp_output \
409             [target_compile $src $asm assembly ""]
410         file delete $src
411         if { [string match "*not supported*" $comp_output] } {
412             set et_tls_saved 0
413         }
414         remove-build-file $asm
415     }
416     verbose "check_effective_target_tls: returning $et_tls_saved" 2
417     return $et_tls_saved
418 }
419
420 # Return 1 if TLS executables can run correctly, 0 otherwise.
421 #
422 # This won't change for different subtargets so cache the result.
423
424 proc check_effective_target_tls_runtime {} {
425     global et_tls_runtime_saved
426
427     if [info exists et_tls_runtime_saved] {
428         verbose "check_effective_target_tls_runtime: using cached result" 2
429     } else {
430         set et_tls_runtime_saved 0
431
432         set src tls_runtime[pid].c
433         set exe tls_runtime[pid].x
434         verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
435         set f [open $src "w"]
436         # Compile a small test program.
437         puts $f "__thread int thr = 0;\n"
438         puts $f "int main(void)\n {\n return thr;\n}"
439         close $f
440
441         set comp_output \
442             [target_compile $src $exe executable ""]
443         file delete $src
444
445         if [string match "" $comp_output] then {
446             # No error messages, everything is OK.
447
448             set result [remote_load target "./$exe" "" ""]
449             set status [lindex $result 0]
450             remote_file build delete $exe
451
452             verbose "check_effective_target_tls_runtime status is <$status>" 2
453
454             if { $status == "pass" } {
455                 set et_tls_runtime_saved 1
456             }
457
458             verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
459         }
460     }
461
462     return $et_tls_runtime_saved
463 }
464
465 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
466 # emitted, 0 otherwise.  Whether a shared library can actually be built is
467 # out of scope for this test.
468 #
469 # When the target name changes, replace the cached result.
470
471 proc check_effective_target_fpic { } {
472     global et_fpic_saved
473     global et_fpic_target_name
474
475     if { ![info exists et_fpic_target_name] } {
476         set et_fpic_target_name ""
477     }
478
479     # If the target has changed since we set the cached value, clear it.
480     set current_target [current_target_name]
481     if { $current_target != $et_fpic_target_name } {
482         verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
483         set et_fpic_target_name $current_target
484         if [info exists et_fpic_saved] {
485             verbose "check_effective_target_fpic: removing cached result" 2
486             unset et_fpic_saved
487         }
488     }
489
490     if [info exists et_fpic_saved] {
491         verbose "check_effective_target_fpic: using cached result" 2
492     } else {
493         verbose "check_effective_target_fpic: compiling source" 2
494
495         # Note that M68K has a multilib that supports -fpic but not
496         # -fPIC, so we need to check both.  We test with a program that
497         # requires GOT references.
498         set et_fpic_saved [string match "" [get_compiler_messages fpic object {
499             extern int foo (void); extern int bar;
500             int baz (void) { return foo () + bar; }
501         } "-fpic"]]
502
503         if { $et_fpic_saved != 0 } {
504             set et_fpic_saved [string match "" [get_compiler_messages fpic object {
505                 extern int foo (void); extern int bar;
506                 int baz (void) { return foo () + bar; }
507             } "-fPIC"]]
508         }
509     }
510     verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
511     return $et_fpic_saved
512 }
513
514 # Return true if iconv is supported on the target. In particular IBM1047.
515
516 proc check_iconv_available { test_what } {
517     global tool
518     global libiconv
519
520     set result ""
521
522     set src iconv[pid].c
523     set exe iconv[pid].x
524     verbose "check_iconv_available compiling testfile $src" 2
525     set f [open $src "w"]
526     # Compile a small test program.
527     puts $f "#include <iconv.h>\n"
528     puts $f "int main (void)\n {\n iconv_t cd; \n"
529     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
530     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
531     puts $f "return 0;\n}"
532     close $f
533
534     # If the tool configuration file has not set libiconv, try "-liconv"
535     if { ![info exists libiconv] } {
536         set libiconv "-liconv"
537     }
538     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
539     file delete $src
540
541     if [string match "" $lines] then {
542         # No error messages, everything is OK.
543
544         set result [${tool}_load "./$exe" "" ""]
545         set status [lindex $result 0]
546         remote_file build delete $exe
547
548         verbose "check_iconv_available status is <$status>" 2
549
550         if { $status == "pass" } then {
551             return 1
552         }
553     }
554
555     return 0
556 }
557
558 # Return true if named sections are supported on this target.
559 # This proc does not cache results, because the answer may vary
560 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
561 # the same test run.
562 proc check_named_sections_available { } {
563     verbose "check_named_sections_available: compiling source" 2
564     set answer [string match "" [get_compiler_messages named object {
565         int __attribute__ ((section("whatever"))) foo;
566     }]]
567     verbose "check_named_sections_available: returning $answer" 2
568     return $answer
569 }
570
571 # Return 1 if the target supports Fortran real kinds larger than real(8),
572 # 0 otherwise.
573 #
574 # When the target name changes, replace the cached result.
575
576 proc check_effective_target_fortran_large_real { } {
577     global et_fortran_large_real_saved
578     global et_fortran_large_real_target_name
579     global tool
580
581     if { ![info exists et_fortran_large_real_target_name] } {
582         set et_fortran_large_real_target_name ""
583     }
584
585     # If the target has changed since we set the cached value, clear it.
586     set current_target [current_target_name]
587     if { $current_target != $et_fortran_large_real_target_name } {
588         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
589         set et_fortran_large_real_target_name $current_target
590         if [info exists et_fortran_large_real_saved] {
591             verbose "check_effective_target_fortran_large_real: removing cached result" 2
592             unset et_fortran_large_real_saved
593         }
594     }
595
596     if [info exists et_fortran_large_real_saved] {
597         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
598     } else {
599         set et_fortran_large_real_saved 0
600
601         # Set up, compile, and execute a test program using large real
602         # kinds.  Include the current process ID in the file names to
603         # prevent conflicts with invocations for multiple testsuites.
604         set src real[pid].f90
605         set exe real[pid].x
606
607         set f [open $src "w"]
608         puts $f "integer,parameter :: k = &"
609         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
610         puts $f "real(kind=k) :: x"
611         puts $f "x = cos (x);"
612         puts $f "end"
613         close $f
614
615         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
616         set lines [${tool}_target_compile $src $exe executable ""]
617         file delete $src
618
619         if [string match "" $lines] then {
620             # No error message, compilation succeeded.
621             set et_fortran_large_real_saved 1
622         }
623     }
624
625     return $et_fortran_large_real_saved
626 }
627
628 # Return 1 if the target supports Fortran integer kinds larger than
629 # integer(8), 0 otherwise.
630 #
631 # When the target name changes, replace the cached result.
632
633 proc check_effective_target_fortran_large_int { } {
634     global et_fortran_large_int_saved
635     global et_fortran_large_int_target_name
636     global tool
637
638     if { ![info exists et_fortran_large_int_target_name] } {
639         set et_fortran_large_int_target_name ""
640     }
641
642     # If the target has changed since we set the cached value, clear it.
643     set current_target [current_target_name]
644     if { $current_target != $et_fortran_large_int_target_name } {
645         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
646         set et_fortran_large_int_target_name $current_target
647         if [info exists et_fortran_large_int_saved] {
648             verbose "check_effective_target_fortran_large_int: removing cached result" 2
649             unset et_fortran_large_int_saved
650         }
651     }
652
653     if [info exists et_fortran_large_int_saved] {
654         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
655     } else {
656         set et_fortran_large_int_saved 0
657
658         # Set up, compile, and execute a test program using large integer
659         # kinds.  Include the current process ID in the file names to
660         # prevent conflicts with invocations for multiple testsuites.
661         set src int[pid].f90
662         set exe int[pid].x
663
664         set f [open $src "w"]
665         puts $f "integer,parameter :: k = &"
666         puts $f "  selected_int_kind (range (0_8) + 1)"
667         puts $f "integer(kind=k) :: i"
668         puts $f "end"
669         close $f
670
671         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
672         set lines [${tool}_target_compile $src $exe executable ""]
673         file delete $src
674
675         if [string match "" $lines] then {
676             # No error message, compilation succeeded.
677             set et_fortran_large_int_saved 1
678         }
679     }
680
681     return $et_fortran_large_int_saved
682 }
683
684 # Return 1 if we can statically link libgfortran, 0 otherwise.
685 #
686 # When the target name changes, replace the cached result.
687
688 proc check_effective_target_static_libgfortran { } {
689     global et_static_libgfortran
690     global et_static_libgfortran_target_name
691     global tool
692
693     if { ![info exists et_static_libgfortran_target_name] } {
694        set et_static_libgfortran_target_name ""
695     }
696
697     # If the target has changed since we set the cached value, clear it.
698     set current_target [current_target_name]
699     if { $current_target != $et_static_libgfortran_target_name } {
700        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
701        set et_static_libgfortran_target_name $current_target
702        if [info exists et_static_libgfortran_saved] {
703            verbose "check_effective_target_static_libgfortran: removing cached result" 2
704            unset et_static_libgfortran_saved
705        }
706     }
707
708     if [info exists et_static_libgfortran_saved] {
709        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
710     } else {
711        set et_static_libgfortran_saved 0
712
713        # Set up, compile, and execute a test program using static linking.
714        # Include the current process ID in the file names to prevent
715        # conflicts with invocations for multiple testsuites.
716        set opts "additional_flags=-static"
717        set src static[pid].f
718        set exe static[pid].x
719
720        set f [open $src "w"]
721        puts $f "      print *, 'test'"
722        puts $f "      end"
723        close $f
724
725        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
726        set lines [${tool}_target_compile $src $exe executable "$opts"]
727        file delete $src
728
729        if [string match "" $lines] then {
730            # No error message, compilation succeeded.
731            set et_static_libgfortran_saved 1
732        }
733     }
734
735     return $et_static_libgfortran_saved
736 }
737
738 # Return 1 if the target supports executing AltiVec instructions, 0
739 # otherwise.  Cache the result.
740
741 proc check_vmx_hw_available { } {
742     global vmx_hw_available_saved
743     global tool
744
745     if [info exists vmx_hw_available_saved] {
746         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
747     } else {
748         set vmx_hw_available_saved 0
749
750         # Some simulators are known to not support VMX instructions.
751         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
752             verbose "check_hw_available  returning 0" 2
753             return $vmx_hw_available_saved
754         }
755
756         # Set up, compile, and execute a test program containing VMX
757         # instructions.  Include the current process ID in the file
758         # names to prevent conflicts with invocations for multiple
759         # testsuites.
760         set src vmx[pid].c
761         set exe vmx[pid].x
762
763         set f [open $src "w"]
764         puts $f "int main() {"
765         puts $f "#ifdef __MACH__"
766         puts $f "  asm volatile (\"vor v0,v0,v0\");"
767         puts $f "#else"
768         puts $f "  asm volatile (\"vor 0,0,0\");"
769         puts $f "#endif"
770         puts $f "  return 0; }"
771         close $f
772
773         # Most targets don't require special flags for this test case, but
774         # Darwin does.
775         if [istarget *-*-darwin*] {
776           set opts "additional_flags=-maltivec"
777         } else {
778           set opts ""
779         }
780
781         verbose "check_vmx_hw_available  compiling testfile $src" 2
782         set lines [${tool}_target_compile $src $exe executable "$opts"]
783         file delete $src
784
785         if [string match "" $lines] then {
786             # No error message, compilation succeeded.
787             set result [${tool}_load "./$exe" "" ""]
788             set status [lindex $result 0]
789             remote_file build delete $exe
790             verbose "check_vmx_hw_available testfile status is <$status>" 2
791
792             if { $status == "pass" } then {
793                 set vmx_hw_available_saved 1
794             }
795         } else {
796             verbose "check_vmx_hw_availalble testfile compilation failed" 2
797         }
798     }
799
800     return $vmx_hw_available_saved
801 }
802
803 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
804 # complex float arguments.  This affects gfortran tests that call cabsf
805 # in libm built by an earlier compiler.  Return 1 if libm uses the same
806 # argument passing as the compiler under test, 0 otherwise.
807 #
808 # When the target name changes, replace the cached result.
809
810 proc check_effective_target_broken_cplxf_arg { } {
811     global et_broken_cplxf_arg_saved
812     global et_broken_cplxf_arg_target_name
813     global tool
814
815     # Skip the work for targets known not to be affected.
816     if { ![istarget powerpc64-*-linux*] } {
817         return 0
818     } elseif { [is-effective-target ilp32] } {
819         return 0
820     }
821
822     if { ![info exists et_broken_cplxf_arg_target_name] } {
823         set et_broken_cplxf_arg_target_name ""
824     }
825
826     # If the target has changed since we set the cached value, clear it.
827     set current_target [current_target_name]
828     if { $current_target != $et_broken_cplxf_arg_target_name } {
829         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
830         set et_broken_cplxf_arg_target_name $current_target
831         if [info exists et_broken_cplxf_arg_saved] {
832             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
833             unset et_broken_cplxf_arg_saved
834         }
835     }
836
837     if [info exists et_broken_cplxf_arg_saved] {
838         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
839     } else {
840         set et_broken_cplxf_arg_saved 0
841         # This is only known to affect one target.
842         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
843             set et_broken_cplxf_arg_saved 0
844             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
845             return $et_broken_cplxf_arg_saved
846         }
847
848         # Set up, compile, and execute a C test program that calls cabsf.
849         set src cabsf[pid].c
850         set exe cabsf[pid].x
851
852         set f [open $src "w"]
853         puts $f "#include <complex.h>"
854         puts $f "extern void abort (void);"
855         puts $f "float fabsf (float);"
856         puts $f "float cabsf (_Complex float);"
857         puts $f "int main ()"
858         puts $f "{"
859         puts $f "  _Complex float cf;"
860         puts $f "  float f;"
861         puts $f "  cf = 3 + 4.0fi;"
862         puts $f "  f = cabsf (cf);"
863         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
864         puts $f "  return 0;"
865         puts $f "}"
866         close $f
867
868         set lines [${tool}_target_compile $src $exe executable "-lm"]
869         file delete $src
870
871         if [string match "" $lines] {
872             # No error message, compilation succeeded.
873             set result [${tool}_load "./$exe" "" ""]
874             set status [lindex $result 0]
875             remote_file build delete $exe
876
877             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
878
879             if { $status != "pass" } {
880                 set et_broken_cplxf_arg_saved 1
881             }
882         } else {
883             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
884         }
885     }
886     return $et_broken_cplxf_arg_saved
887 }
888
889 proc check_alpha_max_hw_available { } {
890     global alpha_max_hw_available_saved
891     global tool
892
893     if [info exists alpha_max_hw_available_saved] {
894         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
895     } else {
896         set alpha_max_hw_available_saved 0
897
898         # Set up, compile, and execute a test program probing bit 8 of the
899         # architecture mask, which indicates presence of MAX instructions.
900         set src max[pid].c
901         set exe max[pid].x
902
903         set f [open $src "w"]
904         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
905         close $f
906
907         verbose "check_alpha_max_hw_available compiling testfile $src" 2
908         set lines [${tool}_target_compile $src $exe executable ""]
909         file delete $src
910
911         if [string match "" $lines] then {
912             # No error message, compilation succeeded.
913             set result [${tool}_load "./$exe" "" ""]
914             set status [lindex $result 0]
915             remote_file build delete $exe
916             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
917
918             if { $status == "pass" } then {
919                 set alpha_max_hw_available_saved 1
920             }
921         } else {
922             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
923         }
924     }
925
926     return $alpha_max_hw_available_saved
927 }
928
929 # Returns true iff the FUNCTION is available on the target system.
930 # (This is essentially a Tcl implementation of Autoconf's
931 # AC_CHECK_FUNC.)
932
933 proc check_function_available { function } {
934     set var "${function}_available_saved"
935     global $var
936     global tool
937
938     if {![info exists $var]} {
939         # Assume it exists.
940         set $var 1
941         # Check to make sure.
942         set src "function[pid].c"
943         set exe "function[pid].exe"
944
945         set f [open $src "w"]
946         puts $f "int main () { $function (); }"
947         close $f
948
949         set lines [${tool}_target_compile $src $exe executable ""]
950         file delete $src
951         file delete $exe
952
953         if {![string match "" $lines]} then {
954             set $var 0
955             verbose -log "$function is not available"
956         } else {
957             verbose -log "$function is available"
958         }
959     }
960
961     eval return \$$var
962 }
963
964 # Returns true iff "fork" is available on the target system.
965
966 proc check_fork_available {} {
967     return [check_function_available "fork"]
968 }
969
970 # Returns true iff "mkfifo" is available on the target system.
971
972 proc check_mkfifo_available {} {
973     if {[istarget *-*-cygwin*]} {
974        # Cygwin has mkfifo, but support is incomplete.
975        return 0
976      }
977
978     return [check_function_available "mkfifo"]
979 }
980
981 # Return 1 if we're generating 32-bit code using default options, 0
982 # otherwise.
983 #
984 # When the target name changes, replace the cached result.
985
986 proc check_effective_target_ilp32 { } {
987     global et_ilp32_saved
988     global et_ilp32_target_name
989
990     if { ![info exists et_ilp32_target_name] } {
991         set et_ilp32_target_name ""
992     }
993
994     # If the target has changed since we set the cached value, clear it.
995     set current_target [current_target_name]
996     if { $current_target != $et_ilp32_target_name } {
997         verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
998         set et_ilp32_target_name $current_target
999         if { [info exists et_ilp32_saved] } {
1000             verbose "check_effective_target_ilp32: removing cached result" 2
1001             unset et_ilp32_saved
1002         }
1003     }
1004
1005     if [info exists et_ilp32_saved] {
1006         verbose "check-effective_target_ilp32: using cached result" 2
1007     } else {
1008         verbose "check_effective_target_ilp32: compiling source" 2
1009         set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
1010             int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
1011         }]]
1012     }
1013     verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
1014     return $et_ilp32_saved
1015 }
1016
1017 # Return 1 if we're generating 64-bit code using default options, 0
1018 # otherwise.
1019 #
1020 # When the target name changes, replace the cached result.
1021
1022 proc check_effective_target_lp64 { } {
1023     global et_lp64_saved
1024     global et_lp64_target_name
1025
1026     if { ![info exists et_lp64_target_name] } {
1027         set et_lp64_target_name ""
1028     }
1029
1030     # If the target has changed since we set the cached value, clear it.
1031     set current_target [current_target_name]
1032     if { $current_target != $et_lp64_target_name } {
1033         verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
1034         set et_lp64_target_name $current_target
1035         if [info exists et_lp64_saved] {
1036             verbose "check_effective_target_lp64: removing cached result" 2
1037             unset et_lp64_saved
1038         }
1039     }
1040
1041     if [info exists et_lp64_saved] {
1042         verbose "check_effective_target_lp64: using cached result" 2
1043     } else {
1044         verbose "check_effective_target_lp64: compiling source" 2
1045         set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
1046             int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
1047         }]]
1048     }
1049     verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
1050     return $et_lp64_saved
1051 }
1052
1053 # Return 1 if the target needs a command line argument to enable a SIMD
1054 # instruction set.
1055 #
1056 # This won't change for different subtargets so cache the result.
1057
1058 proc check_effective_target_vect_cmdline_needed { } {
1059     global et_vect_cmdline_needed_saved
1060
1061     if [info exists et_vect_cmdline_needed_saved] {
1062         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1063     } else {
1064         set et_vect_cmdline_needed_saved 1
1065         if { [istarget ia64-*-*]
1066               || [istarget x86_64-*-*] } {
1067            set et_vect_cmdline_needed_saved 0
1068         }
1069     }
1070
1071     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1072     return $et_vect_cmdline_needed_saved
1073 }
1074
1075 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1076 #
1077 # This won't change for different subtargets so cache the result.
1078
1079 proc check_effective_target_vect_int { } {
1080     global et_vect_int_saved
1081
1082     if [info exists et_vect_int_saved] {
1083         verbose "check_effective_target_vect_int: using cached result" 2
1084     } else {
1085         set et_vect_int_saved 0
1086         if { [istarget i?86-*-*]
1087               || [istarget powerpc*-*-*]
1088               || [istarget x86_64-*-*]
1089               || [istarget sparc*-*-*]
1090               || [istarget alpha*-*-*]
1091               || [istarget ia64-*-*] } {
1092            set et_vect_int_saved 1
1093         }
1094     }
1095
1096     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1097     return $et_vect_int_saved
1098 }
1099
1100 # Return 1 is this is an arm target using 32-bit instructions
1101 proc check_effective_target_arm32 { } {
1102     global et_arm32_saved
1103     global et_arm32_target_name
1104     global compiler_flags
1105
1106     if { ![info exists et_arm32_target_name] } {
1107         set et_arm32_target_name ""
1108     }
1109
1110     # If the target has changed since we set the cached value, clear it.
1111     set current_target [current_target_name]
1112     if { $current_target != $et_arm32_target_name } {
1113         verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1114         set et_arm32_target_name $current_target
1115         if { [info exists et_arm32_saved] } {
1116             verbose "check_effective_target_arm32: removing cached result" 2
1117             unset et_arm32_saved
1118         }
1119     }
1120
1121     if [info exists et_arm32_saved] {
1122         verbose "check-effective_target_arm32: using cached result" 2
1123     } else {
1124         set et_arm32_saved 0
1125         if { [istarget arm-*-*]
1126               || [istarget strongarm*-*-*]
1127               || [istarget xscale-*-*] } {
1128             if ![string match "*-mthumb *" $compiler_flags] {
1129                 set et_arm32_saved 1
1130             }
1131         }
1132     }
1133     verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1134     return $et_arm32_saved
1135 }
1136
1137 # Return 1 if the target supports hardware vector shift operation.
1138
1139 proc check_effective_target_vect_shift { } {
1140     global et_vect_shift_saved
1141
1142     if [info exists et_vect_shift_saved] {
1143         verbose "check_effective_target_vect_shift: using cached result" 2
1144     } else {
1145         set et_vect_shift_saved 0
1146         if { [istarget powerpc*-*-*]
1147              || [istarget ia64-*-*]
1148              || [istarget i?86-*-*]
1149              || [istarget x86_64-*-*] } {
1150            set et_vect_shift_saved 1
1151         }
1152     }
1153
1154     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1155     return $et_vect_shift_saved
1156 }
1157
1158 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1159 #
1160 # This can change for different subtargets so do not cache the result.
1161
1162 proc check_effective_target_vect_long { } {
1163     if { [istarget i?86-*-*]
1164          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1165          || [istarget x86_64-*-*]
1166          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1167         set answer 1
1168     } else {
1169         set answer 0
1170     }
1171
1172     verbose "check_effective_target_vect_long: returning $answer" 2
1173     return $answer
1174 }
1175
1176 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1177 #
1178 # This won't change for different subtargets so cache the result.
1179
1180 proc check_effective_target_vect_float { } {
1181     global et_vect_float_saved
1182
1183     if [info exists et_vect_float_saved] {
1184         verbose "check_effective_target_vect_float: using cached result" 2
1185     } else {
1186         set et_vect_float_saved 0
1187         if { [istarget i?86-*-*]
1188               || [istarget powerpc*-*-*]
1189               || [istarget mipsisa64*-*-*]
1190               || [istarget x86_64-*-*]
1191               || [istarget ia64-*-*] } {
1192            set et_vect_float_saved 1
1193         }
1194     }
1195
1196     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1197     return $et_vect_float_saved
1198 }
1199
1200 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1201 #
1202 # This won't change for different subtargets so cache the result.
1203
1204 proc check_effective_target_vect_double { } {
1205     global et_vect_double_saved
1206
1207     if [info exists et_vect_double_saved] {
1208         verbose "check_effective_target_vect_double: using cached result" 2
1209     } else {
1210         set et_vect_double_saved 0
1211         if { [istarget i?86-*-*]
1212               || [istarget x86_64-*-*] } {
1213            set et_vect_double_saved 1
1214         }
1215     }
1216
1217     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1218     return $et_vect_double_saved
1219 }
1220
1221 # Return 1 if the target plus current options does not support a vector
1222 # max instruction on "int", 0 otherwise.
1223 #
1224 # This won't change for different subtargets so cache the result.
1225
1226 proc check_effective_target_vect_no_int_max { } {
1227     global et_vect_no_int_max_saved
1228
1229     if [info exists et_vect_no_int_max_saved] {
1230         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1231     } else {
1232         set et_vect_no_int_max_saved 0
1233         if { [istarget sparc*-*-*]
1234              || [istarget alpha*-*-*] } {
1235             set et_vect_no_int_max_saved 1
1236         }
1237     }
1238     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1239     return $et_vect_no_int_max_saved
1240 }
1241
1242 # Return 1 if the target plus current options does not support a vector
1243 # add instruction on "int", 0 otherwise.
1244 #
1245 # This won't change for different subtargets so cache the result.
1246
1247 proc check_effective_target_vect_no_int_add { } {
1248     global et_vect_no_int_add_saved
1249
1250     if [info exists et_vect_no_int_add_saved] {
1251         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1252     } else {
1253         set et_vect_no_int_add_saved 0
1254         # Alpha only supports vector add on V8QI and V4HI.
1255         if { [istarget alpha*-*-*] } {
1256             set et_vect_no_int_add_saved 1
1257         }
1258     }
1259     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1260     return $et_vect_no_int_add_saved
1261 }
1262
1263 # Return 1 if the target plus current options does not support vector
1264 # bitwise instructions, 0 otherwise.
1265 #
1266 # This won't change for different subtargets so cache the result.
1267
1268 proc check_effective_target_vect_no_bitwise { } {
1269     global et_vect_no_bitwise_saved
1270
1271     if [info exists et_vect_no_bitwise_saved] {
1272         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1273     } else {
1274         set et_vect_no_bitwise_saved 0
1275     }
1276     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1277     return $et_vect_no_bitwise_saved
1278 }
1279
1280 # Return 1 if the target plus current options does not support a vector
1281 # alignment mechanism, 0 otherwise.
1282 #
1283 # This won't change for different subtargets so cache the result.
1284
1285 proc check_effective_target_vect_no_align { } {
1286     global et_vect_no_align_saved
1287
1288     if [info exists et_vect_no_align_saved] {
1289         verbose "check_effective_target_vect_no_align: using cached result" 2
1290     } else {
1291         set et_vect_no_align_saved 0
1292         if { [istarget mipsisa64*-*-*]
1293              || [istarget sparc*-*-*]
1294              || [istarget ia64-*-*] } {
1295             set et_vect_no_align_saved 1
1296         }
1297     }
1298     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1299     return $et_vect_no_align_saved
1300 }
1301
1302 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1303
1304 proc check_effective_target_vect_condition { } {
1305     global et_vect_cond_saved
1306
1307     if [info exists et_vect_cond_saved] {
1308         verbose "check_effective_target_vect_cond: using cached result" 2
1309     } else {
1310         set et_vect_cond_saved 0
1311         if { [istarget powerpc*-*-*]
1312              || [istarget ia64-*-*]
1313              || [istarget i?86-*-*]
1314              || [istarget x86_64-*-*] } {
1315            set et_vect_cond_saved 1
1316         }
1317     }
1318
1319     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1320     return $et_vect_cond_saved
1321 }
1322
1323 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1324
1325 proc check_effective_target_vect_int_mult { } {
1326     global et_vect_int_mult_saved
1327
1328     if [info exists et_vect_int_mult_saved] {
1329         verbose "check_effective_target_vect_int_mult: using cached result" 2
1330     } else {
1331         set et_vect_int_mult_saved 0
1332         if { [istarget powerpc*-*-*]
1333              || [istarget i?86-*-*]
1334              || [istarget x86_64-*-*] } {
1335            set et_vect_int_mult_saved 1
1336         }
1337     }
1338
1339     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1340     return $et_vect_int_mult_saved
1341 }
1342
1343 # Return 1 if the target supports atomic operations on "int" and "long".
1344
1345 proc check_effective_target_sync_int_long { } {
1346     global et_sync_int_long_saved
1347
1348     if [info exists et_sync_int_long_saved] {
1349         verbose "check_effective_target_sync_int_long: using cached result" 2
1350     } else {
1351         set et_sync_int_long_saved 0
1352 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1353 # load-reserved/store-conditional instructions.
1354         if { [istarget ia64-*-*]
1355              || [istarget i?86-*-*]
1356              || [istarget x86_64-*-*]
1357              || [istarget alpha*-*-*] 
1358              || [istarget s390*-*-*] 
1359              || [istarget powerpc*-*-*]
1360              || [istarget sparc64-*-*]
1361              || [istarget sparcv9-*-*] } {
1362            set et_sync_int_long_saved 1
1363         }
1364     }
1365
1366     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1367     return $et_sync_int_long_saved
1368 }
1369
1370 # Return 1 if the target supports atomic operations on "char" and "short".
1371
1372 proc check_effective_target_sync_char_short { } {
1373     global et_sync_char_short_saved
1374
1375     if [info exists et_sync_char_short_saved] {
1376         verbose "check_effective_target_sync_char_short: using cached result" 2
1377     } else {
1378         set et_sync_char_short_saved 0
1379 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1380 # load-reserved/store-conditional instructions.
1381         if { [istarget ia64-*-*]
1382              || [istarget i?86-*-*]
1383              || [istarget x86_64-*-*]
1384              || [istarget alpha*-*-*] 
1385              || [istarget s390*-*-*] 
1386              || [istarget powerpc*-*-*]
1387              || [istarget sparc64-*-*]
1388              || [istarget sparcv9-*-*] } {
1389            set et_sync_char_short_saved 1
1390         }
1391     }
1392
1393     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1394     return $et_sync_char_short_saved
1395 }
1396
1397 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1398 # This can be used with any check_* proc that takes no argument and
1399 # returns only 1 or 0.  It could be used with check_* procs that take
1400 # arguments with keywords that pass particular arguments.
1401
1402 proc is-effective-target { arg } {
1403     set selected 0
1404     if { [info procs check_effective_target_${arg}] != [list] } {
1405         set selected [check_effective_target_${arg}]
1406     } else {
1407         switch $arg {
1408           "vmx_hw"         { set selected [check_vmx_hw_available] }
1409           "named_sections" { set selected [check_named_sections_available] }
1410           "gc_sections"    { set selected [check_gc_sections_available] }
1411           default          { error "unknown effective target keyword `$arg'" }
1412         }
1413     }
1414     verbose "is-effective-target: $arg $selected" 2
1415     return $selected
1416 }
1417
1418 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1419
1420 proc is-effective-target-keyword { arg } {
1421     if { [info procs check_effective_target_${arg}] != [list] } {
1422         return 1
1423     } else {
1424         # These have different names for their check_* procs.
1425         switch $arg {
1426           "vmx_hw"         { return 1 }
1427           "named_sections" { return 1 }
1428           "gc_sections"    { return 1 }
1429           default          { return 0 }
1430         }
1431     }
1432 }