Commit 0ffd38c8 by Richard Sandiford Committed by Richard Sandiford

target-supports.exp (get_compiler_messages): Replace with...

gcc/testsuite/
	* lib/target-supports.exp (get_compiler_messages): Replace with...
	(check_compile): ...this new procedure.  Handle TYPE == executable.
	Use comments in the source to determine the correct extension.
	Return a pair containing the compiler output and the output filename.
	Don't delete the file here.
	(check_no_compiler_messages_nocache): New procedure.
	(check_no_compiler_messages): Use it.
	(check_no_messages_and_pattern_nocache): New procedure.
	(check_no_messages_and_pattern): Use it.
	(check_runtime_nocache, check_runtime): New procedures.
	(check_effective_target_tls): Use check_no_compiler_messages.
	(check_effective_target_tls_native): Use check_no_messages_and_pattern.
	(check_effective_target_tls_runtime): Use check_runtime.
	(check_effective_target_fstack_protector): Likewise.
	(check_iconv_available): Use check_runtime_nocache.
	(check_effective_target_fortran_large_real): Use
	check_no_compiler_messages.
	(check_effective_target_fortran_large_int): Likewise.
	(check_effective_target_static_libgfortran): Likewise.
	(check_750cl_hw_available): Use check_cached_effective_target
	and check_runtime_nocache.
	(check_vmx_hw_available): Likewise.
	(check_effective_target_broken_cplxf_arg): Likewise.
	(check_alpha_max_hw_available): Use check_runtime.
	(check_function_available): Use check_no_compiler_messages.
	(check_cxa_atexit_available): Use check_cached_effective_target
	and check_runtime_nocache.
	(check_effective_target_dfp_nocache): Use
	check_no_compiler_messages_nocache.
	(check_effective_target_dfprt_nocache): Use check_runtime_nocache.
	(check_effective_target_dfp): Use check_cached_effective_target.
	(check_effective_target_dfprt): Likewise.
	(check_effective_target_arm_neon_hw): Use check_runtime.
	(check_effective_target_ultrasparc_hw): Likewise.
	(check_effective_target_c99_runtime): Use
	check_no_compiler_messages_nocache.

From-SVN: r130599
parent 34add780
2007-12-04 Richard Sandiford <rsandifo@nildram.co.uk>
* lib/target-supports.exp (get_compiler_messages): Replace with...
(check_compile): ...this new procedure. Handle TYPE == executable.
Use comments in the source to determine the correct extension.
Return a pair containing the compiler output and the output filename.
Don't delete the file here.
(check_no_compiler_messages_nocache): New procedure.
(check_no_compiler_messages): Use it.
(check_no_messages_and_pattern_nocache): New procedure.
(check_no_messages_and_pattern): Use it.
(check_runtime_nocache, check_runtime): New procedures.
(check_effective_target_tls): Use check_no_compiler_messages.
(check_effective_target_tls_native): Use check_no_messages_and_pattern.
(check_effective_target_tls_runtime): Use check_runtime.
(check_effective_target_fstack_protector): Likewise.
(check_iconv_available): Use check_runtime_nocache.
(check_effective_target_fortran_large_real): Use
check_no_compiler_messages.
(check_effective_target_fortran_large_int): Likewise.
(check_effective_target_static_libgfortran): Likewise.
(check_750cl_hw_available): Use check_cached_effective_target
and check_runtime_nocache.
(check_vmx_hw_available): Likewise.
(check_effective_target_broken_cplxf_arg): Likewise.
(check_alpha_max_hw_available): Use check_runtime.
(check_function_available): Use check_no_compiler_messages.
(check_cxa_atexit_available): Use check_cached_effective_target
and check_runtime_nocache.
(check_effective_target_dfp_nocache): Use
check_no_compiler_messages_nocache.
(check_effective_target_dfprt_nocache): Use check_runtime_nocache.
(check_effective_target_dfp): Use check_cached_effective_target.
(check_effective_target_dfprt): Likewise.
(check_effective_target_arm_neon_hw): Use check_runtime.
(check_effective_target_ultrasparc_hw): Likewise.
(check_effective_target_c99_runtime): Use
check_no_compiler_messages_nocache.
2007-12-03 Jakub Jelinek <jakub@redhat.com> 2007-12-03 Jakub Jelinek <jakub@redhat.com>
PR middle-end/29749 PR middle-end/29749
...@@ -20,20 +20,18 @@ ...@@ -20,20 +20,18 @@
# This file defines procs for determining features supported by the target. # This file defines procs for determining features supported by the target.
# Try to compile some code and return the messages printed by the compiler, # Try to compile the code given by CONTENTS into an output file of
# and optionally the contents for assembly files. Either a string or # type TYPE, where TYPE is as for target_compile. Return a list
# a list of two strings are returned, depending on WANT_OUTPUT. # whose first element contains the compiler messages and whose
# second element is the name of the output file.
# #
# BASENAME is a basename to use for temporary files. # BASENAME is a prefix to use for source and output files.
# WANT_OUTPUT is a flag which is 0 to request returning just the # If ARGS is not empty, its first element is a string that
# compiler messages, or 1 to return the messages and the contents # should be added to the command line.
# of the assembly file. TYPE should be "assembly" if WANT_OUTPUT #
# is set. # Assume by default that CONTENTS is C code. C++ code should contain
# TYPE is the type of compilation to perform (see target_compile). # "// C++" and Fortran code should contain "! Fortran".
# CONTENTS gives the contents of the input file. proc check_compile {basename type contents args} {
# The rest is optional:
# OPTIONS: additional compiler options to use.
proc get_compiler_messages {basename want_output type contents args} {
global tool global tool
if { [llength $args] > 0 } { if { [llength $args] > 0 } {
...@@ -41,11 +39,15 @@ proc get_compiler_messages {basename want_output type contents args} { ...@@ -41,11 +39,15 @@ proc get_compiler_messages {basename want_output type contents args} {
} else { } else {
set options "" set options ""
} }
switch -glob -- $contents {
set src ${basename}[pid].c "*! Fortran*" { set src ${basename}[pid].f90 }
"*// C++*" { set src ${basename}[pid].cc }
default { set src ${basename}[pid].c }
}
switch $type { switch $type {
assembly { set output ${basename}[pid].s } assembly { set output ${basename}[pid].s }
object { set output ${basename}[pid].o } object { set output ${basename}[pid].o }
executable { set output ${basename}[pid].exe }
} }
set f [open $src "w"] set f [open $src "w"]
puts $f $contents puts $f $contents
...@@ -53,27 +55,7 @@ proc get_compiler_messages {basename want_output type contents args} { ...@@ -53,27 +55,7 @@ proc get_compiler_messages {basename want_output type contents args} {
set lines [${tool}_target_compile $src $output $type "$options"] set lines [${tool}_target_compile $src $output $type "$options"]
file delete $src file delete $src
if { $want_output } { return [list $lines $output]
if { $type != "assembly" } {
error "WANT_OUTPUT can only be used with assembly output"
} elseif { ![string match "" $lines] } {
# An error occurred.
set result [list $lines ""]
} else {
set text ""
set chan [open "$output"]
while {[gets $chan line] >= 0} {
append text "$line\n"
}
close $chan
set result [list $lines $text]
}
} else {
set result $lines
}
remote_file build delete $output
return $result
} }
proc current_target_name { } { proc current_target_name { } {
...@@ -104,23 +86,96 @@ proc check_cached_effective_target { prop args } { ...@@ -104,23 +86,96 @@ proc check_cached_effective_target { prop args } {
return $value return $value
} }
# Implement an effective-target check for property PROP by invoking # Like check_compile, but delete the output file and return true if the
# the compiler and seeing if it prints any messages. Assume that the # compiler printed no messages.
# property holds if the compiler doesn't print anything. The other proc check_no_compiler_messages_nocache {args} {
# arguments are as for get_compiler_messages, starting with TYPE. set result [eval check_compile $args]
set lines [lindex $result 0]
set output [lindex $result 1]
remote_file build delete $output
return [string match "" $lines]
}
# Like check_no_compiler_messages_nocache, but cache the result.
# PROP is the property we're checking, and doubles as a prefix for
# temporary filenames.
proc check_no_compiler_messages {prop args} { proc check_no_compiler_messages {prop args} {
return [check_cached_effective_target $prop { return [check_cached_effective_target $prop {
string match "" [eval get_compiler_messages $prop 0 $args] eval [list check_no_compiler_messages_nocache $prop] $args
}] }]
} }
# Similar to check_no_compiler_messages, but also verify that the regular # Like check_compile, but return true if the compiler printed no
# expression PATTERN matches the compiler's output. # messages and if the contents of the output file satisfy PATTERN.
# If PATTERN has the form "!REGEXP", the contents satisfy it if they
# don't match regular expression REGEXP, otherwise they satisfy it
# if they do match regular expression PATTERN. (PATTERN can start
# with something like "[!]" if the regular expression needs to match
# "!" as the first character.)
#
# Delete the output file before returning. The other arguments are
# as for check_compile.
proc check_no_messages_and_pattern_nocache {basename pattern args} {
global tool
set result [eval [list check_compile $basename] $args]
set lines [lindex $result 0]
set output [lindex $result 1]
set ok 0
if { [string match "" $lines] } {
set chan [open "$output"]
set invert [regexp {^!(.*)} $pattern dummy pattern]
set ok [expr { [regexp $pattern [read $chan]] != $invert }]
close $chan
}
remote_file build delete $output
return $ok
}
# Like check_no_messages_and_pattern_nocache, but cache the result.
# PROP is the property we're checking, and doubles as a prefix for
# temporary filenames.
proc check_no_messages_and_pattern {prop pattern args} { proc check_no_messages_and_pattern {prop pattern args} {
return [check_cached_effective_target $prop { return [check_cached_effective_target $prop {
set results [eval get_compiler_messages $prop 1 $args] eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
expr { [string match "" [lindex $results 0]] }]
&& [regexp $pattern [lindex $results 1]] } }
# Try to compile and run an executable from code CONTENTS. Return true
# if the compiler reports no messages and if execution "passes" in the
# usual DejaGNU sense. The arguments are as for check_compile, with
# TYPE implicitly being "executable".
proc check_runtime_nocache {basename contents args} {
global tool
set result [eval [list check_compile $basename executable $contents] $args]
set lines [lindex $result 0]
set output [lindex $result 1]
set ok 0
if { [string match "" $lines] } {
# No error messages, everything is OK.
set result [remote_load target "./$output" "" ""]
set status [lindex $result 0]
verbose "check_runtime_nocache $basename: status is <$status>" 2
if { $status == "pass" } {
set ok 1
}
}
remote_file build delete $output
return $ok
}
# Like check_runtime_nocache, but cache the result. PROP is the
# property we're checking, and doubles as a prefix for temporary
# filenames.
proc check_runtime {prop args} {
global tool
return [check_cached_effective_target $prop {
eval [list check_runtime_nocache $prop] $args
}] }]
} }
...@@ -414,37 +469,11 @@ proc check_effective_target_pcc_bitfield_type_matters { } { ...@@ -414,37 +469,11 @@ proc check_effective_target_pcc_bitfield_type_matters { } {
# This won't change for different subtargets so cache the result. # This won't change for different subtargets so cache the result.
proc check_effective_target_tls {} { proc check_effective_target_tls {} {
global et_tls_saved return [check_no_compiler_messages tls assembly {
global tool __thread int i;
int f (void) { return i; }
if [info exists et_tls_saved] { void g (int j) { i = j; }
verbose "check_effective_target_tls: using cached result" 2 }]
} else {
set et_tls_saved 0
set src tls[pid].c
set asm tls[pid].S
verbose "check_effective_target_tls: compiling testfile $src" 2
set f [open $src "w"]
# Compile a small test program. Make sure that we test accesses
# as well as declarations.
puts $f "__thread int i;\n"
puts $f "int f (void) { return i; }\n"
puts $f "void g (int j) { i = j; }\n"
close $f
# Test for thread-local data supported by the platform.
set comp_output \
[${tool}_target_compile $src $asm assembly ""]
file delete $src
if { [string match "" $comp_output] } {
# No error messages, everything is OK.
set et_tls_saved 1
}
remove-build-file $asm
}
verbose "check_effective_target_tls: returning $et_tls_saved" 2
return $et_tls_saved
} }
# Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise. # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
...@@ -452,43 +481,11 @@ proc check_effective_target_tls {} { ...@@ -452,43 +481,11 @@ proc check_effective_target_tls {} {
# This won't change for different subtargets so cache the result. # This won't change for different subtargets so cache the result.
proc check_effective_target_tls_native {} { proc check_effective_target_tls_native {} {
global et_tls_native_saved return [check_no_messages_and_pattern tls_native "!emultls" assembly {
global tool __thread int i;
int f (void) { return i; }
if [info exists et_tls_saved] { void g (int j) { i = j; }
verbose "check_effective_target_tls_native: using cached result" 2 }]
} else {
set et_tls_native_saved 0
set src tls[pid].c
set asm tls[pid].S
verbose "check_effective_target_tls_native: compiling testfile $src" 2
set f [open $src "w"]
# Compile a small test program. Make sure that we test accesses
# as well as declarations.
puts $f "__thread int i;\n"
puts $f "int f (void) { return i; }\n"
puts $f "void g (int j) { i = j; }\n"
close $f
# Test for thread-local data supported by the platform.
set comp_output [${tool}_target_compile $src $asm assembly ""]
file delete $src
if { [string match "" $comp_output] } {
# No error messages, everything is OK.
set fd [open $asm r]
set text [read $fd]
close $fd
if { [string match "*emutls*" $text]} {
set et_tls_native_saved 0
} else {
set et_tls_native_saved 1
}
}
remove-build-file $asm
}
verbose "check_effective_target_tls_native: returning $et_tls_native_saved" 2
return $et_tls_native_saved
} }
# Return 1 if TLS executables can run correctly, 0 otherwise. # Return 1 if TLS executables can run correctly, 0 otherwise.
...@@ -496,45 +493,10 @@ proc check_effective_target_tls_native {} { ...@@ -496,45 +493,10 @@ proc check_effective_target_tls_native {} {
# This won't change for different subtargets so cache the result. # This won't change for different subtargets so cache the result.
proc check_effective_target_tls_runtime {} { proc check_effective_target_tls_runtime {} {
global et_tls_runtime_saved return [check_runtime tls_runtime {
global tool __thread int thr = 0;
int main (void) { return thr; }
if [info exists et_tls_runtime_saved] { }]
verbose "check_effective_target_tls_runtime: using cached result" 2
} else {
set et_tls_runtime_saved 0
set src tls_runtime[pid].c
set exe tls_runtime[pid].x
verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
set f [open $src "w"]
# Compile a small test program.
puts $f "__thread int thr = 0;\n"
puts $f "int main(void)\n {\n return thr;\n}"
close $f
set comp_output \
[${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $comp_output] then {
# No error messages, everything is OK.
set result [remote_load target "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_effective_target_tls_runtime status is <$status>" 2
if { $status == "pass" } {
set et_tls_runtime_saved 1
}
verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
}
}
return $et_tls_runtime_saved
} }
# Return 1 if compilation with -fopenmp is error-free for trivial # Return 1 if compilation with -fopenmp is error-free for trivial
...@@ -548,35 +510,9 @@ proc check_effective_target_fopenmp {} { ...@@ -548,35 +510,9 @@ proc check_effective_target_fopenmp {} {
# Return 1 if the target supports -fstack-protector # Return 1 if the target supports -fstack-protector
proc check_effective_target_fstack_protector {} { proc check_effective_target_fstack_protector {} {
global tool return [check_runtime fstack_protector {
set result "" int main (void) { return 0; }
} "-fstack-protector"]
set src stack_prot[pid].c
set exe stack_prot[pid].x
verbose "check_effective_target_fstack_protector compiling testfile $src" 2
set f [open $src "w"]
# Compile a small test program.
puts $f "int main (void)\n { return 0; }\n"
close $f
set opts "additional_flags=-fstack-protector"
set lines [${tool}_target_compile $src $exe executable "$opts" ]
file delete $src
if [string match "" $lines] then {
# No error messages, everything is OK.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_iconv_available status is <$status>" 2
if { $status == "pass" } then {
return 1
}
}
return 0
} }
# Return 1 if compilation with -freorder-blocks-and-partition is error-free # Return 1 if compilation with -freorder-blocks-and-partition is error-free
...@@ -699,45 +635,25 @@ proc check_effective_target_unwrapped { } { ...@@ -699,45 +635,25 @@ proc check_effective_target_unwrapped { } {
# Return true if iconv is supported on the target. In particular IBM1047. # Return true if iconv is supported on the target. In particular IBM1047.
proc check_iconv_available { test_what } { proc check_iconv_available { test_what } {
global tool
global libiconv global libiconv
set result ""
set src iconv[pid].c
set exe iconv[pid].x
verbose "check_iconv_available compiling testfile $src" 2
set f [open $src "w"]
# Compile a small test program.
puts $f "#include <iconv.h>\n"
puts $f "int main (void)\n {\n iconv_t cd; \n"
puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
puts $f "return 0;\n}"
close $f
# If the tool configuration file has not set libiconv, try "-liconv" # If the tool configuration file has not set libiconv, try "-liconv"
if { ![info exists libiconv] } { if { ![info exists libiconv] } {
set libiconv "-liconv" set libiconv "-liconv"
} }
set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ] set test_what [lindex $test_what 1]
file delete $src return [check_runtime_nocache $test_what [subst {
#include <iconv.h>
if [string match "" $lines] then { int main (void)
# No error messages, everything is OK. {
iconv_t cd;
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0] cd = iconv_open ("$test_what", "UTF-8");
remote_file build delete $exe if (cd == (iconv_t) -1)
return 1;
verbose "check_iconv_available status is <$status>" 2 return 0;
if { $status == "pass" } then {
return 1
} }
} }] $libiconv]
return 0
} }
# Return true if named sections are supported on this target. # Return true if named sections are supported on this target.
...@@ -754,56 +670,13 @@ proc check_named_sections_available { } { ...@@ -754,56 +670,13 @@ proc check_named_sections_available { } {
# When the target name changes, replace the cached result. # When the target name changes, replace the cached result.
proc check_effective_target_fortran_large_real { } { proc check_effective_target_fortran_large_real { } {
global et_fortran_large_real_saved return [check_no_compiler_messages fortran_large_real executable {
global et_fortran_large_real_target_name ! Fortran
global tool integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
real(kind=k) :: x
if { ![info exists et_fortran_large_real_target_name] } { x = cos (x)
set et_fortran_large_real_target_name "" end
} }]
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_fortran_large_real_target_name } {
verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
set et_fortran_large_real_target_name $current_target
if [info exists et_fortran_large_real_saved] {
verbose "check_effective_target_fortran_large_real: removing cached result" 2
unset et_fortran_large_real_saved
}
}
if [info exists et_fortran_large_real_saved] {
verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
} else {
set et_fortran_large_real_saved 0
# Set up, compile, and execute a test program using large real
# kinds. Include the current process ID in the file names to
# prevent conflicts with invocations for multiple testsuites.
set src real[pid].f90
set exe real[pid].x
set f [open $src "w"]
puts $f "integer,parameter :: k = &"
puts $f " selected_real_kind (precision (0.0_8) + 1)"
puts $f "real(kind=k) :: x"
puts $f "x = cos (x);"
puts $f "end"
close $f
verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
remote_file build delete $exe
set et_fortran_large_real_saved 1
}
}
return $et_fortran_large_real_saved
} }
# Return 1 if the target supports Fortran integer kinds larger than # Return 1 if the target supports Fortran integer kinds larger than
...@@ -812,55 +685,12 @@ proc check_effective_target_fortran_large_real { } { ...@@ -812,55 +685,12 @@ proc check_effective_target_fortran_large_real { } {
# When the target name changes, replace the cached result. # When the target name changes, replace the cached result.
proc check_effective_target_fortran_large_int { } { proc check_effective_target_fortran_large_int { } {
global et_fortran_large_int_saved return [check_no_compiler_messages fortran_large_int executable {
global et_fortran_large_int_target_name ! Fortran
global tool integer,parameter :: k = selected_int_kind (range (0_8) + 1)
integer(kind=k) :: i
if { ![info exists et_fortran_large_int_target_name] } { end
set et_fortran_large_int_target_name "" }]
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_fortran_large_int_target_name } {
verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
set et_fortran_large_int_target_name $current_target
if [info exists et_fortran_large_int_saved] {
verbose "check_effective_target_fortran_large_int: removing cached result" 2
unset et_fortran_large_int_saved
}
}
if [info exists et_fortran_large_int_saved] {
verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
} else {
set et_fortran_large_int_saved 0
# Set up, compile, and execute a test program using large integer
# kinds. Include the current process ID in the file names to
# prevent conflicts with invocations for multiple testsuites.
set src int[pid].f90
set exe int[pid].x
set f [open $src "w"]
puts $f "integer,parameter :: k = &"
puts $f " selected_int_kind (range (0_8) + 1)"
puts $f "integer(kind=k) :: i"
puts $f "end"
close $f
verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
remote_file build delete $exe
set et_fortran_large_int_saved 1
}
}
return $et_fortran_large_int_saved
} }
# Return 1 if we can statically link libgfortran, 0 otherwise. # Return 1 if we can statically link libgfortran, 0 otherwise.
...@@ -868,177 +698,67 @@ proc check_effective_target_fortran_large_int { } { ...@@ -868,177 +698,67 @@ proc check_effective_target_fortran_large_int { } {
# When the target name changes, replace the cached result. # When the target name changes, replace the cached result.
proc check_effective_target_static_libgfortran { } { proc check_effective_target_static_libgfortran { } {
global et_static_libgfortran return [check_no_compiler_messages static_libgfortran executable {
global et_static_libgfortran_target_name ! Fortran
global tool print *, 'test'
end
if { ![info exists et_static_libgfortran_target_name] } { } "-static"]
set et_static_libgfortran_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_static_libgfortran_target_name } {
verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
set et_static_libgfortran_target_name $current_target
if [info exists et_static_libgfortran_saved] {
verbose "check_effective_target_static_libgfortran: removing cached result" 2
unset et_static_libgfortran_saved
}
}
if [info exists et_static_libgfortran_saved] {
verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
} else {
set et_static_libgfortran_saved 0
# Set up, compile, and execute a test program using static linking.
# Include the current process ID in the file names to prevent
# conflicts with invocations for multiple testsuites.
set opts "additional_flags=-static"
set src static[pid].f
set exe static[pid].x
set f [open $src "w"]
puts $f " print *, 'test'"
puts $f " end"
close $f
verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable "$opts"]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
remote_file build delete $exe
set et_static_libgfortran_saved 1
}
}
return $et_static_libgfortran_saved
} }
# Return 1 if the target supports executing 750CL paired-single instructions, 0 # Return 1 if the target supports executing 750CL paired-single instructions, 0
# otherwise. Cache the result. # otherwise. Cache the result.
proc check_750cl_hw_available { } { proc check_750cl_hw_available { } {
global 750cl_hw_available_saved return [check_cached_effective_target 750cl_hw_available {
global tool # If this is not the right target then we can skip the test.
if { ![istarget powerpc-*paired*] } {
if [info exists 750cl_hw_available_saved] { expr 0
verbose "check_hw_available returning saved $750cl_hw_available_saved" 2 } else {
} else { check_runtime_nocache 750cl_hw_available {
set 750cl_hw_available_saved 0 int main()
{
# If this is not the right target then we can quit. #ifdef __MACH__
if { ![istarget powerpc-*paired*] } { asm volatile ("ps_mul v0,v0,v0");
verbose "check_hw_available returning 0" 2 #else
return $750cl_hw_available_saved asm volatile ("ps_mul 0,0,0");
} #endif
return 0;
# Set up, compile, and execute a test program containing paired-single }
# instructions. Include the current process ID in the file } "-mpaired"
# names to prevent conflicts with invocations for multiple }
# testsuites. }]
set src 750cl[pid].c
set exe 750cl[pid].x
set f [open $src "w"]
puts $f "int main() {"
puts $f "#ifdef __MACH__"
puts $f " asm volatile (\"ps_mul v0,v0,v0\");"
puts $f "#else"
puts $f " asm volatile (\"ps_mul 0,0,0\");"
puts $f "#endif"
puts $f " return 0; }"
close $f
verbose "check_750cl_hw_available compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable "-mpaired"]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_750cl_hw_available testfile status is <$status>" 2
if { $status == "pass" } then {
set 750cl_hw_available_saved 1
}
} else {
verbose "check_750cl_hw_availalble testfile compilation failed" 2
}
}
return $750cl_hw_available_saved
} }
# Return 1 if the target supports executing AltiVec instructions, 0 # Return 1 if the target supports executing AltiVec instructions, 0
# otherwise. Cache the result. # otherwise. Cache the result.
proc check_vmx_hw_available { } { proc check_vmx_hw_available { } {
global vmx_hw_available_saved return [check_cached_effective_target vmx_hw_available {
global tool
if [info exists vmx_hw_available_saved] {
verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
} else {
set vmx_hw_available_saved 0
# Some simulators are known to not support VMX instructions. # Some simulators are known to not support VMX instructions.
if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } { if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
verbose "check_hw_available returning 0" 2 expr 0
return $vmx_hw_available_saved
}
# Set up, compile, and execute a test program containing VMX
# instructions. Include the current process ID in the file
# names to prevent conflicts with invocations for multiple
# testsuites.
set src vmx[pid].c
set exe vmx[pid].x
set f [open $src "w"]
puts $f "int main() {"
puts $f "#ifdef __MACH__"
puts $f " asm volatile (\"vor v0,v0,v0\");"
puts $f "#else"
puts $f " asm volatile (\"vor 0,0,0\");"
puts $f "#endif"
puts $f " return 0; }"
close $f
# Most targets don't require special flags for this test case, but
# Darwin does.
if { [istarget *-*-darwin*]
|| [istarget *-*-aix*] } {
set opts "additional_flags=-maltivec"
} else { } else {
set opts "" # Most targets don't require special flags for this test case, but
} # Darwin does.
if { [istarget *-*-darwin*]
verbose "check_vmx_hw_available compiling testfile $src" 2 || [istarget *-*-aix*] } {
set lines [${tool}_target_compile $src $exe executable "$opts"] set options "-maltivec"
file delete $src } else {
set options ""
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_vmx_hw_available testfile status is <$status>" 2
if { $status == "pass" } then {
set vmx_hw_available_saved 1
} }
} else { check_runtime_nocache vmx_hw_available {
verbose "check_vmx_hw_availalble testfile compilation failed" 2 int main()
{
#ifdef __MACH__
asm volatile ("vor v0,v0,v0");
#else
asm volatile ("vor 0,0,0");
#endif
return 0;
}
} $options
} }
} }]
return $vmx_hw_available_saved
} }
# GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
...@@ -1049,122 +769,37 @@ proc check_vmx_hw_available { } { ...@@ -1049,122 +769,37 @@ proc check_vmx_hw_available { } {
# When the target name changes, replace the cached result. # When the target name changes, replace the cached result.
proc check_effective_target_broken_cplxf_arg { } { proc check_effective_target_broken_cplxf_arg { } {
global et_broken_cplxf_arg_saved return [check_cached_effective_target broken_cplxf_arg {
global et_broken_cplxf_arg_target_name # Skip the work for targets known not to be affected.
global tool if { ![istarget powerpc64-*-linux*] } {
expr 0
# Skip the work for targets known not to be affected. } elseif { ![is-effective-target lp64] } {
if { ![istarget powerpc64-*-linux*] } { expr 0
return 0
} elseif { [is-effective-target ilp32] } {
return 0
}
if { ![info exists et_broken_cplxf_arg_target_name] } {
set et_broken_cplxf_arg_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_broken_cplxf_arg_target_name } {
verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
set et_broken_cplxf_arg_target_name $current_target
if [info exists et_broken_cplxf_arg_saved] {
verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
unset et_broken_cplxf_arg_saved
}
}
if [info exists et_broken_cplxf_arg_saved] {
verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
} else {
set et_broken_cplxf_arg_saved 0
# This is only known to affect one target.
if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
set et_broken_cplxf_arg_saved 0
verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
return $et_broken_cplxf_arg_saved
}
# Set up, compile, and execute a C test program that calls cabsf.
set src cabsf[pid].c
set exe cabsf[pid].x
set f [open $src "w"]
puts $f "#include <complex.h>"
puts $f "extern void abort (void);"
puts $f "float fabsf (float);"
puts $f "float cabsf (_Complex float);"
puts $f "int main ()"
puts $f "{"
puts $f " _Complex float cf;"
puts $f " float f;"
puts $f " cf = 3 + 4.0fi;"
puts $f " f = cabsf (cf);"
puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
puts $f " return 0;"
puts $f "}"
close $f
set lines [${tool}_target_compile $src $exe executable "-lm"]
file delete $src
if [string match "" $lines] {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
if { $status != "pass" } {
set et_broken_cplxf_arg_saved 1
}
} else { } else {
verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2 check_runtime_nocache broken_cplxf_arg {
#include <complex.h>
extern void abort (void);
float fabsf (float);
float cabsf (_Complex float);
int main ()
{
_Complex float cf;
float f;
cf = 3 + 4.0fi;
f = cabsf (cf);
if (fabsf (f - 5.0) > 0.0001)
abort ();
return 0;
}
} "-lm"
} }
} }]
return $et_broken_cplxf_arg_saved
} }
proc check_alpha_max_hw_available { } { proc check_alpha_max_hw_available { } {
global alpha_max_hw_available_saved return [check_runtime alpha_max_hw_available {
global tool int main() { return __builtin_alpha_amask(1<<8) != 0; }
}]
if [info exists alpha_max_hw_available_saved] {
verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
} else {
set alpha_max_hw_available_saved 0
# Set up, compile, and execute a test program probing bit 8 of the
# architecture mask, which indicates presence of MAX instructions.
set src max[pid].c
set exe max[pid].x
set f [open $src "w"]
puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
close $f
verbose "check_alpha_max_hw_available compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_alpha_max_hw_available testfile status is <$status>" 2
if { $status == "pass" } then {
set alpha_max_hw_available_saved 1
}
} else {
verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
}
}
return $alpha_max_hw_available_saved
} }
# Returns true iff the FUNCTION is available on the target system. # Returns true iff the FUNCTION is available on the target system.
...@@ -1172,36 +807,14 @@ proc check_alpha_max_hw_available { } { ...@@ -1172,36 +807,14 @@ proc check_alpha_max_hw_available { } {
# AC_CHECK_FUNC.) # AC_CHECK_FUNC.)
proc check_function_available { function } { proc check_function_available { function } {
set var "${function}_available_saved" return [check_no_compiler_messages ${function}_available \
global $var executable [subst {
global tool #ifdef __cplusplus
extern "C"
if {![info exists $var]} { #endif
# Assume it exists. char $function ();
set $var 1 int main () { $function (); }
# Check to make sure. }]]
set src "function[pid].c"
set exe "function[pid].exe"
set f [open $src "w"]
puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
puts $f "char $function ();\n"
puts $f "int main () { $function (); }"
close $f
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
file delete $exe
if {![string match "" $lines]} then {
set $var 0
verbose -log "$function is not available"
} else {
verbose -log "$function is available"
}
}
eval return \$$var
} }
# Returns true iff "fork" is available on the target system. # Returns true iff "fork" is available on the target system.
...@@ -1224,90 +837,44 @@ proc check_mkfifo_available {} { ...@@ -1224,90 +837,44 @@ proc check_mkfifo_available {} {
# Returns true iff "__cxa_atexit" is used on the target system. # Returns true iff "__cxa_atexit" is used on the target system.
proc check_cxa_atexit_available { } { proc check_cxa_atexit_available { } {
global et_cxa_atexit return [check_cached_effective_target cxa_atexit_available {
global et_cxa_atexit_target_name if { [istarget "hppa*-*-hpux10*"] } {
global tool # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
expr 0
if { ![info exists et_cxa_atexit_target_name] } {
set et_cxa_atexit_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_cxa_atexit_target_name } {
verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
set et_cxa_atexit_target_name $current_target
if [info exists et_cxa_atexit] {
verbose "check_cxa_atexit_available: removing cached result" 2
unset et_cxa_atexit
}
}
if [info exists et_cxa_atexit] {
verbose "check_cxa_atexit_available: using cached result" 2
} elseif { [istarget "hppa*-*-hpux10*"] } {
# HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
set et_cxa_atexit 0
} else {
set et_cxa_atexit 0
# Set up, compile, and execute a C++ test program that depends
# on correct ordering of static object destructors. This is
# indicative of the presence and use of __cxa_atexit.
set src cxaatexit[pid].cc
set exe cxaatexit[pid].x
set f [open $src "w"]
puts $f "#include <stdlib.h>"
puts $f "static unsigned int count;"
puts $f "struct X"
puts $f "{"
puts $f " X() { count = 1; }"
puts $f " ~X()"
puts $f " {"
puts $f " if (count != 3)"
puts $f " exit(1);"
puts $f " count = 4;"
puts $f " }"
puts $f "};"
puts $f "void f()"
puts $f "{"
puts $f " static X x;"
puts $f "}"
puts $f "struct Y"
puts $f "{"
puts $f " Y() { f(); count = 2; }"
puts $f " ~Y()"
puts $f " {"
puts $f " if (count != 2)"
puts $f " exit(1);"
puts $f " count = 3;"
puts $f " }"
puts $f "};"
puts $f "Y y;"
puts $f "int main()"
puts $f "{ return 0; }"
close $f
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_cxa_atexit_available: status is <$status>" 2
if { $status == "pass" } {
set et_cxa_atexit 1
}
} else { } else {
verbose "check_cxa_atexit_available: compilation failed" 2 check_runtime_nocache cxa_atexit_available {
// C++
#include <stdlib.h>
static unsigned int count;
struct X
{
X() { count = 1; }
~X()
{
if (count != 3)
exit(1);
count = 4;
}
};
void f()
{
static X x;
}
struct Y
{
Y() { f(); count = 2; }
~Y()
{
if (count != 2)
exit(1);
count = 3;
}
};
Y y;
int main() { return 0; }
}
} }
} }]
return $et_cxa_atexit
} }
...@@ -1392,45 +959,18 @@ proc check_effective_target_fixed_point { } { ...@@ -1392,45 +959,18 @@ proc check_effective_target_fixed_point { } {
proc check_effective_target_dfp_nocache { } { proc check_effective_target_dfp_nocache { } {
verbose "check_effective_target_dfp_nocache: compiling source" 2 verbose "check_effective_target_dfp_nocache: compiling source" 2
set ret [string match "" [get_compiler_messages dfp 0 object { set ret [check_no_compiler_messages_nocache dfp object {
_Decimal32 x; _Decimal64 y; _Decimal128 z; _Decimal32 x; _Decimal64 y; _Decimal128 z;
}]] }]
verbose "check_effective_target_dfp_nocache: returning $ret" 2 verbose "check_effective_target_dfp_nocache: returning $ret" 2
return $ret return $ret
} }
proc check_effective_target_dfprt_nocache { } { proc check_effective_target_dfprt_nocache { } {
global tool return [check_runtime_nocache dfprt {
_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
set ret 0 int main () { z = x + y; return 0; }
}]
verbose "check_effective_target_dfprt_nocache: compiling source" 2
# Set up, compile, and execute a test program containing decimal
# float operations.
set src dfprt[pid].c
set exe dfprt[pid].x
set f [open $src "w"]
puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
puts $f "int main () { z = x + y; return 0; }"
close $f
verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable ""]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
if { $status == "pass" } then {
set ret 1
}
}
return $ret
verbose "check_effective_target_dfprt_nocache: returning $ret" 2
} }
# Return 1 if the target supports compiling Decimal Floating Point, # Return 1 if the target supports compiling Decimal Floating Point,
...@@ -1439,15 +979,9 @@ proc check_effective_target_dfprt_nocache { } { ...@@ -1439,15 +979,9 @@ proc check_effective_target_dfprt_nocache { } {
# This won't change for different subtargets so cache the result. # This won't change for different subtargets so cache the result.
proc check_effective_target_dfp { } { proc check_effective_target_dfp { } {
global et_dfp_saved return [check_cached_effective_target dfp {
check_effective_target_dfp_nocache
if [info exists et_dfp_saved] { }]
verbose "check_effective_target_dfp: using cached result" 2
} else {
set et_dfp_saved [check_effective_target_dfp_nocache]
}
verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
return $et_dfp_saved
} }
# Return 1 if the target supports linking and executing Decimal Floating # Return 1 if the target supports linking and executing Decimal Floating
...@@ -1456,16 +990,9 @@ proc check_effective_target_dfp { } { ...@@ -1456,16 +990,9 @@ proc check_effective_target_dfp { } {
# This won't change for different subtargets so cache the result. # This won't change for different subtargets so cache the result.
proc check_effective_target_dfprt { } { proc check_effective_target_dfprt { } {
global et_dfprt_saved return [check_cached_effective_target dfprt {
global tool check_effective_target_dfprt_nocache
}]
if [info exists et_dfprt_saved] {
verbose "check_effective_target_dfprt: using cached result" 2
} else {
set et_dfprt_saved [check_effective_target_dfprt_nocache]
}
verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
return $et_dfprt_saved
} }
# Return 1 if the target needs a command line argument to enable a SIMD # Return 1 if the target needs a command line argument to enable a SIMD
...@@ -1619,54 +1146,17 @@ proc check_effective_target_arm_neon_ok { } { ...@@ -1619,54 +1146,17 @@ proc check_effective_target_arm_neon_ok { } {
# otherwise. Cache the result. # otherwise. Cache the result.
proc check_effective_target_arm_neon_hw { } { proc check_effective_target_arm_neon_hw { } {
global arm_neon_hw_available_saved return [check_runtime arm_neon_hw_available {
global tool int
main (void)
if [info exists arm_neon_hw_available_saved] { {
verbose "check_arm_neon_hw_available returning saved $arm_neon_hw_avail long long a = 0, b = 1;
able_saved" 2 asm ("vorr %P0, %P1, %P2"
} else { : "=w" (a)
set arm_neon_hw_available_saved 0 : "0" (a), "w" (b));
return (a != 1);
# Set up, compile, and execute a test program containing NEON }
# instructions. Include the current process ID in the file } "-mfpu=neon -mfloat-abi=softfp"]
# names to prevent conflicts with invocations for multiple
# testsuites.
set src neon[pid].c
set exe neon[pid].x
set f [open $src "w"]
puts $f "int main() {"
puts $f " long long a = 0, b = 1;"
puts $f " asm (\"vorr %P0, %P1, %P2\""
puts $f " : \"=w\" (a)"
puts $f " : \"0\" (a), \"w\" (b));"
puts $f " return (a != 1);"
puts $f "}"
close $f
set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
verbose "check_arm_neon_hw_available compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable "$opts"]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_arm_neon_hw_available testfile status is <$status>" 2
if { $status == "pass" } then {
set arm_neon_hw_available_saved 1
}
} else {
verbose "check_arm_neon_hw_available testfile compilation failed" 2
}
}
return $arm_neon_hw_available_saved
} }
# Return 1 if this is a PowerPC target with floating-point registers. # Return 1 if this is a PowerPC target with floating-point registers.
...@@ -1743,44 +1233,9 @@ proc check_effective_target_powerpc_altivec { } { ...@@ -1743,44 +1233,9 @@ proc check_effective_target_powerpc_altivec { } {
# test environment appears to run executables on such a simulator. # test environment appears to run executables on such a simulator.
proc check_effective_target_ultrasparc_hw { } { proc check_effective_target_ultrasparc_hw { } {
global et_ultrasparc_hw_saved return [check_runtime ultrasparc_hw {
global tool int main() { return 0; }
} "-mcpu=ultrasparc"]
if [info exists et_ultrasparc_hw_saved] {
verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
} else {
set et_ultrasparc_hw_saved 0
# Set up, compile, and execute a simple test program. The
# program will be compiled with -mcpu=ultrasparc to instruct the
# assembler to produce EM_SPARC32PLUS executables.
set src svect[pid].c
set exe svect[pid].x
set f [open $src "w"]
puts $f "int main() { return 0; }"
close $f
verbose "check_ultrasparc_hw_available compiling testfile $src" 2
set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
file delete $src
if [string match "" $lines] then {
# No error message, compilation succeeded.
set result [${tool}_load "./$exe" "" ""]
set status [lindex $result 0]
remote_file build delete $exe
verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
if { $status == "pass" } then {
set et_ultrasparc_hw_saved 1
}
} else {
verbose "check_ultrasparc_hw_available testfile compilation failed" 2
}
}
return $et_ultrasparc_hw_saved
} }
# Return 1 if the target supports hardware vector shift operation. # Return 1 if the target supports hardware vector shift operation.
...@@ -2747,7 +2202,7 @@ proc check_effective_target_c99_runtime { } { ...@@ -2747,7 +2202,7 @@ proc check_effective_target_c99_runtime { } {
#error FOO #error FOO
#endif #endif
} }
string match "" [get_compiler_messages c99_runtime 0 assembly \ check_no_compiler_messages_nocache c99_runtime assembly \
$contents [add_options_for_c99_runtime ""]] $contents [add_options_for_c99_runtime ""]
}] }]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment