Patchwork eliminate UNRESOLVED errors on attr-ifunc-1.[c,C]

login
register
mail settings
Submitter Nathan Sidwell
Date Sept. 15, 2010, 6:16 p.m.
Message ID <4C910D67.3050809@codesourcery.com>
Download mbox | patch
Permalink /patch/64879/
State New
Headers show

Comments

Nathan Sidwell - Sept. 15, 2010, 6:16 p.m.
On 09/14/10 11:16, Jack Howarth wrote:
>     Currently on targets like darwin which lack weak alias support in their
> object format, the gcc.dg/attr-ifunc-1.c and g++.dg/ext/attr-ifunc-1.C produce
> UNRESOLVED testsuite results...

Would you like to try this patch?  It correctly enables ifunc testing on my 
i686-pc-linux-gnu glibc 2.11 system

nathan
Rainer Orth - Sept. 16, 2010, 7:51 a.m.
Nathan Sidwell <nathan@codesourcery.com> writes:

> Would you like to try this patch?  It correctly enables ifunc testing on my
> i686-pc-linux-gnu glibc 2.11 system

I think this is the wrong approach: if the feature requires linker
and/or runtime linker support, the gcc/configure.ac check should check
for this and enable or disable it depending on the results.  I consider
it bad if the compiler accepts the code, only to fall down at link or
runtime.

And as I've asked before: what is required to make this work:

* Assembler support for @gnu_indirect_function (already checked in
  gcc/configure.ac)?

* Linker support?  What specifially?

* Runtime linker support?  Is this the purpose of your glibc 2.11 check:
  to test for ld.so.1 support?

Thanks.
	Rainer
Nathan Sidwell - Sept. 16, 2010, 8:06 a.m.
On 09/16/10 08:51, Rainer Orth wrote:
> Nathan Sidwell<nathan@codesourcery.com>  writes:
>
>> Would you like to try this patch?  It correctly enables ifunc testing on my
>> i686-pc-linux-gnu glibc 2.11 system
>
> I think this is the wrong approach: if the feature requires linker
> and/or runtime linker support, the gcc/configure.ac check should check
> for this and enable or disable it depending on the results.  I consider
> it bad if the compiler accepts the code, only to fall down at link or
> runtime.
>
> And as I've asked before: what is required to make this work:
>
> * Assembler support for @gnu_indirect_function (already checked in
>    gcc/configure.ac)?

correct
>
> * Linker support?  What specifially?

support for the ifunc relocations (both static and dynamic)

> * Runtime linker support?  Is this the purpose of your glibc 2.11 check:
>    to test for ld.so.1 support?

handling for the ifunc dynamic relocations.

nathan
Rainer Orth - Sept. 16, 2010, 8:16 a.m.
Nathan Sidwell <nathan@codesourcery.com> writes:

>> And as I've asked before: what is required to make this work:
>>
>> * Assembler support for @gnu_indirect_function (already checked in
>>    gcc/configure.ac)?
>
> correct
>>
>> * Linker support?  What specifially?
>
> support for the ifunc relocations (both static and dynamic)

Ok, so check for the GNU ld (and eventually gold) version that supports
this in gcc/configure.ac, and assume that other linkers don't have that
support.  If that assumption proves incorrect later, this can be handled
on a case-by-case basis.

>> * Runtime linker support?  Is this the purpose of your glibc 2.11 check:
>>    to test for ld.so.1 support?
>
> handling for the ifunc dynamic relocations.

No idea what's the best way to check this.

	Rainer
Jakub Jelinek - Sept. 16, 2010, 8:31 a.m.
On Thu, Sep 16, 2010 at 10:16:21AM +0200, Rainer Orth wrote:
> Ok, so check for the GNU ld (and eventually gold) version that supports
> this in gcc/configure.ac, and assume that other linkers don't have that
> support.  If that assumption proves incorrect later, this can be handled
> on a case-by-case basis.
> 
> >> * Runtime linker support?  Is this the purpose of your glibc 2.11 check:
> >>    to test for ld.so.1 support?
> >
> > handling for the ifunc dynamic relocations.
> 
> No idea what's the best way to check this.

Especially for cross compiling it can't be a runtime test, so the best
is to check __GLIBC__ and __GLIBC_MINOR__ IMHO (for the targets that
actually support it).

	Jakub

Patch

2010-09-15  Nathan Sidwell  <nathan@codesourcery.com>

	* lib/target-supports-dg.exp (dg-require_ifunc): Remove remnants
	of dg-require-alias.
	* lib/target-supports.exp (check_ifunc_available): Check known
	good GLIBC version.  Remove check_alias_available remnants.

Index: lib/target-supports-dg.exp
===================================================================
--- lib/target-supports-dg.exp	(revision 164285)
+++ lib/target-supports-dg.exp	(working copy)
@@ -94,12 +94,7 @@ 
 # test.
 
 proc dg-require-ifunc { args } {
-    set ifunc_available [ check_ifunc_available ]
-    if { $ifunc_available == -1 } {
-	upvar name name
-	unresolved "$name"
-    }
-    if { $ifunc_available < 2 } {
+    if { ![ check_ifunc_available ] } {
 	upvar dg-do-what dg-do-what
 	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
     }
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 164285)
+++ lib/target-supports.exp	(working copy)
@@ -372,12 +372,10 @@ 
 # proc check_ifunc_available { }
 ###############################
 
-# Determine if the target toolchain supports the alias attribute.
+# Determine if the target toolchain supports the ifunc attribute.
 
-# Returns 2 if the target supports aliases.  Returns 1 if the target
-# only supports weak aliased.  Returns 0 if the target does not
-# support aliases at all.  Returns -1 if support for aliases could not
-# be determined.
+# Returns 1 if the target supports ifunc.  Returns 0 if the target
+# does not support ifunc.
 
 proc check_ifunc_available { } {
     global ifunc_available_saved
@@ -390,26 +388,22 @@ 
 	set obj ifunc[pid].o
         verbose "check_ifunc_available  compiling testfile $src" 2
 	set f [open $src "w"]
-	# Compile a small test program.  The definition of "g" is
-	# necessary to keep the Solaris assembler from complaining
-	# about the program.
-	puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
-	puts $f "void g() {} void f() __attribute__((ifunc(\"g\")));"
+	puts $f "#include <features.h>"
+	puts $f "#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)"
+	puts $f "#error FOO"
+	puts $f "#endif"
+	puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
+	puts $f "void g() {}"
+	puts $f "void f() __attribute__((ifunc(\"g\")));"
 	close $f
 	set lines [${tool}_target_compile $src $obj object ""]
 	file delete $src
 	remote_file build delete $obj
 
 	if [string match "" $lines] then {
-	    # No error messages, everything is OK.
-	    set ifunc_available_saved 2
+	    set ifunc_available_saved 1
 	} else {
-	    if [regexp "ifunc is not supported" $lines] {
-		verbose "check_ifunc_available  target does not support ifunc" 2
-		set ifunc_available_saved 0
-	    } else {
-		set ifunc_available_saved -1
-	    }
+	    set ifunc_available_saved 0
 	}
 
 	verbose "check_ifunc_available  returning $ifunc_available_saved" 2