1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
23 # Try to compile some code and return the messages printed by the compiler.
25 # BASENAME is a basename to use for temporary files.
26 # TYPE is the type of compilation to perform (see target_compile).
27 # CONTENTS gives the contents of the input file.
28 # The rest is optional:
29 # OPTIONS: additional compiler options to use.
30 proc get_compiler_messages {basename type contents args} {
33 if { [llength $args] > 0 } {
34 set options "additional_flags=[lindex $args 0]"
39 set src ${basename}[pid].c
41 assembly { set output ${basename}[pid].s }
42 object { set output ${basename}[pid].o }
47 set lines [${tool}_target_compile $src $output $type "$options"]
49 remote_file build delete $output
54 proc current_target_name { } {
56 if [info exists target_info(target,name)] {
57 set answer $target_info(target,name)
64 ###############################
65 # proc check_weak_available { }
66 ###############################
68 # weak symbols are only supported in some configs/object formats
69 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
71 proc check_weak_available { } {
75 # All mips targets should support it
77 if { [ string first "mips" $target_cpu ] >= 0 } {
81 # All solaris2 targets should support it
83 if { [regexp ".*-solaris2.*" $target_triplet] } {
87 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
89 if { [regexp "alpha.*osf.*" $target_triplet] } {
93 # Windows targets Cygwin and MingW32 support it
95 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
99 # HP-UX 10.X doesn't support it
101 if { [regexp "hppa.*hpux10" $target_triplet] } {
105 # ELF and ECOFF support it. a.out does with gas/gld but may also with
106 # other linkers, so we should try it
108 set objformat [gcc_target_object_format]
116 unknown { return -1 }
121 ###############################
122 # proc check_visibility_available { what_kind }
123 ###############################
125 # The visibility attribute is only support in some object formats
126 # This proc returns 1 if it is supported, 0 if not.
127 # The argument is the kind of visibility, default/protected/hidden/internal.
129 proc check_visibility_available { what_kind } {
130 global visibility_available_saved
132 global target_triplet
134 # On NetWare, support makes no sense.
135 if { [istarget *-*-netware*] } {
139 if [string match "" $what_kind] { set what_kind "hidden" }
141 if { [info exists visibility_available_saved] } {
142 verbose "Saved result is <$visibility_available_saved>" 1
143 if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
145 } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
150 set lines [get_compiler_messages visibility object "
151 void f() __attribute__((visibility(\"$what_kind\")));
154 if [string match "" $lines] then {
156 lappend visibility_available_saved $what_kind
159 lappend visibility_available_saved "!$what_kind"
164 ###############################
165 # proc check_alias_available { }
166 ###############################
168 # Determine if the target toolchain supports the alias attribute.
170 # Returns 2 if the target supports aliases. Returns 1 if the target
171 # only supports weak aliased. Returns 0 if the target does not
172 # support aliases at all. Returns -1 if support for aliases could not
175 proc check_alias_available { } {
176 global alias_available_saved
179 if [info exists alias_available_saved] {
180 verbose "check_alias_available returning saved $alias_available_saved" 2
184 verbose "check_alias_available compiling testfile $src" 2
185 set f [open $src "w"]
186 # Compile a small test program. The definition of "g" is
187 # necessary to keep the Solaris assembler from complaining
189 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
190 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
192 set lines [${tool}_target_compile $src $obj object ""]
194 remote_file build delete $obj
196 if [string match "" $lines] then {
197 # No error messages, everything is OK.
198 set alias_available_saved 2
200 if [regexp "alias definitions not supported" $lines] {
201 verbose "check_alias_available target does not support aliases" 2
203 set objformat [gcc_target_object_format]
205 if { $objformat == "elf" } {
206 verbose "check_alias_available but target uses ELF format, so it ought to" 2
207 set alias_available_saved -1
209 set alias_available_saved 0
212 if [regexp "only weak aliases are supported" $lines] {
213 verbose "check_alias_available target supports only weak aliases" 2
214 set alias_available_saved 1
216 set alias_available_saved -1
221 verbose "check_alias_available returning $alias_available_saved" 2
224 return $alias_available_saved
227 # Returns true if --gc-sections is supported on the target.
229 proc check_gc_sections_available { } {
230 global gc_sections_available_saved
233 if {![info exists gc_sections_available_saved]} {
234 # Some targets don't support gc-sections despite whatever's
235 # advertised by ld's options.
236 if { [istarget alpha*-*-*]
237 || [istarget ia64-*-*] } {
238 set gc_sections_available_saved 0
242 # Check if the ld used by gcc supports --gc-sections.
243 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
244 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
245 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
246 set ld_output [remote_exec host "$gcc_ld" "--help"]
247 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
248 set gc_sections_available_saved 1
250 set gc_sections_available_saved 0
253 return $gc_sections_available_saved
256 # Return true if profiling is supported on the target.
258 proc check_profiling_available { test_what } {
259 global profiling_available_saved
261 verbose "Profiling argument is <$test_what>" 1
263 # These conditions depend on the argument so examine them before
264 # looking at the cache variable.
266 # Support for -p on solaris2 relies on mcrt1.o which comes with the
267 # vendor compiler. We cannot reliably predict the directory where the
268 # vendor compiler (and thus mcrt1.o) is installed so we can't
269 # necessarily find mcrt1.o even if we have it.
270 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
274 # Support for -p on irix relies on libprof1.a which doesn't appear to
275 # exist on any irix6 system currently posting testsuite results.
276 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
277 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
278 if { [istarget mips*-*-irix*]
279 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
283 # At present, there is no profiling support on NetWare.
284 if { [istarget *-*-netware*] } {
288 # Now examine the cache variable.
289 if {![info exists profiling_available_saved]} {
290 # Some targets don't have any implementation of __bb_init_func or are
291 # missing other needed machinery.
292 if { [istarget mmix-*-*]
293 || [istarget arm*-*-eabi*]
294 || [istarget arm*-*-elf]
295 || [istarget arm*-*-symbianelf*]
296 || [istarget powerpc-*-eabi*]
297 || [istarget strongarm*-*-elf]
298 || [istarget xscale*-*-elf]
299 || [istarget cris-*-*]
300 || [istarget h8300-*-*]
301 || [istarget mips*-*-elf]
302 || [istarget xtensa-*-elf]
303 || [istarget *-*-windiss] } {
304 set profiling_available_saved 0
306 set profiling_available_saved 1
310 return $profiling_available_saved
313 # Return 1 if target has packed layout of structure members by
314 # default, 0 otherwise. Note that this is slightly different than
315 # whether the target has "natural alignment": both attributes may be
318 proc check_effective_target_default_packed { } {
319 global et_default_packed_saved
320 global et_default_packed_target_name
322 if { ![info exists et_default_packed_target_name] } {
323 set et_default_packed_target_name ""
326 # If the target has changed since we set the cached value, clear it.
327 set current_target [current_target_name]
328 if { $current_target != $et_default_packed_target_name } {
329 verbose "check_effective_target_default_packed: `$et_default_packed_target_name'" 2
330 set et_default_packed_target_name $current_target
331 if [info exists et_default_packed_saved] {
332 verbose "check_effective_target_default_packed: removing cached result" 2
333 unset et_default_packed_saved
337 if [info exists et_default_packed_saved] {
338 verbose "check_effective_target_default_packed: using cached result" 2
340 verbose "check_effective_target_default_packed: compiling source" 2
342 set et_default_packed_saved \
343 [string match "" [get_compiler_messages default_packed assembly {
344 struct x { char a; long b; } c;
345 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
349 verbose "check_effective_target_default_packed: returning $et_default_packed_saved" 2
350 return $et_default_packed_saved
353 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
354 # documentation, where the test also comes from.
356 proc check_effective_target_pcc_bitfield_type_matters { } {
357 global et_pcc_bitfield_type_matters_saved
358 global et_pcc_bitfield_type_matters_target_name
360 if { ![info exists et_pcc_bitfield_type_matters_target_name] } {
361 set et_pcc_bitfield_type_matters_target_name ""
364 # If the target has changed since we set the cached value, clear it.
365 set current_target [current_target_name]
366 if { $current_target != $et_pcc_bitfield_type_matters_target_name } {
367 verbose "check_effective_target_pcc_bitfield_type_matters: `$et_pcc_bitfield_type_matters_target_name'" 2
368 set et_pcc_bitfield_type_matters_target_name $current_target
369 if [info exists et_pcc_bitfield_type_matters_saved] {
370 verbose "check_effective_target_pcc_bitfield_type_matters: removing cached result" 2
371 unset et_pcc_bitfield_type_matters_saved
375 if [info exists et_pcc_bitfield_type_matters_saved] {
376 verbose "check_effective_target_pcc_bitfield_type_matters: using cached result" 2
378 verbose "check_effective_target_pcc_bitfield_type_matters: compiling source" 2
380 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
381 # bitfields, but let's stick to the example code from the docs.
382 set et_pcc_bitfield_type_matters_saved \
383 [string match "" [get_compiler_messages pcc_bitfield_type_matters assembly {
384 struct foo1 { char x; char :0; char y; };
385 struct foo2 { char x; int :0; char y; };
386 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
389 verbose "check_effective_target_pcc_bitfield_type_matters: returning $et_pcc_bitfield_type_matters_saved" 2
390 return $et_pcc_bitfield_type_matters_saved
393 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
395 # This won't change for different subtargets so cache the result.
397 proc check_effective_target_tls {} {
400 if [info exists et_tls_saved] {
401 verbose "check_effective_target_tls: using cached result" 2
407 verbose "check_effective_target_tls: compiling testfile $src" 2
408 set f [open $src "w"]
409 # Compile a small test program.
410 puts $f "__thread int i;\n"
413 # Test for thread-local data supported by the platform.
415 [target_compile $src $asm assembly ""]
417 if { [string match "*not supported*" $comp_output] } {
420 remove-build-file $asm
422 verbose "check_effective_target_tls: returning $et_tls_saved" 2
426 # Return 1 if TLS executables can run correctly, 0 otherwise.
428 # This won't change for different subtargets so cache the result.
430 proc check_effective_target_tls_runtime {} {
431 global et_tls_runtime_saved
433 if [info exists et_tls_runtime_saved] {
434 verbose "check_effective_target_tls_runtime: using cached result" 2
436 set et_tls_runtime_saved 0
438 set src tls_runtime[pid].c
439 set exe tls_runtime[pid].x
440 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
441 set f [open $src "w"]
442 # Compile a small test program.
443 puts $f "__thread int thr = 0;\n"
444 puts $f "int main(void)\n {\n return thr;\n}"
448 [target_compile $src $exe executable ""]
451 if [string match "" $comp_output] then {
452 # No error messages, everything is OK.
454 set result [remote_load target "./$exe" "" ""]
455 set status [lindex $result 0]
456 remote_file build delete $exe
458 verbose "check_effective_target_tls_runtime status is <$status>" 2
460 if { $status == "pass" } {
461 set et_tls_runtime_saved 1
464 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
468 return $et_tls_runtime_saved
471 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
472 # emitted, 0 otherwise. Whether a shared library can actually be built is
473 # out of scope for this test.
475 # When the target name changes, replace the cached result.
477 proc check_effective_target_fpic { } {
479 global et_fpic_target_name
481 if { ![info exists et_fpic_target_name] } {
482 set et_fpic_target_name ""
485 # If the target has changed since we set the cached value, clear it.
486 set current_target [current_target_name]
487 if { $current_target != $et_fpic_target_name } {
488 verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
489 set et_fpic_target_name $current_target
490 if [info exists et_fpic_saved] {
491 verbose "check_effective_target_fpic: removing cached result" 2
496 if [info exists et_fpic_saved] {
497 verbose "check_effective_target_fpic: using cached result" 2
499 verbose "check_effective_target_fpic: compiling source" 2
501 # Note that M68K has a multilib that supports -fpic but not
502 # -fPIC, so we need to check both. We test with a program that
503 # requires GOT references.
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; }
509 if { $et_fpic_saved != 0 } {
510 set et_fpic_saved [string match "" [get_compiler_messages fpic object {
511 extern int foo (void); extern int bar;
512 int baz (void) { return foo () + bar; }
516 verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
517 return $et_fpic_saved
520 # Return true if iconv is supported on the target. In particular IBM1047.
522 proc check_iconv_available { test_what } {
530 verbose "check_iconv_available compiling testfile $src" 2
531 set f [open $src "w"]
532 # Compile a small test program.
533 puts $f "#include <iconv.h>\n"
534 puts $f "int main (void)\n {\n iconv_t cd; \n"
535 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
536 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
537 puts $f "return 0;\n}"
540 # If the tool configuration file has not set libiconv, try "-liconv"
541 if { ![info exists libiconv] } {
542 set libiconv "-liconv"
544 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
547 if [string match "" $lines] then {
548 # No error messages, everything is OK.
550 set result [${tool}_load "./$exe" "" ""]
551 set status [lindex $result 0]
552 remote_file build delete $exe
554 verbose "check_iconv_available status is <$status>" 2
556 if { $status == "pass" } then {
564 # Return true if named sections are supported on this target.
565 # This proc does not cache results, because the answer may vary
566 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
568 proc check_named_sections_available { } {
569 verbose "check_named_sections_available: compiling source" 2
570 set answer [string match "" [get_compiler_messages named object {
571 int __attribute__ ((section("whatever"))) foo;
573 verbose "check_named_sections_available: returning $answer" 2
577 # Return 1 if the target supports Fortran real kinds larger than real(8),
580 # When the target name changes, replace the cached result.
582 proc check_effective_target_fortran_large_real { } {
583 global et_fortran_large_real_saved
584 global et_fortran_large_real_target_name
587 if { ![info exists et_fortran_large_real_target_name] } {
588 set et_fortran_large_real_target_name ""
591 # If the target has changed since we set the cached value, clear it.
592 set current_target [current_target_name]
593 if { $current_target != $et_fortran_large_real_target_name } {
594 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
595 set et_fortran_large_real_target_name $current_target
596 if [info exists et_fortran_large_real_saved] {
597 verbose "check_effective_target_fortran_large_real: removing cached result" 2
598 unset et_fortran_large_real_saved
602 if [info exists et_fortran_large_real_saved] {
603 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
605 set et_fortran_large_real_saved 0
607 # Set up, compile, and execute a test program using large real
608 # kinds. Include the current process ID in the file names to
609 # prevent conflicts with invocations for multiple testsuites.
610 set src real[pid].f90
613 set f [open $src "w"]
614 puts $f "integer,parameter :: k = &"
615 puts $f " selected_real_kind (precision (0.0_8) + 1)"
616 puts $f "real(kind=k) :: x"
617 puts $f "x = cos (x);"
621 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
622 set lines [${tool}_target_compile $src $exe executable ""]
625 if [string match "" $lines] then {
626 # No error message, compilation succeeded.
627 set et_fortran_large_real_saved 1
631 return $et_fortran_large_real_saved
634 # Return 1 if the target supports Fortran integer kinds larger than
635 # integer(8), 0 otherwise.
637 # When the target name changes, replace the cached result.
639 proc check_effective_target_fortran_large_int { } {
640 global et_fortran_large_int_saved
641 global et_fortran_large_int_target_name
644 if { ![info exists et_fortran_large_int_target_name] } {
645 set et_fortran_large_int_target_name ""
648 # If the target has changed since we set the cached value, clear it.
649 set current_target [current_target_name]
650 if { $current_target != $et_fortran_large_int_target_name } {
651 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
652 set et_fortran_large_int_target_name $current_target
653 if [info exists et_fortran_large_int_saved] {
654 verbose "check_effective_target_fortran_large_int: removing cached result" 2
655 unset et_fortran_large_int_saved
659 if [info exists et_fortran_large_int_saved] {
660 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
662 set et_fortran_large_int_saved 0
664 # Set up, compile, and execute a test program using large integer
665 # kinds. Include the current process ID in the file names to
666 # prevent conflicts with invocations for multiple testsuites.
670 set f [open $src "w"]
671 puts $f "integer,parameter :: k = &"
672 puts $f " selected_int_kind (range (0_8) + 1)"
673 puts $f "integer(kind=k) :: i"
677 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
678 set lines [${tool}_target_compile $src $exe executable ""]
681 if [string match "" $lines] then {
682 # No error message, compilation succeeded.
683 set et_fortran_large_int_saved 1
687 return $et_fortran_large_int_saved
690 # Return 1 if we can statically link libgfortran, 0 otherwise.
692 # When the target name changes, replace the cached result.
694 proc check_effective_target_static_libgfortran { } {
695 global et_static_libgfortran
696 global et_static_libgfortran_target_name
699 if { ![info exists et_static_libgfortran_target_name] } {
700 set et_static_libgfortran_target_name ""
703 # If the target has changed since we set the cached value, clear it.
704 set current_target [current_target_name]
705 if { $current_target != $et_static_libgfortran_target_name } {
706 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
707 set et_static_libgfortran_target_name $current_target
708 if [info exists et_static_libgfortran_saved] {
709 verbose "check_effective_target_static_libgfortran: removing cached result" 2
710 unset et_static_libgfortran_saved
714 if [info exists et_static_libgfortran_saved] {
715 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
717 set et_static_libgfortran_saved 0
719 # Set up, compile, and execute a test program using static linking.
720 # Include the current process ID in the file names to prevent
721 # conflicts with invocations for multiple testsuites.
722 set opts "additional_flags=-static"
723 set src static[pid].f
724 set exe static[pid].x
726 set f [open $src "w"]
727 puts $f " print *, 'test'"
731 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
732 set lines [${tool}_target_compile $src $exe executable "$opts"]
735 if [string match "" $lines] then {
736 # No error message, compilation succeeded.
737 set et_static_libgfortran_saved 1
741 return $et_static_libgfortran_saved
744 # Return 1 if the target supports executing AltiVec instructions, 0
745 # otherwise. Cache the result.
747 proc check_vmx_hw_available { } {
748 global vmx_hw_available_saved
751 if [info exists vmx_hw_available_saved] {
752 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
754 set vmx_hw_available_saved 0
756 # Some simulators are known to not support VMX instructions.
757 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
758 verbose "check_hw_available returning 0" 2
759 return $vmx_hw_available_saved
762 # Set up, compile, and execute a test program containing VMX
763 # instructions. Include the current process ID in the file
764 # names to prevent conflicts with invocations for multiple
769 set f [open $src "w"]
770 puts $f "int main() {"
771 puts $f "#ifdef __MACH__"
772 puts $f " asm volatile (\"vor v0,v0,v0\");"
774 puts $f " asm volatile (\"vor 0,0,0\");"
776 puts $f " return 0; }"
779 # Most targets don't require special flags for this test case, but
781 if [istarget *-*-darwin*] {
782 set opts "additional_flags=-maltivec"
787 verbose "check_vmx_hw_available compiling testfile $src" 2
788 set lines [${tool}_target_compile $src $exe executable "$opts"]
791 if [string match "" $lines] then {
792 # No error message, compilation succeeded.
793 set result [${tool}_load "./$exe" "" ""]
794 set status [lindex $result 0]
795 remote_file build delete $exe
796 verbose "check_vmx_hw_available testfile status is <$status>" 2
798 if { $status == "pass" } then {
799 set vmx_hw_available_saved 1
802 verbose "check_vmx_hw_availalble testfile compilation failed" 2
806 return $vmx_hw_available_saved
809 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
810 # complex float arguments. This affects gfortran tests that call cabsf
811 # in libm built by an earlier compiler. Return 1 if libm uses the same
812 # argument passing as the compiler under test, 0 otherwise.
814 # When the target name changes, replace the cached result.
816 proc check_effective_target_broken_cplxf_arg { } {
817 global et_broken_cplxf_arg_saved
818 global et_broken_cplxf_arg_target_name
821 # Skip the work for targets known not to be affected.
822 if { ![istarget powerpc64-*-linux*] } {
824 } elseif { [is-effective-target ilp32] } {
828 if { ![info exists et_broken_cplxf_arg_target_name] } {
829 set et_broken_cplxf_arg_target_name ""
832 # If the target has changed since we set the cached value, clear it.
833 set current_target [current_target_name]
834 if { $current_target != $et_broken_cplxf_arg_target_name } {
835 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
836 set et_broken_cplxf_arg_target_name $current_target
837 if [info exists et_broken_cplxf_arg_saved] {
838 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
839 unset et_broken_cplxf_arg_saved
843 if [info exists et_broken_cplxf_arg_saved] {
844 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
846 set et_broken_cplxf_arg_saved 0
847 # This is only known to affect one target.
848 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
849 set et_broken_cplxf_arg_saved 0
850 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
851 return $et_broken_cplxf_arg_saved
854 # Set up, compile, and execute a C test program that calls cabsf.
858 set f [open $src "w"]
859 puts $f "#include <complex.h>"
860 puts $f "extern void abort (void);"
861 puts $f "float fabsf (float);"
862 puts $f "float cabsf (_Complex float);"
863 puts $f "int main ()"
865 puts $f " _Complex float cf;"
867 puts $f " cf = 3 + 4.0fi;"
868 puts $f " f = cabsf (cf);"
869 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
874 set lines [${tool}_target_compile $src $exe executable "-lm"]
877 if [string match "" $lines] {
878 # No error message, compilation succeeded.
879 set result [${tool}_load "./$exe" "" ""]
880 set status [lindex $result 0]
881 remote_file build delete $exe
883 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
885 if { $status != "pass" } {
886 set et_broken_cplxf_arg_saved 1
889 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
892 return $et_broken_cplxf_arg_saved
895 proc check_alpha_max_hw_available { } {
896 global alpha_max_hw_available_saved
899 if [info exists alpha_max_hw_available_saved] {
900 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
902 set alpha_max_hw_available_saved 0
904 # Set up, compile, and execute a test program probing bit 8 of the
905 # architecture mask, which indicates presence of MAX instructions.
909 set f [open $src "w"]
910 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
913 verbose "check_alpha_max_hw_available compiling testfile $src" 2
914 set lines [${tool}_target_compile $src $exe executable ""]
917 if [string match "" $lines] then {
918 # No error message, compilation succeeded.
919 set result [${tool}_load "./$exe" "" ""]
920 set status [lindex $result 0]
921 remote_file build delete $exe
922 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
924 if { $status == "pass" } then {
925 set alpha_max_hw_available_saved 1
928 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
932 return $alpha_max_hw_available_saved
935 # Returns true iff the FUNCTION is available on the target system.
936 # (This is essentially a Tcl implementation of Autoconf's
939 proc check_function_available { function } {
940 set var "${function}_available_saved"
944 if {![info exists $var]} {
947 # Check to make sure.
948 set src "function[pid].c"
949 set exe "function[pid].exe"
951 set f [open $src "w"]
952 puts $f "int main () { $function (); }"
955 set lines [${tool}_target_compile $src $exe executable ""]
959 if {![string match "" $lines]} then {
961 verbose -log "$function is not available"
963 verbose -log "$function is available"
970 # Returns true iff "fork" is available on the target system.
972 proc check_fork_available {} {
973 return [check_function_available "fork"]
976 # Returns true iff "mkfifo" is available on the target system.
978 proc check_mkfifo_available {} {
979 if {[istarget *-*-cygwin*]} {
980 # Cygwin has mkfifo, but support is incomplete.
984 return [check_function_available "mkfifo"]
987 # Return 1 if we're generating 32-bit code using default options, 0
990 # When the target name changes, replace the cached result.
992 proc check_effective_target_ilp32 { } {
993 global et_ilp32_saved
994 global et_ilp32_target_name
996 if { ![info exists et_ilp32_target_name] } {
997 set et_ilp32_target_name ""
1000 # If the target has changed since we set the cached value, clear it.
1001 set current_target [current_target_name]
1002 if { $current_target != $et_ilp32_target_name } {
1003 verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
1004 set et_ilp32_target_name $current_target
1005 if { [info exists et_ilp32_saved] } {
1006 verbose "check_effective_target_ilp32: removing cached result" 2
1007 unset et_ilp32_saved
1011 if [info exists et_ilp32_saved] {
1012 verbose "check-effective_target_ilp32: using cached result" 2
1014 verbose "check_effective_target_ilp32: compiling source" 2
1015 set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
1016 int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
1019 verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
1020 return $et_ilp32_saved
1023 # Return 1 if we're generating 64-bit code using default options, 0
1026 # When the target name changes, replace the cached result.
1028 proc check_effective_target_lp64 { } {
1029 global et_lp64_saved
1030 global et_lp64_target_name
1032 if { ![info exists et_lp64_target_name] } {
1033 set et_lp64_target_name ""
1036 # If the target has changed since we set the cached value, clear it.
1037 set current_target [current_target_name]
1038 if { $current_target != $et_lp64_target_name } {
1039 verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
1040 set et_lp64_target_name $current_target
1041 if [info exists et_lp64_saved] {
1042 verbose "check_effective_target_lp64: removing cached result" 2
1047 if [info exists et_lp64_saved] {
1048 verbose "check_effective_target_lp64: using cached result" 2
1050 verbose "check_effective_target_lp64: compiling source" 2
1051 set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
1052 int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
1055 verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
1056 return $et_lp64_saved
1059 # Return 1 if the target supports compiling decimal floating point,
1062 proc check_effective_target_dfp_nocache { } {
1063 verbose "check_effective_target_dfp_nocache: compiling source" 2
1064 set ret [string match "" [get_compiler_messages dfp object {
1065 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1067 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1071 proc check_effective_target_dfprt_nocache { } {
1076 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1077 # Set up, compile, and execute a test program containing decimal
1079 set src dfprt[pid].c
1080 set exe dfprt[pid].x
1082 set f [open $src "w"]
1083 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1084 puts $f "int main () { z = x + y; return 0; }"
1087 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1088 set lines [${tool}_target_compile $src $exe executable ""]
1091 if [string match "" $lines] then {
1092 # No error message, compilation succeeded.
1093 set result [${tool}_load "./$exe" "" ""]
1094 set status [lindex $result 0]
1095 remote_file build delete $exe
1096 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1097 if { $status == "pass" } then {
1102 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1105 # Return 1 if the target supports compiling Decimal Floating Point,
1108 # This won't change for different subtargets so cache the result.
1110 proc check_effective_target_dfp { } {
1113 if [info exists et_dfp_saved] {
1114 verbose "check_effective_target_dfp: using cached result" 2
1116 set et_dfp_saved [check_effective_target_dfp_nocache]
1118 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1119 return $et_dfp_saved
1122 # Return 1 if the target supports linking and executing Decimal Floating
1123 # Point, # 0 otherwise.
1125 # This won't change for different subtargets so cache the result.
1127 proc check_effective_target_dfprt { } {
1128 global et_dfprt_saved
1131 if [info exists et_dfprt_saved] {
1132 verbose "check_effective_target_dfprt: using cached result" 2
1134 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1136 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1137 return $et_dfprt_saved
1140 # Return 1 if the target needs a command line argument to enable a SIMD
1143 # This won't change for different subtargets so cache the result.
1145 proc check_effective_target_vect_cmdline_needed { } {
1146 global et_vect_cmdline_needed_saved
1148 if [info exists et_vect_cmdline_needed_saved] {
1149 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1151 set et_vect_cmdline_needed_saved 1
1152 if { [istarget ia64-*-*]
1153 || [istarget x86_64-*-*] } {
1154 set et_vect_cmdline_needed_saved 0
1158 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1159 return $et_vect_cmdline_needed_saved
1162 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1164 # This won't change for different subtargets so cache the result.
1166 proc check_effective_target_vect_int { } {
1167 global et_vect_int_saved
1169 if [info exists et_vect_int_saved] {
1170 verbose "check_effective_target_vect_int: using cached result" 2
1172 set et_vect_int_saved 0
1173 if { [istarget i?86-*-*]
1174 || [istarget powerpc*-*-*]
1175 || [istarget x86_64-*-*]
1176 || [istarget sparc*-*-*]
1177 || [istarget alpha*-*-*]
1178 || [istarget ia64-*-*] } {
1179 set et_vect_int_saved 1
1183 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1184 return $et_vect_int_saved
1187 # Return 1 is this is an arm target using 32-bit instructions
1188 proc check_effective_target_arm32 { } {
1189 global et_arm32_saved
1190 global et_arm32_target_name
1191 global compiler_flags
1193 if { ![info exists et_arm32_target_name] } {
1194 set et_arm32_target_name ""
1197 # If the target has changed since we set the cached value, clear it.
1198 set current_target [current_target_name]
1199 if { $current_target != $et_arm32_target_name } {
1200 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1201 set et_arm32_target_name $current_target
1202 if { [info exists et_arm32_saved] } {
1203 verbose "check_effective_target_arm32: removing cached result" 2
1204 unset et_arm32_saved
1208 if [info exists et_arm32_saved] {
1209 verbose "check-effective_target_arm32: using cached result" 2
1211 set et_arm32_saved 0
1212 if { [istarget arm-*-*]
1213 || [istarget strongarm*-*-*]
1214 || [istarget xscale-*-*] } {
1215 if ![string match "*-mthumb *" $compiler_flags] {
1216 set et_arm32_saved 1
1220 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1221 return $et_arm32_saved
1224 # Return 1 if the target supports hardware vector shift operation.
1226 proc check_effective_target_vect_shift { } {
1227 global et_vect_shift_saved
1229 if [info exists et_vect_shift_saved] {
1230 verbose "check_effective_target_vect_shift: using cached result" 2
1232 set et_vect_shift_saved 0
1233 if { [istarget powerpc*-*-*]
1234 || [istarget ia64-*-*]
1235 || [istarget i?86-*-*]
1236 || [istarget x86_64-*-*] } {
1237 set et_vect_shift_saved 1
1241 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1242 return $et_vect_shift_saved
1245 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1247 # This can change for different subtargets so do not cache the result.
1249 proc check_effective_target_vect_long { } {
1250 if { [istarget i?86-*-*]
1251 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1252 || [istarget x86_64-*-*]
1253 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1259 verbose "check_effective_target_vect_long: returning $answer" 2
1263 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1265 # This won't change for different subtargets so cache the result.
1267 proc check_effective_target_vect_float { } {
1268 global et_vect_float_saved
1270 if [info exists et_vect_float_saved] {
1271 verbose "check_effective_target_vect_float: using cached result" 2
1273 set et_vect_float_saved 0
1274 if { [istarget i?86-*-*]
1275 || [istarget powerpc*-*-*]
1276 || [istarget mipsisa64*-*-*]
1277 || [istarget x86_64-*-*]
1278 || [istarget ia64-*-*] } {
1279 set et_vect_float_saved 1
1283 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1284 return $et_vect_float_saved
1287 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1289 # This won't change for different subtargets so cache the result.
1291 proc check_effective_target_vect_double { } {
1292 global et_vect_double_saved
1294 if [info exists et_vect_double_saved] {
1295 verbose "check_effective_target_vect_double: using cached result" 2
1297 set et_vect_double_saved 0
1298 if { [istarget i?86-*-*]
1299 || [istarget x86_64-*-*] } {
1300 set et_vect_double_saved 1
1304 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1305 return $et_vect_double_saved
1308 # Return 1 if the target plus current options does not support a vector
1309 # max instruction on "int", 0 otherwise.
1311 # This won't change for different subtargets so cache the result.
1313 proc check_effective_target_vect_no_int_max { } {
1314 global et_vect_no_int_max_saved
1316 if [info exists et_vect_no_int_max_saved] {
1317 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1319 set et_vect_no_int_max_saved 0
1320 if { [istarget sparc*-*-*]
1321 || [istarget alpha*-*-*] } {
1322 set et_vect_no_int_max_saved 1
1325 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1326 return $et_vect_no_int_max_saved
1329 # Return 1 if the target plus current options does not support a vector
1330 # add instruction on "int", 0 otherwise.
1332 # This won't change for different subtargets so cache the result.
1334 proc check_effective_target_vect_no_int_add { } {
1335 global et_vect_no_int_add_saved
1337 if [info exists et_vect_no_int_add_saved] {
1338 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1340 set et_vect_no_int_add_saved 0
1341 # Alpha only supports vector add on V8QI and V4HI.
1342 if { [istarget alpha*-*-*] } {
1343 set et_vect_no_int_add_saved 1
1346 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1347 return $et_vect_no_int_add_saved
1350 # Return 1 if the target plus current options does not support vector
1351 # bitwise instructions, 0 otherwise.
1353 # This won't change for different subtargets so cache the result.
1355 proc check_effective_target_vect_no_bitwise { } {
1356 global et_vect_no_bitwise_saved
1358 if [info exists et_vect_no_bitwise_saved] {
1359 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1361 set et_vect_no_bitwise_saved 0
1363 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1364 return $et_vect_no_bitwise_saved
1367 # Return 1 if the target plus current options does not support a vector
1368 # alignment mechanism, 0 otherwise.
1370 # This won't change for different subtargets so cache the result.
1372 proc check_effective_target_vect_no_align { } {
1373 global et_vect_no_align_saved
1375 if [info exists et_vect_no_align_saved] {
1376 verbose "check_effective_target_vect_no_align: using cached result" 2
1378 set et_vect_no_align_saved 0
1379 if { [istarget mipsisa64*-*-*]
1380 || [istarget sparc*-*-*]
1381 || [istarget ia64-*-*] } {
1382 set et_vect_no_align_saved 1
1385 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1386 return $et_vect_no_align_saved
1389 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1391 proc check_effective_target_vect_condition { } {
1392 global et_vect_cond_saved
1394 if [info exists et_vect_cond_saved] {
1395 verbose "check_effective_target_vect_cond: using cached result" 2
1397 set et_vect_cond_saved 0
1398 if { [istarget powerpc*-*-*]
1399 || [istarget ia64-*-*]
1400 || [istarget i?86-*-*]
1401 || [istarget x86_64-*-*] } {
1402 set et_vect_cond_saved 1
1406 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1407 return $et_vect_cond_saved
1410 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1412 proc check_effective_target_vect_int_mult { } {
1413 global et_vect_int_mult_saved
1415 if [info exists et_vect_int_mult_saved] {
1416 verbose "check_effective_target_vect_int_mult: using cached result" 2
1418 set et_vect_int_mult_saved 0
1419 if { [istarget powerpc*-*-*]
1420 || [istarget i?86-*-*]
1421 || [istarget x86_64-*-*] } {
1422 set et_vect_int_mult_saved 1
1426 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1427 return $et_vect_int_mult_saved
1430 # Return 1 if the target supports atomic operations on "int" and "long".
1432 proc check_effective_target_sync_int_long { } {
1433 global et_sync_int_long_saved
1435 if [info exists et_sync_int_long_saved] {
1436 verbose "check_effective_target_sync_int_long: using cached result" 2
1438 set et_sync_int_long_saved 0
1439 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1440 # load-reserved/store-conditional instructions.
1441 if { [istarget ia64-*-*]
1442 || [istarget i?86-*-*]
1443 || [istarget x86_64-*-*]
1444 || [istarget alpha*-*-*]
1445 || [istarget s390*-*-*]
1446 || [istarget powerpc*-*-*]
1447 || [istarget sparc64-*-*]
1448 || [istarget sparcv9-*-*] } {
1449 set et_sync_int_long_saved 1
1453 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1454 return $et_sync_int_long_saved
1457 # Return 1 if the target supports atomic operations on "char" and "short".
1459 proc check_effective_target_sync_char_short { } {
1460 global et_sync_char_short_saved
1462 if [info exists et_sync_char_short_saved] {
1463 verbose "check_effective_target_sync_char_short: using cached result" 2
1465 set et_sync_char_short_saved 0
1466 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1467 # load-reserved/store-conditional instructions.
1468 if { [istarget ia64-*-*]
1469 || [istarget i?86-*-*]
1470 || [istarget x86_64-*-*]
1471 || [istarget alpha*-*-*]
1472 || [istarget s390*-*-*]
1473 || [istarget powerpc*-*-*]
1474 || [istarget sparc64-*-*]
1475 || [istarget sparcv9-*-*] } {
1476 set et_sync_char_short_saved 1
1480 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1481 return $et_sync_char_short_saved
1484 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1485 # This can be used with any check_* proc that takes no argument and
1486 # returns only 1 or 0. It could be used with check_* procs that take
1487 # arguments with keywords that pass particular arguments.
1489 proc is-effective-target { arg } {
1491 if { [info procs check_effective_target_${arg}] != [list] } {
1492 set selected [check_effective_target_${arg}]
1495 "vmx_hw" { set selected [check_vmx_hw_available] }
1496 "named_sections" { set selected [check_named_sections_available] }
1497 "gc_sections" { set selected [check_gc_sections_available] }
1498 default { error "unknown effective target keyword `$arg'" }
1501 verbose "is-effective-target: $arg $selected" 2
1505 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1507 proc is-effective-target-keyword { arg } {
1508 if { [info procs check_effective_target_${arg}] != [list] } {
1511 # These have different names for their check_* procs.
1513 "vmx_hw" { return 1 }
1514 "named_sections" { return 1 }
1515 "gc_sections" { return 1 }
1516 default { return 0 }