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
,
24 # and optionally the contents
for assembly files. Either a string or
25 # a list of two strings are returned
, depending
on WANT_OUTPUT.
27 # BASENAME is a basename to use
for temporary files.
28 # WANT_OUTPUT is a flag which is
0 to request returning just the
29 # compiler messages
, or
1 to
return the messages and the contents
30 # of the assembly file. TYPE should be
"assembly" if WANT_OUTPUT
32 # TYPE is the type of compilation to perform
(see target_compile
).
33 # CONTENTS gives the contents of the input file.
34 # The rest is optional
:
35 # OPTIONS
: additional compiler options to use.
36 proc get_compiler_messages
{basename want_output type contents
args} {
39 if { [llength $
args] > 0 } {
40 set options
[list
"additional_flags=[lindex $args 0]"]
45 set src $
{basename
}[pid
].c
47 assembly
{ set output $
{basename
}[pid
].s
}
48 object
{ set output $
{basename
}[pid
].o
}
53 set lines
[$
{tool
}_target_compile $src $output $type
"$options"]
57 if { $type
!= "assembly" } {
58 error
"WANT_OUTPUT can only be used with assembly output"
59 } elseif
{ ![string match
"" $lines] } {
61 set result
[list $lines
""]
64 set chan
[open
"$output"]
65 while {[gets $chan line
] >= 0} {
69 set result
[list $lines $
text]
75 remote_file build
delete $output
79 proc current_target_name
{ } {
81 if [info exists target_info
(target
,name)] {
82 set answer $target_info
(target
,name)
89 # Implement an effective
-target check
for property PROP by invoking
90 # the compiler and seeing
if it prints
any messages. Assume that the
91 #
property holds
if the compiler doesn
't print anything. The other
92 # arguments are as for get_compiler_messages, starting with TYPE.
93 proc check_no_compiler_messages {prop args} {
96 set target [current_target_name]
97 if {![info exists et_cache($prop,target)]
98 || $et_cache($prop,target) != $target} {
99 verbose "check_no_compiler_messages $prop: compiling source for $target" 2
100 set et_cache($prop,target) $target
101 set et_cache($prop,value) \
102 [string match "" [eval get_compiler_messages $prop 0 $args]]
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
109 # Similar to check_no_compiler_messages, but also verify that the regular
110 # expression PATTERN matches the compiler's output.
111 proc check_no_messages_and_pattern
{prop pattern
args} {
114 set target
[current_target_name
]
115 if {![info exists et_cache
($prop
,target
)]
116 || $et_cache
($prop
,target
) != $target
} {
117 verbose
"check_no_messages_and_pattern $prop: compiling source for $target" 2
118 set et_cache
($prop
,target
) $target
119 set results
[eval get_compiler_messages $prop
1 $
args]
120 set et_cache
($prop
,value
) \
121 [expr
[string match
"" [lindex $results 0]] \
122 && [regexp $pattern
[lindex $results
1]]]
124 set value $et_cache
($prop
,value
)
125 verbose
"check_no_messages_and_pattern $prop: returning $value for $target" 2
129 ###############################
130 # proc check_weak_available
{ }
131 ###############################
133 # weak symbols are only supported in some configs
/object formats
134 # this proc returns
1 if they
're supported, 0 if they're not
, or
-1 if unsure
136 proc check_weak_available
{ } {
137 global target_triplet
140 # All mips targets should support it
142 if { [ string first
"mips" $target_cpu ] >= 0 } {
146 # All solaris2 targets should support it
148 if { [regexp
".*-solaris2.*" $target_triplet] } {
152 # DEC OSF
/1/Digital UNIX
/Tru64 UNIX supports it
154 if { [regexp
"alpha.*osf.*" $target_triplet] } {
158 # Windows targets Cygwin and MingW32 support it
160 if { [regexp
".*mingw32|.*cygwin" $target_triplet] } {
164 # HP
-UX
10.X doesn
't support it
166 if { [regexp "hppa.*hpux10" $target_triplet] } {
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
173 set objformat [gcc_target_object_format]
181 unknown { return -1 }
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
190 # The visibility attribute is only support in some object formats
191 # This proc returns 1 if it is supported, 0 if not.
192 # The argument is the kind of visibility, default/protected/hidden/internal.
194 proc check_visibility_available { what_kind } {
196 global target_triplet
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
203 if [string match "" $what_kind] { set what_kind "hidden" }
205 return [check_no_compiler_messages visibility_available_$what_kind object "
206 void f() __attribute__((visibility(\"$what_kind\")));
211 ###############################
212 # proc check_alias_available { }
213 ###############################
215 # Determine if the target toolchain supports the alias attribute.
217 # Returns 2 if the target supports aliases. Returns 1 if the target
218 # only supports weak aliased. Returns 0 if the target does not
219 # support aliases at all. Returns -1 if support for aliases could not
222 proc check_alias_available { } {
223 global alias_available_saved
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
231 verbose "check_alias_available compiling testfile $src" 2
232 set f [open $src "w"]
233 # Compile a small test program. The definition of "g" is
234 # necessary to keep the Solaris assembler from complaining
236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
239 set lines [${tool}_target_compile $src $obj object ""]
241 remote_file build delete $obj
243 if [string match "" $lines] then {
244 # No error messages, everything is OK.
245 set alias_available_saved 2
247 if [regexp "alias definitions not supported" $lines] {
248 verbose "check_alias_available target does not support aliases" 2
250 set objformat [gcc_target_object_format]
252 if { $objformat == "elf" } {
253 verbose "check_alias_available but target uses ELF format, so it ought to" 2
254 set alias_available_saved -1
256 set alias_available_saved 0
259 if [regexp "only weak aliases are supported" $lines] {
260 verbose "check_alias_available target supports only weak aliases" 2
261 set alias_available_saved 1
263 set alias_available_saved -1
268 verbose "check_alias_available returning $alias_available_saved" 2
271 return $alias_available_saved
274 # Returns true if --gc-sections is supported on the target.
276 proc check_gc_sections_available { } {
277 global gc_sections_available_saved
280 if {![info exists gc_sections_available_saved]} {
281 # Some targets don't support gc
-sections despite whatever
's
282 # advertised by ld's options.
283 if { [istarget alpha
*-*-*]
284 ||
[istarget ia64
-*-*] } {
285 set gc_sections_available_saved
0
289 # Check
if the
ld used by gcc supports
--gc
-sections.
290 set gcc_spec
[$
{tool
}_target_compile
"-dumpspecs" "" "none" ""]
291 regsub
".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
292 set gcc_ld
[lindex
[$
{tool
}_target_compile
"-print-prog-name=$linker" "" "none" ""] 0]
293 set ld_output
[remote_exec host
"$gcc_ld" "--help"]
294 if { [ string first
"--gc-sections" $ld_output ] >= 0 } {
295 set gc_sections_available_saved
1
297 set gc_sections_available_saved
0
300 return $gc_sections_available_saved
303 #
Return true
if profiling is supported
on the target.
305 proc check_profiling_available
{ test_what
} {
306 global profiling_available_saved
308 verbose
"Profiling argument is <$test_what>" 1
310 # These conditions depend
on the
argument so examine them before
311 # looking at the
cache variable.
313 # Support
for -p
on solaris2 relies
on mcrt1.o which comes with the
314 # vendor compiler. We cannot reliably predict the directory where the
315 # vendor compiler
(and thus mcrt1.o
) is installed so we can
't
316 # necessarily find mcrt1.o even if we have it.
317 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
321 # Support for -p on irix relies on libprof1.a which doesn't appear to
322 # exist
on any irix6
system currently posting testsuite results.
323 # Support
for -pg
on irix relies
on gcrt1.o which doesn
't exist yet.
324 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
325 if { [istarget mips*-*-irix*]
326 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
330 # At present, there is no profiling support on NetWare.
331 if { [istarget *-*-netware*] } {
335 # Now examine the cache variable.
336 if {![info exists profiling_available_saved]} {
337 # Some targets don't have
any implementation of __bb_init_func or are
338 # missing other needed machinery.
339 if { [istarget mmix
-*-*]
340 ||
[istarget arm
*-*-eabi
*]
341 ||
[istarget arm
*-*-elf
]
342 ||
[istarget arm
*-*-symbianelf
*]
343 ||
[istarget powerpc
-*-eabi
*]
344 ||
[istarget strongarm
*-*-elf
]
345 ||
[istarget xscale
*-*-elf
]
346 ||
[istarget cris
-*-*]
347 ||
[istarget h8300
-*-*]
348 ||
[istarget mips
*-*-elf
]
349 ||
[istarget xtensa
-*-elf
]
350 ||
[istarget
*-*-windiss
] } {
351 set profiling_available_saved
0
353 set profiling_available_saved
1
357 return $profiling_available_saved
360 #
Return 1 if target has packed layout of structure members by
361 # default
, 0 otherwise. Note that this is slightly different than
362 # whether the target has
"natural alignment": both attributes may be
365 proc check_effective_target_default_packed
{ } {
366 return [check_no_compiler_messages default_packed assembly
{
367 struct x
{ char a
; long b
; } c
;
368 int s
[sizeof
(c
) == sizeof
(char
) + sizeof
(long
) ?
1 : -1];
372 #
Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
373 # documentation
, where the test also comes from.
375 proc check_effective_target_pcc_bitfield_type_matters
{ } {
376 # PCC_BITFIELD_TYPE_MATTERS isn
't just about unnamed or empty
377 # bitfields, but let's stick to the example code from the docs.
378 return [check_no_compiler_messages pcc_bitfield_type_matters assembly
{
379 struct foo1
{ char x
; char
:0; char y
; };
380 struct foo2
{ char x
; int :0; char y
; };
381 int s
[sizeof
(struct foo1
) != sizeof
(struct foo2
) ?
1 : -1];
385 #
Return 1 if thread local storage
(TLS
) is supported
, 0 otherwise.
387 # This won
't change for different subtargets so cache the result.
389 proc check_effective_target_tls {} {
393 if [info exists et_tls_saved] {
394 verbose "check_effective_target_tls: using cached result" 2
400 verbose "check_effective_target_tls: compiling testfile $src" 2
401 set f [open $src "w"]
402 # Compile a small test program.
403 puts $f "__thread int i;\n"
406 # Test for thread-local data supported by the platform.
408 [${tool}_target_compile $src $asm assembly ""]
410 if { [string match "*not supported*" $comp_output] } {
413 remove-build-file $asm
415 verbose "check_effective_target_tls: returning $et_tls_saved" 2
419 # Return 1 if TLS executables can run correctly, 0 otherwise.
421 # This won't change
for different subtargets so
cache the result.
423 proc check_effective_target_tls_runtime
{} {
424 global et_tls_runtime_saved
427 if [info exists et_tls_runtime_saved
] {
428 verbose
"check_effective_target_tls_runtime: using cached result" 2
430 set et_tls_runtime_saved
0
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}"
442 [$
{tool
}_target_compile $src $exe executable
""]
445 if [string match
"" $comp_output] then {
446 # No error messages
, everything is OK.
448 set result
[remote_load target
"./$exe" "" ""]
449 set status [lindex $result
0]
450 remote_file build
delete $exe
452 verbose
"check_effective_target_tls_runtime status is <$status>" 2
454 if { $
status == "pass" } {
455 set et_tls_runtime_saved
1
458 verbose
"check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
462 return $et_tls_runtime_saved
465 #
Return 1 if compilation with
-freorder
-blocks
-and
-partition is error
-free
466 #
for trivial code
, 0 otherwise.
468 proc check_effective_target_freorder
{} {
469 return [check_no_compiler_messages freorder object
{
471 } "-freorder-blocks-and-partition"]
474 #
Return 1 if -fpic and
-fPIC are supported
, as in no warnings or errors
475 # emitted
, 0 otherwise. Whether a shared library can actually be built is
476 # out of scope
for this test.
478 proc check_effective_target_fpic
{ } {
479 # Note that M68K has a multilib that supports
-fpic but not
480 #
-fPIC
, so we need to check both. We test with a
program that
481 # requires GOT references.
482 foreach
arg {fpic fPIC
} {
483 if [check_no_compiler_messages $
arg object
{
484 extern
int foo
(void
); extern
int bar
;
485 int baz
(void
) { return foo
() + bar
; }
493 #
Return 1 if the current multilib does not generate PIC by default.
495 proc check_effective_target_nonpic
{ } {
496 return [check_no_compiler_messages nonpic assembly
{
497 #
if __PIC__ || __pic__
503 #
Return true
if iconv is supported
on the target. In particular IBM1047.
505 proc check_iconv_available
{ test_what
} {
513 verbose
"check_iconv_available compiling testfile $src" 2
514 set f
[open $src
"w"]
515 #
Compile a small test
program.
516 puts $f
"#include <iconv.h>\n"
517 puts $f
"int main (void)\n {\n iconv_t cd; \n"
518 puts $f
"cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
519 puts $f
"if (cd == (iconv_t) -1)\n return 1;\n"
520 puts $f
"return 0;\n}"
523 #
If the tool configuration file has not
set libiconv
, try
"-liconv"
524 if { ![info exists libiconv
] } {
525 set libiconv
"-liconv"
527 set lines
[$
{tool
}_target_compile $src $exe executable
"libs=$libiconv" ]
530 if [string match
"" $lines] then {
531 # No error messages
, everything is OK.
533 set result
[$
{tool
}_load
"./$exe" "" ""]
534 set status [lindex $result
0]
535 remote_file build
delete $exe
537 verbose
"check_iconv_available status is <$status>" 2
539 if { $
status == "pass" } then {
547 #
Return true
if named sections are supported
on this target.
549 proc check_named_sections_available
{ } {
550 return [check_no_compiler_messages named_sections assembly
{
551 int __attribute__
((section
("whatever"))) foo;
555 #
Return 1 if the target supports Fortran real kinds larger than real
(8),
558 # When the target
name changes
, replace the cached result.
560 proc check_effective_target_fortran_large_real
{ } {
561 global et_fortran_large_real_saved
562 global et_fortran_large_real_target_name
565 if { ![info exists et_fortran_large_real_target_name
] } {
566 set et_fortran_large_real_target_name
""
569 #
If the target has changed since we
set the cached value
, clear it.
570 set current_target
[current_target_name
]
571 if { $current_target
!= $et_fortran_large_real_target_name
} {
572 verbose
"check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
573 set et_fortran_large_real_target_name $current_target
574 if [info exists et_fortran_large_real_saved
] {
575 verbose
"check_effective_target_fortran_large_real: removing cached result" 2
576 unset et_fortran_large_real_saved
580 if [info exists et_fortran_large_real_saved
] {
581 verbose
"check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
583 set et_fortran_large_real_saved
0
585 #
Set up
, compile, and
execute a test
program using large real
586 # kinds.
Include the current process ID in the file names to
587 # prevent conflicts with invocations
for multiple testsuites.
588 set src real
[pid
].f90
591 set f
[open $src
"w"]
592 puts $f
"integer,parameter :: k = &"
593 puts $f
" selected_real_kind (precision (0.0_8) + 1)"
594 puts $f
"real(kind=k) :: x"
595 puts $f
"x = cos (x);"
599 verbose
"check_effective_target_fortran_large_real compiling testfile $src" 2
600 set lines
[$
{tool
}_target_compile $src $exe executable
""]
603 if [string match
"" $lines] then {
604 # No error message
, compilation succeeded.
605 set et_fortran_large_real_saved
1
609 return $et_fortran_large_real_saved
612 #
Return 1 if the target supports Fortran
integer kinds larger than
613 #
integer(8), 0 otherwise.
615 # When the target
name changes
, replace the cached result.
617 proc check_effective_target_fortran_large_int
{ } {
618 global et_fortran_large_int_saved
619 global et_fortran_large_int_target_name
622 if { ![info exists et_fortran_large_int_target_name
] } {
623 set et_fortran_large_int_target_name
""
626 #
If the target has changed since we
set the cached value
, clear it.
627 set current_target
[current_target_name
]
628 if { $current_target
!= $et_fortran_large_int_target_name
} {
629 verbose
"check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
630 set et_fortran_large_int_target_name $current_target
631 if [info exists et_fortran_large_int_saved
] {
632 verbose
"check_effective_target_fortran_large_int: removing cached result" 2
633 unset et_fortran_large_int_saved
637 if [info exists et_fortran_large_int_saved
] {
638 verbose
"check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
640 set et_fortran_large_int_saved
0
642 #
Set up
, compile, and
execute a test
program using large
integer
643 # kinds.
Include the current process ID in the file names to
644 # prevent conflicts with invocations
for multiple testsuites.
648 set f
[open $src
"w"]
649 puts $f
"integer,parameter :: k = &"
650 puts $f
" selected_int_kind (range (0_8) + 1)"
651 puts $f
"integer(kind=k) :: i"
655 verbose
"check_effective_target_fortran_large_int compiling testfile $src" 2
656 set lines
[$
{tool
}_target_compile $src $exe executable
""]
659 if [string match
"" $lines] then {
660 # No error message
, compilation succeeded.
661 set et_fortran_large_int_saved
1
665 return $et_fortran_large_int_saved
668 #
Return 1 if we can statically link libgfortran
, 0 otherwise.
670 # When the target
name changes
, replace the cached result.
672 proc check_effective_target_static_libgfortran
{ } {
673 global et_static_libgfortran
674 global et_static_libgfortran_target_name
677 if { ![info exists et_static_libgfortran_target_name
] } {
678 set et_static_libgfortran_target_name
""
681 #
If the target has changed since we
set the cached value
, clear it.
682 set current_target
[current_target_name
]
683 if { $current_target
!= $et_static_libgfortran_target_name
} {
684 verbose
"check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
685 set et_static_libgfortran_target_name $current_target
686 if [info exists et_static_libgfortran_saved
] {
687 verbose
"check_effective_target_static_libgfortran: removing cached result" 2
688 unset et_static_libgfortran_saved
692 if [info exists et_static_libgfortran_saved
] {
693 verbose
"check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
695 set et_static_libgfortran_saved
0
697 #
Set up
, compile, and
execute a test
program using static linking.
698 #
Include the current process ID in the file names to prevent
699 # conflicts with invocations
for multiple testsuites.
700 set opts
"additional_flags=-static"
701 set src static
[pid
].f
702 set exe static
[pid
].x
704 set f
[open $src
"w"]
705 puts $f
" print *, 'test'"
709 verbose
"check_effective_target_static_libgfortran compiling testfile $src" 2
710 set lines
[$
{tool
}_target_compile $src $exe executable
"$opts"]
713 if [string match
"" $lines] then {
714 # No error message
, compilation succeeded.
715 set et_static_libgfortran_saved
1
719 return $et_static_libgfortran_saved
722 #
Return 1 if the target supports executing AltiVec instructions
, 0
723 # otherwise.
Cache the result.
725 proc check_vmx_hw_available
{ } {
726 global vmx_hw_available_saved
729 if [info exists vmx_hw_available_saved
] {
730 verbose
"check_hw_available returning saved $vmx_hw_available_saved" 2
732 set vmx_hw_available_saved
0
734 # Some simulators are known to not support VMX instructions.
735 if { [istarget powerpc
-*-eabi
] ||
[istarget powerpc
*-*-eabispe
] } {
736 verbose
"check_hw_available returning 0" 2
737 return $vmx_hw_available_saved
740 #
Set up
, compile, and
execute a test
program containing VMX
741 # instructions.
Include the current process ID in the file
742 # names to prevent conflicts with invocations
for multiple
747 set f
[open $src
"w"]
748 puts $f
"int main() {"
749 puts $f
"#ifdef __MACH__"
750 puts $f
" asm volatile (\"vor v0,v0,v0\");"
752 puts $f
" asm volatile (\"vor 0,0,0\");"
754 puts $f
" return 0; }"
757 # Most targets don
't require special flags for this test case, but
759 if [istarget *-*-darwin*] {
760 set opts "additional_flags=-maltivec"
765 verbose "check_vmx_hw_available compiling testfile $src" 2
766 set lines [${tool}_target_compile $src $exe executable "$opts"]
769 if [string match "" $lines] then {
770 # No error message, compilation succeeded.
771 set result [${tool}_load "./$exe" "" ""]
772 set status [lindex $result 0]
773 remote_file build delete $exe
774 verbose "check_vmx_hw_available testfile status is <$status>" 2
776 if { $status == "pass" } then {
777 set vmx_hw_available_saved 1
780 verbose "check_vmx_hw_availalble testfile compilation failed" 2
784 return $vmx_hw_available_saved
787 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
788 # complex float arguments. This affects gfortran tests that call cabsf
789 # in libm built by an earlier compiler. Return 1 if libm uses the same
790 # argument passing as the compiler under test, 0 otherwise.
792 # When the target name changes, replace the cached result.
794 proc check_effective_target_broken_cplxf_arg { } {
795 global et_broken_cplxf_arg_saved
796 global et_broken_cplxf_arg_target_name
799 # Skip the work for targets known not to be affected.
800 if { ![istarget powerpc64-*-linux*] } {
802 } elseif { [is-effective-target ilp32] } {
806 if { ![info exists et_broken_cplxf_arg_target_name] } {
807 set et_broken_cplxf_arg_target_name ""
810 # If the target has changed since we set the cached value, clear it.
811 set current_target [current_target_name]
812 if { $current_target != $et_broken_cplxf_arg_target_name } {
813 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
814 set et_broken_cplxf_arg_target_name $current_target
815 if [info exists et_broken_cplxf_arg_saved
] {
816 verbose
"check_effective_target_broken_cplxf_arg: removing cached result" 2
817 unset et_broken_cplxf_arg_saved
821 if [info exists et_broken_cplxf_arg_saved
] {
822 verbose
"check_effective_target_broken_cplxf_arg: using cached result" 2
824 set et_broken_cplxf_arg_saved
0
825 # This is only known to affect one target.
826 if { ![istarget powerpc64
-*-linux
*] ||
![is
-effective
-target lp64
] } {
827 set et_broken_cplxf_arg_saved
0
828 verbose
"check_effective_target_broken_cplxf_arg: caching 0" 2
829 return $et_broken_cplxf_arg_saved
832 #
Set up
, compile, and
execute a C test
program that calls cabsf.
836 set f
[open $src
"w"]
837 puts $f
"#include <complex.h>"
838 puts $f
"extern void abort (void);"
839 puts $f
"float fabsf (float);"
840 puts $f
"float cabsf (_Complex float);"
841 puts $f
"int main ()"
843 puts $f
" _Complex float cf;"
845 puts $f
" cf = 3 + 4.0fi;"
846 puts $f
" f = cabsf (cf);"
847 puts $f
" if (fabsf (f - 5.0) > 0.0001) abort ();"
852 set lines
[$
{tool
}_target_compile $src $exe executable
"-lm"]
855 if [string match
"" $lines] {
856 # No error message
, compilation succeeded.
857 set result
[$
{tool
}_load
"./$exe" "" ""]
858 set status [lindex $result
0]
859 remote_file build
delete $exe
861 verbose
"check_effective_target_broken_cplxf_arg: status is <$status>" 2
863 if { $
status != "pass" } {
864 set et_broken_cplxf_arg_saved
1
867 verbose
"check_effective_target_broken_cplxf_arg: compilation failed" 2
870 return $et_broken_cplxf_arg_saved
873 proc check_alpha_max_hw_available
{ } {
874 global alpha_max_hw_available_saved
877 if [info exists alpha_max_hw_available_saved
] {
878 verbose
"check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
880 set alpha_max_hw_available_saved
0
882 #
Set up
, compile, and
execute a test
program probing bit
8 of the
883 # architecture mask
, which indicates presence of
MAX instructions.
887 set f
[open $src
"w"]
888 puts $f
"int main() { return __builtin_alpha_amask(1<<8) != 0; }"
891 verbose
"check_alpha_max_hw_available compiling testfile $src" 2
892 set lines
[$
{tool
}_target_compile $src $exe executable
""]
895 if [string match
"" $lines] then {
896 # No error message
, compilation succeeded.
897 set result
[$
{tool
}_load
"./$exe" "" ""]
898 set status [lindex $result
0]
899 remote_file build
delete $exe
900 verbose
"check_alpha_max_hw_available testfile status is <$status>" 2
902 if { $
status == "pass" } then {
903 set alpha_max_hw_available_saved
1
906 verbose
"check_alpha_max_hw_availalble testfile compilation failed" 2
910 return $alpha_max_hw_available_saved
913 # Returns true iff the FUNCTION is available
on the target
system.
914 #
(This is essentially a Tcl implementation of Autoconf
's
917 proc check_function_available { function } {
918 set var "${function}_available_saved"
922 if {![info exists $var]} {
925 # Check to make sure.
926 set src "function[pid].c"
927 set exe "function[pid].exe"
929 set f [open $src "w"]
930 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
931 puts $f "char $function ();\n"
932 puts $f "int main () { $function (); }"
935 set lines [${tool}_target_compile $src $exe executable ""]
939 if {![string match "" $lines]} then {
941 verbose -log "$function is not available"
943 verbose -log "$function is available"
950 # Returns true iff "fork" is available on the target system.
952 proc check_fork_available {} {
953 return [check_function_available "fork"]
956 # Returns true iff "mkfifo" is available on the target system.
958 proc check_mkfifo_available {} {
959 if {[istarget *-*-cygwin*]} {
960 # Cygwin has mkfifo, but support is incomplete.
964 return [check_function_available "mkfifo"]
967 # Returns true iff "__cxa_atexit" is used on the target system.
969 proc check_cxa_atexit_available { } {
971 global et_cxa_atexit_target_name
974 if { ![info exists et_cxa_atexit_target_name] } {
975 set et_cxa_atexit_target_name ""
978 # If the target has changed since we set the cached value, clear it.
979 set current_target [current_target_name]
980 if { $current_target != $et_cxa_atexit_target_name } {
981 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
982 set et_cxa_atexit_target_name $current_target
983 if [info exists et_cxa_atexit
] {
984 verbose
"check_cxa_atexit_available: removing cached result" 2
989 if [info exists et_cxa_atexit
] {
990 verbose
"check_cxa_atexit_available: using cached result" 2
994 #
Set up
, compile, and
execute a C
++ test
program that depends
995 #
on correct ordering of static object destructors. This is
996 # indicative of the presence and use of __cxa_atexit.
997 set src cxaatexit
[pid
].cc
998 set exe cxaatexit
[pid
].x
1000 set f
[open $src
"w"]
1001 puts $f
"#include <stdlib.h>"
1002 puts $f
"static unsigned int count;"
1005 puts $f
" X() { count = 1; }"
1008 puts $f
" if (count != 3)"
1010 puts $f
" count = 4;"
1015 puts $f
" static X x;"
1019 puts $f
" Y() { f(); count = 2; }"
1022 puts $f
" if (count != 2)"
1024 puts $f
" count = 3;"
1028 puts $f
"int main()"
1029 puts $f
"{ return 0; }"
1032 set lines
[$
{tool
}_target_compile $src $exe executable
""]
1035 if [string match
"" $lines] {
1036 # No error message
, compilation succeeded.
1037 set result
[$
{tool
}_load
"./$exe" "" ""]
1038 set status [lindex $result
0]
1039 remote_file build
delete $exe
1041 verbose
"check_cxa_atexit_available: status is <$status>" 2
1043 if { $
status == "pass" } {
1047 verbose
"check_cxa_atexit_available: compilation failed" 2
1050 return $et_cxa_atexit
1054 #
Return 1 if we
're generating 32-bit code using default options, 0
1057 proc check_effective_target_ilp32 { } {
1058 return [check_no_compiler_messages ilp32 object {
1059 int dummy[sizeof (int) == 4
1060 && sizeof (void *) == 4
1061 && sizeof (long) == 4 ? 1 : -1];
1065 # Return 1 if we're generating
32-bit or larger integers using default
1066 # options
, 0 otherwise.
1068 proc check_effective_target_int32plus
{ } {
1069 return [check_no_compiler_messages int32plus object
{
1070 int dummy
[sizeof
(int) >= 4 ?
1 : -1];
1074 #
Return 1 if we
're generating 32-bit or larger pointers using default
1075 # options, 0 otherwise.
1077 proc check_effective_target_ptr32plus { } {
1078 return [check_no_compiler_messages ptr32plus object {
1079 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1083 # Return 1 if we support 32-bit or larger array and structure sizes
1084 # using default options, 0 otherwise.
1086 proc check_effective_target_size32plus { } {
1087 return [check_no_compiler_messages size32plus object {
1092 # Returns 1 if we're generating
16-bit or smaller integers with the
1093 # default options
, 0 otherwise.
1095 proc check_effective_target_int16
{ } {
1096 return [check_no_compiler_messages int16 object
{
1097 int dummy
[sizeof
(int) < 4 ?
1 : -1];
1101 #
Return 1 if we
're generating 64-bit code using default options, 0
1104 proc check_effective_target_lp64 { } {
1105 return [check_no_compiler_messages lp64 object {
1106 int dummy[sizeof (int) == 4
1107 && sizeof (void *) == 8
1108 && sizeof (long) == 8 ? 1 : -1];
1112 # Return 1 if the target needs a command line argument to enable a SIMD
1115 proc check_effective_target_vect_cmdline_needed { } {
1116 global et_vect_cmdline_needed_saved
1117 global et_vect_cmdline_needed_target_name
1119 if { ![info exists et_vect_cmdline_needed_target_name] } {
1120 set et_vect_cmdline_needed_target_name ""
1123 # If the target has changed since we set the cached value, clear it.
1124 set current_target [current_target_name]
1125 if { $current_target != $et_vect_cmdline_needed_target_name } {
1126 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target
'" 2
1127 set et_vect_cmdline_needed_target_name $current_target
1128 if { [info exists et_vect_cmdline_needed_saved] } {
1129 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1130 unset et_vect_cmdline_needed_saved
1134 if [info exists et_vect_cmdline_needed_saved] {
1135 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1137 set et_vect_cmdline_needed_saved 1
1138 if { [istarget ia64-*-*]
1139 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1140 && [check_effective_target_lp64])} {
1141 set et_vect_cmdline_needed_saved 0
1145 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1146 return $et_vect_cmdline_needed_saved
1149 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1151 # This won't change
for different subtargets so
cache the result.
1153 proc check_effective_target_vect_int
{ } {
1154 global et_vect_int_saved
1156 if [info exists et_vect_int_saved
] {
1157 verbose
"check_effective_target_vect_int: using cached result" 2
1159 set et_vect_int_saved
0
1160 if { [istarget i?
86-*-*]
1161 ||
[istarget powerpc
*-*-*]
1162 ||
[istarget x86_64
-*-*]
1163 ||
[istarget sparc
*-*-*]
1164 ||
[istarget alpha
*-*-*]
1165 ||
[istarget ia64
-*-*] } {
1166 set et_vect_int_saved
1
1170 verbose
"check_effective_target_vect_int: returning $et_vect_int_saved" 2
1171 return $et_vect_int_saved
1174 #
Return 1 is this is an arm target using
32-bit instructions
1175 proc check_effective_target_arm32
{ } {
1176 global et_arm32_saved
1177 global et_arm32_target_name
1178 global compiler_flags
1180 if { ![info exists et_arm32_target_name
] } {
1181 set et_arm32_target_name
""
1184 #
If the target has changed since we
set the cached value
, clear it.
1185 set current_target
[current_target_name
]
1186 if { $current_target
!= $et_arm32_target_name
} {
1187 verbose
"check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1188 set et_arm32_target_name $current_target
1189 if { [info exists et_arm32_saved
] } {
1190 verbose
"check_effective_target_arm32: removing cached result" 2
1191 unset et_arm32_saved
1195 if [info exists et_arm32_saved
] {
1196 verbose
"check-effective_target_arm32: using cached result" 2
1198 set et_arm32_saved
0
1199 if { [istarget arm
-*-*]
1200 ||
[istarget strongarm
*-*-*]
1201 ||
[istarget xscale
-*-*] } {
1202 if ![string match
"*-mthumb *" $compiler_flags] {
1203 set et_arm32_saved
1
1207 verbose
"check_effective_target_arm32: returning $et_arm32_saved" 2
1208 return $et_arm32_saved
1211 #
Return 1 if this is an ARM target supporting
-mfpu
=vfp
1212 #
-mfloat
-abi
=softfp. Some multilibs may be incompatible with these
1215 proc check_effective_target_arm_vfp_ok
{ } {
1216 if { [check_effective_target_arm32
] } {
1217 return [check_no_compiler_messages arm_vfp_ok object
{
1219 } "-mfpu=vfp -mfloat-abi=softfp"]
1225 #
Return 1 if this is a PowerPC target with floating
-point registers.
1227 proc check_effective_target_powerpc_fprs
{ } {
1228 if { [istarget powerpc
*-*-*]
1229 ||
[istarget rs6000
-*-*] } {
1230 return [check_no_compiler_messages powerpc_fprs object
{
1242 #
Return 1 if this is a PowerPC target supporting
-maltivec.
1244 proc check_effective_target_powerpc_altivec_ok
{ } {
1245 if { [istarget powerpc
*-*-*]
1246 ||
[istarget rs6000
-*-*] } {
1247 # AltiVec is not supported
on Aix.
1248 if { [istarget powerpc
*-*-aix
*] } {
1251 return [check_no_compiler_messages powerpc_altivec_ok object
{
1259 #
Return 1 if the target supports hardware vector shift operation.
1261 proc check_effective_target_vect_shift
{ } {
1262 global et_vect_shift_saved
1264 if [info exists et_vect_shift_saved
] {
1265 verbose
"check_effective_target_vect_shift: using cached result" 2
1267 set et_vect_shift_saved
0
1268 if { [istarget powerpc
*-*-*]
1269 ||
[istarget ia64
-*-*]
1270 ||
[istarget i?
86-*-*]
1271 ||
[istarget x86_64
-*-*] } {
1272 set et_vect_shift_saved
1
1276 verbose
"check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1277 return $et_vect_shift_saved
1280 #
Return 1 if the target supports hardware vectors of long
, 0 otherwise.
1282 # This can change
for different subtargets so
do not
cache the result.
1284 proc check_effective_target_vect_long
{ } {
1285 if { [istarget i?
86-*-*]
1286 ||
([istarget powerpc
*-*-*] && [check_effective_target_ilp32
])
1287 ||
[istarget x86_64
-*-*]
1288 ||
([istarget sparc
*-*-*] && [check_effective_target_ilp32
]) } {
1294 verbose
"check_effective_target_vect_long: returning $answer" 2
1298 #
Return 1 if the target supports hardware vectors of float
, 0 otherwise.
1300 # This won
't change for different subtargets so cache the result.
1302 proc check_effective_target_vect_float { } {
1303 global et_vect_float_saved
1305 if [info exists et_vect_float_saved] {
1306 verbose "check_effective_target_vect_float: using cached result" 2
1308 set et_vect_float_saved 0
1309 if { [istarget i?86-*-*]
1310 || [istarget powerpc*-*-*]
1311 || [istarget mipsisa64*-*-*]
1312 || [istarget x86_64-*-*]
1313 || [istarget ia64-*-*] } {
1314 set et_vect_float_saved 1
1318 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1319 return $et_vect_float_saved
1322 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1324 # This won't change
for different subtargets so
cache the result.
1326 proc check_effective_target_vect_double
{ } {
1327 global et_vect_double_saved
1329 if [info exists et_vect_double_saved
] {
1330 verbose
"check_effective_target_vect_double: using cached result" 2
1332 set et_vect_double_saved
0
1333 if { [istarget i?
86-*-*]
1334 ||
[istarget x86_64
-*-*] } {
1335 set et_vect_double_saved
1
1339 verbose
"check_effective_target_vect_double: returning $et_vect_double_saved" 2
1340 return $et_vect_double_saved
1343 #
Return 1 if the target plus current options does not support a vector
1344 #
max instruction
on "int", 0 otherwise.
1346 # This won
't change for different subtargets so cache the result.
1348 proc check_effective_target_vect_no_int_max { } {
1349 global et_vect_no_int_max_saved
1351 if [info exists et_vect_no_int_max_saved] {
1352 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1354 set et_vect_no_int_max_saved 0
1355 if { [istarget sparc*-*-*]
1356 || [istarget alpha*-*-*] } {
1357 set et_vect_no_int_max_saved 1
1360 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1361 return $et_vect_no_int_max_saved
1364 # Return 1 if the target plus current options does not support a vector
1365 # add instruction on "int", 0 otherwise.
1367 # This won't change
for different subtargets so
cache the result.
1369 proc check_effective_target_vect_no_int_add
{ } {
1370 global et_vect_no_int_add_saved
1372 if [info exists et_vect_no_int_add_saved
] {
1373 verbose
"check_effective_target_vect_no_int_add: using cached result" 2
1375 set et_vect_no_int_add_saved
0
1376 # Alpha only supports vector add
on V8QI and V4HI.
1377 if { [istarget alpha
*-*-*] } {
1378 set et_vect_no_int_add_saved
1
1381 verbose
"check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1382 return $et_vect_no_int_add_saved
1385 #
Return 1 if the target plus current options does not support vector
1386 # bitwise instructions
, 0 otherwise.
1388 # This won
't change for different subtargets so cache the result.
1390 proc check_effective_target_vect_no_bitwise { } {
1391 global et_vect_no_bitwise_saved
1393 if [info exists et_vect_no_bitwise_saved] {
1394 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1396 set et_vect_no_bitwise_saved 0
1398 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1399 return $et_vect_no_bitwise_saved
1402 # Return 1 if the target plus current options does not support a vector
1403 # alignment mechanism, 0 otherwise.
1405 # This won't change
for different subtargets so
cache the result.
1407 proc check_effective_target_vect_no_align
{ } {
1408 global et_vect_no_align_saved
1410 if [info exists et_vect_no_align_saved
] {
1411 verbose
"check_effective_target_vect_no_align: using cached result" 2
1413 set et_vect_no_align_saved
0
1414 if { [istarget mipsisa64
*-*-*]
1415 ||
[istarget sparc
*-*-*]
1416 ||
[istarget ia64
-*-*] } {
1417 set et_vect_no_align_saved
1
1420 verbose
"check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1421 return $et_vect_no_align_saved
1424 #
Return 1 if the target supports vector conditional operations
, 0 otherwise.
1426 proc check_effective_target_vect_condition
{ } {
1427 global et_vect_cond_saved
1429 if [info exists et_vect_cond_saved
] {
1430 verbose
"check_effective_target_vect_cond: using cached result" 2
1432 set et_vect_cond_saved
0
1433 if { [istarget powerpc
*-*-*]
1434 ||
[istarget ia64
-*-*]
1435 ||
[istarget i?
86-*-*]
1436 ||
[istarget x86_64
-*-*] } {
1437 set et_vect_cond_saved
1
1441 verbose
"check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1442 return $et_vect_cond_saved
1445 #
Return 1 if the target supports vector
int multiplication
, 0 otherwise.
1447 proc check_effective_target_vect_int_mult
{ } {
1448 global et_vect_int_mult_saved
1450 if [info exists et_vect_int_mult_saved
] {
1451 verbose
"check_effective_target_vect_int_mult: using cached result" 2
1453 set et_vect_int_mult_saved
0
1454 if { [istarget powerpc
*-*-*]
1455 ||
[istarget i?
86-*-*]
1456 ||
[istarget x86_64
-*-*] } {
1457 set et_vect_int_mult_saved
1
1461 verbose
"check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1462 return $et_vect_int_mult_saved
1465 #
Return 1 if the target supports atomic operations
on "int" and "long".
1467 proc check_effective_target_sync_int_long
{ } {
1468 global et_sync_int_long_saved
1470 if [info exists et_sync_int_long_saved
] {
1471 verbose
"check_effective_target_sync_int_long: using cached result" 2
1473 set et_sync_int_long_saved
0
1474 # This is intentionally powerpc but not rs6000
, rs6000 doesn
't have the
1475 # load-reserved/store-conditional instructions.
1476 if { [istarget ia64-*-*]
1477 || [istarget i?86-*-*]
1478 || [istarget x86_64-*-*]
1479 || [istarget alpha*-*-*]
1480 || [istarget s390*-*-*]
1481 || [istarget powerpc*-*-*] } {
1482 set et_sync_int_long_saved 1
1486 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1487 return $et_sync_int_long_saved
1490 # Return 1 if the target supports atomic operations on "char" and "short".
1492 proc check_effective_target_sync_char_short { } {
1493 global et_sync_char_short_saved
1495 if [info exists et_sync_char_short_saved] {
1496 verbose "check_effective_target_sync_char_short: using cached result" 2
1498 set et_sync_char_short_saved 0
1499 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1500 #
load-reserved/store
-conditional instructions.
1501 if { [istarget ia64
-*-*]
1502 ||
[istarget i?
86-*-*]
1503 ||
[istarget x86_64
-*-*]
1504 ||
[istarget alpha
*-*-*]
1505 ||
[istarget s390
*-*-*]
1506 ||
[istarget powerpc
*-*-*] } {
1507 set et_sync_char_short_saved
1
1511 verbose
"check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1512 return $et_sync_char_short_saved
1515 #
Return 1 if the target matches the effective target
'arg', 0 otherwise.
1516 # This can be used with
any check_
* proc that takes no
argument and
1517 # returns only
1 or
0. It could be used with check_
* procs that take
1518 # arguments with keywords that pass particular arguments.
1520 proc is
-effective
-target
{ arg } {
1522 if { [info procs check_effective_target_$
{arg}] != [list
] } {
1523 set selected
[check_effective_target_$
{arg}]
1526 "vmx_hw" { set selected [check_vmx_hw_available] }
1527 "named_sections" { set selected [check_named_sections_available] }
1528 "gc_sections" { set selected [check_gc_sections_available] }
1529 "cxa_atexit" { set selected [check_cxa_atexit_available] }
1530 default
{ error
"unknown effective target keyword `$arg'" }
1533 verbose
"is-effective-target: $arg $selected" 2
1537 #
Return 1 if the
argument is an effective
-target keyword
, 0 otherwise.
1539 proc is
-effective
-target
-keyword
{ arg } {
1540 if { [info procs check_effective_target_$
{arg}] != [list
] } {
1543 # These have different names
for their check_
* procs.
1545 "vmx_hw" { return 1 }
1546 "named_sections" { return 1 }
1547 "gc_sections" { return 1 }
1548 "cxa_atexit" { return 1 }
1549 default
{ return 0 }
1554 #
Return 1 if target default to short enums
1556 proc check_effective_target_short_enums
{ } {
1557 return [check_no_compiler_messages short_enums assembly
{
1559 int s
[sizeof
(enum foo
) == 1 ?
1 : -1];
1563 #
Return 1 if target supports merging string constants at link time.
1565 proc check_effective_target_string_merging
{ } {
1566 return [check_no_messages_and_pattern string_merging \
1567 "rodata\\.str" assembly {
1568 const char
*var
= "String";