Bug 50683 - GCC compiles MPFR 3.1.0 wrongly on sparc
Summary: GCC compiles MPFR 3.1.0 wrongly on sparc
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Eric Botcazou
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-10-09 23:21 UTC by Laurent Fousse
Modified: 2011-10-19 07:00 UTC (History)
5 users (show)

See Also:
Host:
Target: sparc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-10-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Fousse 2011-10-09 23:21:05 UTC

    
Comment 1 Laurent Fousse 2011-10-09 23:26:43 UTC
gcc fails to build MPFR 3.1.0 on sparc. You can get a full build log from:

http://bugs.debian.org/644552

This new release of MPFR introduces TLS support. The build is successful when building withouth TLS support, or when using -O0 instead of -O3.

When trying version 4.4.6 (Debian 4.4.6-11) the same tests fail. When building with version 4.5.3 (Debian 4.5.3-9) the same tests fail except for tsqrt which passes correctly.
Comment 2 Richard Biener 2011-10-10 09:43:16 UTC
We need a testcase.
Comment 3 Andrew Pinski 2011-10-10 20:15:24 UTC
Most likely related to bug 50691.
Comment 4 Eric Botcazou 2011-10-16 11:25:03 UTC
Investigating.
Comment 5 Eric Botcazou 2011-10-16 14:45:36 UTC
Ugh, annoying linker relaxation bug.  The compiler correctly generates:

	add	%l7, %l3, %l3, %tgd_add(__gmpfr_flags)
[...]
	call	__tls_get_addr, %tgd_call(__gmpfr_flags)
	 mov	%l3, %o0
	ld	[%o0], %g1

but the linker turns this into:

   0x00014d14 <+504>:   add  %g7, %o0, %o0
   0x00014d18 <+508>:   mov  %l3, %o0
   0x00014d1c <+512>:   ld  [ %o0 ], %g1

so segfault on the load.

Filed as http://sourceware.org/bugzilla/show_bug.cgi?id=13301 for the linker.

Should we put a workaround in the compiler?
Comment 6 David S. Miller 2011-10-17 01:52:02 UTC
I would suggest against a gcc workaround, let's just fix binutils.
I have posted a fix to the binutils list for testing.
Comment 7 Eric Botcazou 2011-10-17 17:40:30 UTC
> I would suggest against a gcc workaround, let's just fix binutils.
> I have posted a fix to the binutils list for testing.

OK, I don't have a strong opinion.  What do the Debian folks think about it?
Comment 8 Eric Botcazou 2011-10-19 07:00:06 UTC
The problem will be fixed in the upcoming binutils 2.22 release.