This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.0 Patch] Backport testsuite "target fpic" support
- From: "Kaveh R. Ghazi" <ghazi at caipclassic dot rutgers dot edu>
- To: janis187 at us dot ibm dot com, mark at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 8 Dec 2005 14:37:26 -0500 (EST)
- Subject: [4.0 Patch] Backport testsuite "target fpic" support
In my last testcase patch that I applied on mainline/4.1/4.0, I failed
to notice that "target fpic" wasn't available in the 4.0 branch. So
we're getting this error from the 4.0 testsuite:
> ERROR: gcc.dg/pr18928-1.c: syntax error in target selector "target fpic" for " dg-do 2 compile { target fpic } "
IMHO, we should strive to keep the testsuite harness up to date on 4.0
because portability of testcases helps keep 4.0 more robust.
So rather than back out the testcase change, I'm backporting the
target fpic support. (In fact I think we should backport all changes
to the testsuite/lib/ directory and other *.exp files, but that's more
than I'd like to do right now.)
Tested via "make check" on 4.0 on i686-unknown-linux-gnu.
Okay for 4.0 branch?
Thanks,
--Kaveh
2005-12-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
Backport:
2005-04-07 Hans-Peter Nilsson <hp@axis.com>
* lib/target-supports.exp (get_compiler_messages): Support
optional arguments, the fourth being compiler options.
(check_effective_target_fpic): New proc.
* gcc.dg/20050321-2.c: Restrict to target fpic.
diff -rup orig/egcc-4.0-SVN20051207/gcc/testsuite/lib/target-supports.exp egcc-4.0-SVN20051207/gcc/testsuite/lib/target-supports.exp
--- orig/egcc-4.0-SVN20051207/gcc/testsuite/lib/target-supports.exp 2005-12-08 08:36:01.000000000 -0500
+++ egcc-4.0-SVN20051207/gcc/testsuite/lib/target-supports.exp 2005-12-08 08:35:47.000000000 -0500
@@ -24,9 +24,17 @@
# BASENAME is a basename to use for temporary files.
# TYPE is the type of compilation to perform (see target_compile).
# CONTENTS gives the contents of the input file.
-proc get_compiler_messages {basename type contents} {
+# The rest is optional:
+# OPTIONS: additional compiler options to use.
+proc get_compiler_messages {basename type contents args} {
global tool
+ if { [llength $args] > 0 } {
+ set options "additional_flags=[lindex $args 0]"
+ } else {
+ set options ""
+ }
+
set src ${basename}[pid].c
switch $type {
assembly { set output ${basename}[pid].s }
@@ -35,7 +43,7 @@ proc get_compiler_messages {basename typ
set f [open $src "w"]
puts $f $contents
close $f
- set lines [${tool}_target_compile $src $output $type ""]
+ set lines [${tool}_target_compile $src $output $type "$options"]
file delete $src
remote_file build delete $output
@@ -295,6 +303,55 @@ proc check_profiling_available { test_wh
return $profiling_available_saved
}
+# Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
+# emitted, 0 otherwise. Whether a shared library can actually be built is
+# out of scope for this test.
+#
+# When the target name changes, replace the cached result.
+
+proc check_effective_target_fpic { } {
+ global et_fpic_saved
+ global et_fpic_target_name
+
+ if { ![info exists et_fpic_target_name] } {
+ set et_fpic_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_fpic_target_name } {
+ verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
+ set et_fpic_target_name $current_target
+ if [info exists et_fpic_saved] {
+ verbose "check_effective_target_fpic: removing cached result" 2
+ unset et_fpic_saved
+ }
+ }
+
+ if [info exists et_fpic_saved] {
+ verbose "check_effective_target_fpic: using cached result" 2
+ } else {
+ verbose "check_effective_target_fpic: compiling source" 2
+
+ # Note that M68K has a multilib that supports -fpic but not
+ # -fPIC, so we need to check both. We test with a program that
+ # requires GOT references.
+ set et_fpic_saved [string match "" [get_compiler_messages fpic object {
+ extern int foo (void); extern int bar;
+ int baz (void) { return foo () + bar; }
+ } "-fpic"]]
+
+ if { $et_fpic_saved != 0 } {
+ set et_fpic_saved [string match "" [get_compiler_messages fpic object {
+ extern int foo (void); extern int bar;
+ int baz (void) { return foo () + bar; }
+ } "-fPIC"]]
+ }
+ }
+ verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
+ return $et_fpic_saved
+}
+
# Return true if iconv is supported on the target. In particular IBM-1047.
proc check_iconv_available { test_what } {