Commit 9debda96 by Iain Sandoe Committed by Janis Johnson

re PR testsuite/42348 (Syntax of dg-skip-if in two obj-c++ tests)

2010-03-24  Iain Sandoe  <iain.sandoe@sandoe-acoustics.co.uk>

	PR testsuite/42348
	* lib/target-supports.exp: Add support for ObjC/ObjC++ tools in
	standard tests.
	(check_effective_target_objc2): New proc.
	(check_effective_target_next_runtime): New proc.
	* lib/objc.exp: Determine which runtime is in force and support it.
	* lib/obj-c++.exp: Ditto.

From-SVN: r157715
parent 94ad7adc
2010-03-24 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
PR testsuite/42348
* lib/target-supports.exp: Add support for ObjC/ObjC++ tools in
standard tests.
(check_effective_target_objc2): New proc.
(check_effective_target_next_runtime): New proc.
* lib/objc.exp: Determine which runtime is in force and support it.
* lib/obj-c++.exp: Ditto.
2010-03-24 Jason Merrill <jason@redhat.com> 2010-03-24 Jason Merrill <jason@redhat.com>
PR c++/43502 PR c++/43502
......
...@@ -42,10 +42,10 @@ proc obj-c++_version { } { ...@@ -42,10 +42,10 @@ proc obj-c++_version { } {
obj-c++_init obj-c++_init
# ignore any arguments after the command # Ignore any arguments after the command.
set compiler [lindex $OBJCXX_UNDER_TEST 0] set compiler [lindex $OBJCXX_UNDER_TEST 0]
# verify that the compiler exists # Verify that the compiler exists.
if { [is_remote host] || [which $compiler] != 0 } then { if { [is_remote host] || [which $compiler] != 0 } then {
set tmp [remote_exec host "$compiler -v"] set tmp [remote_exec host "$compiler -v"]
set status [lindex $tmp 0]; set status [lindex $tmp 0];
...@@ -61,7 +61,7 @@ proc obj-c++_version { } { ...@@ -61,7 +61,7 @@ proc obj-c++_version { } {
clone_output "Couldn't determine version of [which $compiler]\n" clone_output "Couldn't determine version of [which $compiler]\n"
} }
} else { } else {
# compiler does not exist (this should have already been detected) # Compiler does not exist (this should have already been detected)
warning "$compiler does not exist" warning "$compiler does not exist"
} }
} }
...@@ -93,7 +93,7 @@ proc obj-c++_include_flags { paths } { ...@@ -93,7 +93,7 @@ proc obj-c++_include_flags { paths } {
# #
# obj-c++_link_flags -- provide new version of obj-c++_link_flags # obj-c++_link_flags -- provide new version of obj-c++_link_flags
# (originally from libgloss.exp) which knows about the gcc tree structure # (originally from libgloss.exp) which knows about the gcc tree structure.
# #
proc obj-c++_link_flags { paths } { proc obj-c++_link_flags { paths } {
...@@ -115,27 +115,31 @@ proc obj-c++_link_flags { paths } { ...@@ -115,27 +115,31 @@ proc obj-c++_link_flags { paths } {
append ld_library_path ":${gccpath}/lib" append ld_library_path ":${gccpath}/lib"
} }
if [file exists "${gccpath}/libg++/libg++.a"] { if [file exists "${gccpath}/libg++/libg++.a"] {
append flags "-L${gccpath}/libg++ " append flags " -L${gccpath}/libg++ "
append ld_library_path ":${gccpath}/libg++" append ld_library_path ":${gccpath}/libg++"
} }
if [file exists "${gccpath}/libstdc++/libstdc++.a"] { if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
append flags "-L${gccpath}/libstdc++ " append flags " -L${gccpath}/libstdc++ "
append ld_library_path ":${gccpath}/libstdc++" append ld_library_path ":${gccpath}/libstdc++"
} }
if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] { if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
# Allow for %s spec substitutions
append flags " -B${gccpath}/libstdc++-v3/src/.libs "
append flags " -L${gccpath}/libstdc++-v3/src/.libs " append flags " -L${gccpath}/libstdc++-v3/src/.libs "
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
} }
# Look for libstdc++.${shlib_ext}. # Look for libstdc++.${shlib_ext}.
if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] { if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
# Allow for %s spec substitutions
append flags " -B${gccpath}/libstdc++-v3/src/.libs "
append flags " -L${gccpath}/libstdc++-v3/src/.libs " append flags " -L${gccpath}/libstdc++-v3/src/.libs "
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
} }
if [file exists "${gccpath}/libiberty/libiberty.a"] { if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty " append flags " -L${gccpath}/libiberty "
} }
if [file exists "${gccpath}/librx/librx.a"] { if [file exists "${gccpath}/librx/librx.a"] {
append flags "-L${gccpath}/librx " append flags " -L${gccpath}/librx "
} }
set objcpath "[get_multilibs]" set objcpath "[get_multilibs]"
...@@ -145,24 +149,23 @@ proc obj-c++_link_flags { paths } { ...@@ -145,24 +149,23 @@ proc obj-c++_link_flags { paths } {
} }
# Now check if we have a shared only build. # Now check if we have a shared only build.
if { $libobjc_dir == ""} { if { $libobjc_dir == ""} {
set libobjc_dir \ set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
[lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
}
if { $libobjc_dir == ""} { if { $libobjc_dir == ""} {
set libobjc_dir \ set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
[lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}] }
} }
verbose "libobjc_dir: $libobjc_dir" verbose "libobjc_dir: $libobjc_dir"
if { $libobjc_dir != "" } { if { $libobjc_dir != "" } {
set libobjc_dir [file dirname ${libobjc_dir}] set libobjc_dir [file dirname ${libobjc_dir}]
append flags "-L${libobjc_dir}" # Allow for %s spec substitutions
append flags " -B${libobjc_dir} "
append flags " -L${libobjc_dir} "
append ld_library_path ":${libobjc_dir}" append ld_library_path ":${libobjc_dir}"
} }
append ld_library_path \ append ld_library_path \
[gcc-set-multilib-library-path $OBJCXX_UNDER_TEST] [gcc-set-multilib-library-path $OBJCXX_UNDER_TEST]
} else { } else {
global tool_root_dir; global tool_root_dir;
...@@ -284,44 +287,75 @@ proc obj-c++_target_compile { source dest type options } { ...@@ -284,44 +287,75 @@ proc obj-c++_target_compile { source dest type options } {
global OBJCXX_UNDER_TEST global OBJCXX_UNDER_TEST
global shlib_ext global shlib_ext
lappend options "libs=-lobjc"
set shlib_ext [get_shlib_extension] set shlib_ext [get_shlib_extension]
verbose "shared lib extension: $shlib_ext" verbose "input-options: $options" 4
# We have to figure out which runtime will be used on darwin because
# we need to add the include path for the gnu runtime if that is in
# use.
# First, set the default...
if { [istarget "*-*-darwin*"] } {
set nextruntime 1
} else {
set nextruntime 0
}
verbose "initial next runtime state : $nextruntime" 2
# Next, see if we define the option in dg-options...
foreach opt $options {
if [regexp ".*-fnext-runtime.*" $opt] {
set nextruntime 1
}
if [regexp ".*-fgnu-runtime.*" $opt] {
set nextruntime 0
}
}
verbose "next runtime state after dg opts: $nextruntime" 2
set tgt [target_info name]
if [board_info $tgt exists multilib_flags] {
set lb [board_info $tgt multilib_flags]
verbose "board multilib_flags $lb" 2
foreach opt $lb {
if [regexp ".*-fnext-runtime.*" $opt] {
set nextruntime 1
}
if [regexp ".*-fgnu-runtime.*" $opt] {
set nextruntime 0
}
}
}
verbose "next runtime state after any multilib opts: $nextruntime" 2
lappend options "libs=-lobjc"
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}" lappend options "libs=${gluefile}"
lappend options "ldflags=${wrap_flags}" lappend options "ldflags=${wrap_flags}"
} }
# If we have built libobjc along with the compiler (which usually # If we have built libobjc along with the compiler, point the test harness
# _is not_ the case on Mac OS X systems), point the test harness
# at it (and associated headers). # at it (and associated headers).
set objcpath "[get_multilibs]" set objcpath "[get_multilibs]"
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a] set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
if { $libobjc_dir == ""} { if { $libobjc_dir == ""} {
verbose "see if we have -fgnu-runtime in options"
if [regexp ".*-fgnu-runtime.*" "${options}" ] {
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a] set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
} }
}
if { $libobjc_dir == ""} { if { $libobjc_dir == ""} {
set libobjc_dir \ set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
[lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
}
if { $libobjc_dir == ""} { if { $libobjc_dir == ""} {
verbose "see if we have -fgnu-runtime in options" set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
if [regexp ".*-fgnu-runtime.*" "${options}"] {
set libobjc_dir \
[lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
} }
} }
if { $libobjc_dir != "" } { if { $libobjc_dir != "" } {
# If we are using the gnu runtime, add its includes.
if { $nextruntime == 0 } {
set objc_include_dir "${srcdir}/../../libobjc" set objc_include_dir "${srcdir}/../../libobjc"
lappend options "additional_flags=-I${objc_include_dir}" lappend options "additional_flags=-I${objc_include_dir}"
} }
}
lappend options "additional_flags=[libio_include_flags]" lappend options "additional_flags=[libio_include_flags]"
lappend options "compiler=$OBJCXX_UNDER_TEST"; lappend options "compiler=$OBJCXX_UNDER_TEST";
......
...@@ -44,7 +44,7 @@ proc default_objc_version { } { ...@@ -44,7 +44,7 @@ proc default_objc_version { } {
objc_init objc_init
# ignore any arguments after the command # Ignore any arguments after the command.
set compiler [lindex $OBJC_UNDER_TEST 0] set compiler [lindex $OBJC_UNDER_TEST 0]
if ![is_remote host] { if ![is_remote host] {
...@@ -53,7 +53,7 @@ proc default_objc_version { } { ...@@ -53,7 +53,7 @@ proc default_objc_version { } {
set compiler_name $compiler set compiler_name $compiler
} }
# verify that the compiler exists # Verify that the compiler exists.
if { $compiler_name != 0 } then { if { $compiler_name != 0 } then {
set tmp [remote_exec host "$compiler -v"] set tmp [remote_exec host "$compiler -v"]
set status [lindex $tmp 0] set status [lindex $tmp 0]
...@@ -65,7 +65,7 @@ proc default_objc_version { } { ...@@ -65,7 +65,7 @@ proc default_objc_version { } {
clone_output "Couldn't determine version of $compiler_name: $output\n" clone_output "Couldn't determine version of $compiler_name: $output\n"
} }
} else { } else {
# compiler does not exist (this should have already been detected) # Compiler does not exist (this should have already been detected).
warning "$compiler does not exist" warning "$compiler does not exist"
} }
} }
...@@ -98,7 +98,8 @@ proc objc_init { args } { ...@@ -98,7 +98,8 @@ proc objc_init { args } {
global gcc_warning_prefix global gcc_warning_prefix
global gcc_error_prefix global gcc_error_prefix
# We set LC_ALL and LANG to C so that we get the same error messages as expected. # We set LC_ALL and LANG to C so that we get the same error messages as
# expected.
setenv LC_ALL C setenv LC_ALL C
setenv LANG C setenv LANG C
...@@ -142,10 +143,47 @@ proc objc_target_compile { source dest type options } { ...@@ -142,10 +143,47 @@ proc objc_target_compile { source dest type options } {
global objc_libgcc_s_path global objc_libgcc_s_path
global shlib_ext global shlib_ext
set shlib_ext [get_shlib_extension]
set ld_library_path ".:${objc_libgcc_s_path}" set ld_library_path ".:${objc_libgcc_s_path}"
# We have to figure out which runtime will be used on darwin because
# we need to add the include path for the gnu runtime if that is in
# use.
# First set the default...
if { [istarget "*-*-darwin*"] } {
set nextruntime 1
} else {
set nextruntime 0
}
verbose "initial next runtime state : $nextruntime" 2
# Next, see if we define the option in dg-options...
foreach opt $options {
if [regexp ".*-fnext-runtime.*" $opt] {
set nextruntime 1
}
if [regexp ".*-fgnu-runtime.*" $opt] {
set nextruntime 0
}
}
verbose "next runtime state after dg opts: $nextruntime" 2
set tgt [target_info name]
if [board_info $tgt exists multilib_flags] {
set lb [board_info $tgt multilib_flags]
verbose "board multilib_flags $lb" 2
foreach opt $lb {
if [regexp ".*-fnext-runtime.*" $opt] {
set nextruntime 1
}
if [regexp ".*-fgnu-runtime.*" $opt] {
set nextruntime 0
}
}
}
verbose "next runtime state after any multilib opts: $nextruntime" 2
lappend options "libs=-lobjc" lappend options "libs=-lobjc"
set shlib_ext [get_shlib_extension] verbose "shared lib extension: $shlib_ext" 3
verbose "shared lib extension: $shlib_ext"
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
lappend options "libs=${gluefile}" lappend options "libs=${gluefile}"
...@@ -167,42 +205,43 @@ proc objc_target_compile { source dest type options } { ...@@ -167,42 +205,43 @@ proc objc_target_compile { source dest type options } {
set options [concat "{additional_flags=$TOOL_OPTIONS}" $options] set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
} }
# If we have built libobjc along with the compiler (which usually # If we have built libobjc along with the compiler, point the test harness
# _is not_ the case on Mac OS X systems), point the test harness
# at it (and associated headers). # at it (and associated headers).
set objcpath "[get_multilibs]" set objcpath "[get_multilibs]"
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a] set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
if { $libobjc_dir == ""} { if { $libobjc_dir == "" } {
verbose "see if we have -fgnu-runtime in options" # On darwin there is, potentially, a gnu runtime too.
if [regexp ".*-fgnu-runtime.*" "${options}"] {
set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a] set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
} }
} # Perhaps we didn't build static libs.
# Now check if we have a shared only build. if { $libobjc_dir == "" } {
if { $libobjc_dir == ""} { set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
set libobjc_dir \ # On darwin there is, potentially, a gnu runtime too.
[lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}] if { $libobjc_dir == "" } {
} set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
if { $libobjc_dir == ""} {
verbose "see if we have -fgnu-runtime in options"
if [regexp ".*-fgnu-runtime.*" "${options}"] {
set libobjc_dir \
[lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
} }
} }
if { $libobjc_dir != "" } { if { $libobjc_dir != "" } {
# If we are using the gnu runtime, add its includes.
if { $nextruntime == 0 } {
set objc_include_dir "${srcdir}/../../libobjc" set objc_include_dir "${srcdir}/../../libobjc"
lappend options "additional_flags=-I${objc_include_dir}" lappend options "additional_flags=-I${objc_include_dir}"
verbose "adding gnu runtime include dir: $objc_include_dir "
}
set libobjc_dir [file dirname ${libobjc_dir}] set libobjc_dir [file dirname ${libobjc_dir}]
set objc_link_flags "-L${libobjc_dir}" # Allow for %s spec substitutions..
set objc_link_flags " -B${libobjc_dir} "
lappend options "additional_flags=${objc_link_flags}"
set objc_link_flags " -L${libobjc_dir} "
lappend options "additional_flags=${objc_link_flags}" lappend options "additional_flags=${objc_link_flags}"
append ld_library_path ":${libobjc_dir}" append ld_library_path ":${libobjc_dir}"
} }
if { $type == "precompiled_header" } { if { $type == "precompiled_header" } {
# If we generating a precompiled header, we have say this is an # If we generating a precompiled header, we have say this is an
# objective-C header # objective-C header.
set source [concat "-x objective-c-header" $source] set source [concat "-x objective-c-header" $source]
} }
lappend options "compiler=$OBJC_UNDER_TEST" lappend options "compiler=$OBJC_UNDER_TEST"
...@@ -214,7 +253,7 @@ proc objc_target_compile { source dest type options } { ...@@ -214,7 +253,7 @@ proc objc_target_compile { source dest type options } {
} }
# #
# objc_pass -- utility to record a testcase passed # objc_pass -- utility to record a testcase passed.
# #
proc objc_pass { testcase cflags } { proc objc_pass { testcase cflags } {
......
...@@ -29,10 +29,17 @@ ...@@ -29,10 +29,17 @@
# If ARGS is not empty, its first element is a string that # If ARGS is not empty, its first element is a string that
# should be added to the command line. # should be added to the command line.
# #
# Assume by default that CONTENTS is C code. C++ code should contain # Assume by default that CONTENTS is C code.
# "// C++" and Fortran code should contain "! Fortran". # Otherwise, code should contain:
# "// C++" for c++,
# "! Fortran" for Fortran code,
# "/* ObjC", for ObjC
# and "// ObjC++" for ObjC++
# If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
# allow for ObjC/ObjC++ specific flags.
proc check_compile {basename type contents args} { proc check_compile {basename type contents args} {
global tool global tool
verbose "check_compile tool: $tool for $basename"
if { [llength $args] > 0 } { if { [llength $args] > 0 } {
set options [list "additional_flags=[lindex $args 0]"] set options [list "additional_flags=[lindex $args 0]"]
...@@ -42,8 +49,17 @@ proc check_compile {basename type contents args} { ...@@ -42,8 +49,17 @@ proc check_compile {basename type contents args} {
switch -glob -- $contents { switch -glob -- $contents {
"*! Fortran*" { set src ${basename}[pid].f90 } "*! Fortran*" { set src ${basename}[pid].f90 }
"*// C++*" { set src ${basename}[pid].cc } "*// C++*" { set src ${basename}[pid].cc }
"*// ObjC++*" { set src ${basename}[pid].mm }
"*/* ObjC*" { set src ${basename}[pid].m }
default {
switch -- $tool {
"objc" { set src ${basename}[pid].m }
"obj-c++" { set src ${basename}[pid].mm }
default { set src ${basename}[pid].c } default { set src ${basename}[pid].c }
} }
}
}
set compile_type $type set compile_type $type
switch -glob $type { switch -glob $type {
assembly { set output ${basename}[pid].s } assembly { set output ${basename}[pid].s }
...@@ -1188,6 +1204,25 @@ proc check_cxa_atexit_available { } { ...@@ -1188,6 +1204,25 @@ proc check_cxa_atexit_available { } {
}] }]
} }
proc check_effective_target_objc2 { } {
return [check_no_compiler_messages objc2 object {
#ifdef __OBJC2__
int dummy[1];
#else
#error
#endif
}]
}
proc check_effective_target_next_runtime { } {
return [check_no_compiler_messages objc2 object {
#ifdef __NEXT_RUNTIME__
int dummy[1];
#else
#error
#endif
}]
}
# Return 1 if we're generating 32-bit code using default options, 0 # Return 1 if we're generating 32-bit code using default options, 0
# otherwise. # otherwise.
......
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