Bug 29986 - testsuite failures
Summary: testsuite failures
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgomp (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Rainer Orth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-26 09:08 UTC by Eric Botcazou
Modified: 2010-10-27 17:06 UTC (History)
3 users (show)

See Also:
Host: sparc-sun-solaris2.10
Target: sparc-sun-solaris2.10
Build: sparc-sun-solaris2.10
Known to work:
Known to fail:
Last reconfirmed: 2010-01-29 17:34:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Botcazou 2006-11-26 09:08:10 UTC
All the testsuite failures (except libgomp.c++/ctor-9.C) with Sun as/ld
  http://gcc.gnu.org/ml/gcc-testresults/2006-11/msg00764.html
are of the form:

ld: fatal: relocation error: R_SPARC_TLS_LE_HIX22: file /var/tmp//ccuoqyTO.o:
  symbol <unknown>: bad symbol type SECT: symbol type must be TLS

It's a Sun ld problem (GNU ld silently groks the same object file), which can
be reproduced with the Sun toolchain:

hikaru% cc -V
cc: Sun C 5.8 Patch 121015-03 2006/10/18
usage: cc [ options] files.  Use 'cc -flags' for details
hikaru% cat t.c
static __thread int i = 1;

int main(void)
{
  return i;
}
hikaru% cc -S t.c -O
hikaru% cc -o t t.s
ld: fatal: relocation error: R_SPARC_TLS_IE_HI22: file t.o: symbol <unknown>: bad symbol type SECT: symbol type must be TLS
hikaru% cc -o t t.c -O
hikaru%
Comment 1 Kaveh Ghazi 2006-11-26 14:02:53 UTC
Is this a known bug or do we need to report it to Sun?

If known, is there a patch we can recommend in the Solaris-specific installation docs?
Comment 2 Eric Botcazou 2006-11-26 14:35:03 UTC
> Is this a known bug or do we need to report it to Sun?

I quickly skimmed through Sun linker patches but didn't find anything.
The problem is of course that all works flawlessly with the Sun toolchain
in default mode (i.e. without going through the .s file) so you need to use
either GCC or the "convoluted" mode to demonstrate the problem.
Comment 3 Kaveh Ghazi 2006-12-29 04:45:36 UTC
I think the first step is to report it to sun so they track it and hopefully one day fix their toolchain.  Does anyone have a support contract who can file a report?
Comment 4 Ryan Johnson 2008-04-09 15:18:38 UTC
If it's any help, adding some inline asm to the file makes the Sun toolchain croak on my machine.

SunOS 5.10 Generic_118833-23 sun4v sparc SUNW,Sun-Fire-T200
Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12
Solaris Link Editors: 5.10-1.482

// begin tls-bug.c
void membar_producer() { asm volatile("membar #StoreStore"); }
static __thread bool val;
int main() { return val; }
// end tls-bug.c

This bug seems to show up in arbitrary ways for each of the three compilers on my machine:
$ cc -V
cc: Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12
$ gcc -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with: /gates/sfw10/builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
$ ~/apps/gcc/4.3/bin/gcc-4.3 -v
Using built-in specs.
Target: sparc64-sun-solaris2.10
Configured with: ../configure --prefix=/export/home/ryanjohn/apps/gcc/4.3 --build=sparc64-sun-solaris2.10 --program-suffix=-4.3 --with-mpfr=/export/home/ryanjohn/apps --with-gmp=/export/home/ryanjohn/apps --disable-multilib --with-as=/usr/ccs/bin/as --without-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld
Thread model: posix
gcc version 4.3.0 (GCC) 

Note that all three use the same copy of ld

$ cc tls-bug.c
$ cc -g tls-bug.c

$ CC tls-bug.c
ld: fatal: relocation error: R_SPARC_TLS_GD_HI22: file tls-bug.o: symbol<unknown>: bad symbol type SECT: symbol type must be TLS
$ CC -g tls-bug.c

$ gcc -m64 tls-bug.c
$ gcc -m64 -g tls-bug.c
ld: fatal: relocation error: R_SPARC_TLS_DTPOFF64: file /var/tmp//ccuJHWqp.o: symbol done: offset 0xffffffff7d901c33 is non-aligned
collect2: ld returned 1 exit status

$ gcc-4.3 tls-bug.c
ld: fatal: relocation error: R_SPARC_TLS_LE_HIX22: file /var/tmp//ccUeK1AZ.o: symbol <unknown>: bad symbol type SECT: symbol type must be TLS
collect2: ld returned 1 exit status
$ gcc-4.3 tls-bug.c -g
ld: fatal: relocation error: R_SPARC_TLS_LE_HIX22: file /var/tmp//cceRP4ZP.o: symbol <unknown>: bad symbol type SECT: symbol type must be TLS
collect2: ld returned 1 exit status
Comment 5 Rainer Orth 2010-01-26 15:35:44 UTC
I've found that the problem doesn't occur when assembler patch 118683-03 is
installed.  If I compare the relocations produced by as from patch 118683-02 with
those produced by patch 118683-03, I find some differences (elfdump -r output):

--- /vol/gcc/obj/gcc-4.5.0-20100107/10-gcc/sparc-sun-solaris2.10/libgomp/testsuite/ctor-5.elfdump-r     2010-01-26 16:19:54.304447900 +0100
+++ ctor-5.elfdump-r    2010-01-26 16:19:48.584176600 +0100
@@ -21,10 +21,10 @@
   R_SPARC_LO10                   0x90          0  .rela.text     _ZN1B5countE
   R_SPARC_HI22                   0xc4          0  .rela.text     _ZN1B8expectedE
   R_SPARC_LO10                   0xc8          0  .rela.text     _ZN1B8expectedE
-  R_SPARC_TLS_LE_HIX22           0xcc          0  .rela.text     .tbss (section)
-  R_SPARC_TLS_LE_LOX10           0xd0          0  .rela.text     .tbss (section)
-  R_SPARC_TLS_LE_HIX22           0xdc          0  .rela.text     .tbss (section)
-  R_SPARC_TLS_LE_LOX10           0xe0          0  .rela.text     .tbss (section)
+  R_SPARC_TLS_LE_HIX22           0xcc          0  .rela.text     _ZL3thr
+  R_SPARC_TLS_LE_LOX10           0xd0          0  .rela.text     _ZL3thr
+  R_SPARC_TLS_LE_HIX22           0xdc          0  .rela.text     _ZL3thr
+  R_SPARC_TLS_LE_LOX10           0xe0          0  .rela.text     _ZL3thr
   R_SPARC_HI22                   0xf0      0x1a0  .rela.text     .text (section)
   R_SPARC_LO10                   0xf4      0x1a0  .rela.text     .text (section)
   R_SPARC_WDISP30               0x100          0  .rela.text     GOMP_parallel_start
@@ -47,8 +47,8 @@
   R_SPARC_WDISP30               0x1e0          0  .rela.text     omp_get_num_threads
   R_SPARC_HI22                  0x1ec          0  .rela.text     _ZL8nthreads
   R_SPARC_LO10                  0x1f0          0  .rela.text     _ZL8nthreads
-  R_SPARC_TLS_LE_HIX22          0x208          0  .rela.text     .tbss (section)
-  R_SPARC_TLS_LE_LOX10          0x20c          0  .rela.text     .tbss (section)
+  R_SPARC_TLS_LE_HIX22          0x208          0  .rela.text     _ZL3thr
+  R_SPARC_TLS_LE_LOX10          0x20c          0  .rela.text     _ZL3thr
   R_SPARC_WDISP30               0x21c          0  .rela.text     _ZN1BaSERKS_
 
 Relocation Section:  .rela.eh_frame

In the broken object, the relocations are relative to the .tbss section, in the
working one, they are relative to a symbol.

I strongly suppose this is due to the fix for 

6728528  assembler does not handle __thread code correctly

although

  http://bugs.sun.com/view_bug.do?bug_id=6728528

doesn't provide much detail.
Comment 6 Kaveh Ghazi 2010-01-26 16:31:17 UTC
(In reply to comment #5)
> I've found that the problem doesn't occur when assembler patch 118683-03 is
> installed.

If this issue is fixed, perhaps you could add a note to:
http://gcc.gnu.org/install/specific.html#x-x-solaris2

describe the bug and mention which patch fixes it, then close this PR?
Comment 7 ro@CeBiTec.Uni-Bielefeld.DE 2010-01-26 16:38:31 UTC
Subject: Re:  testsuite failures

> ------- Comment #6 from ghazi at gcc dot gnu dot org  2010-01-26 16:31 -------
> (In reply to comment #5)
>> I've found that the problem doesn't occur when assembler patch 118683-03 is
>> installed.
>
> If this issue is fixed, perhaps you could add a note to:
> http://gcc.gnu.org/install/specific.html#x-x-solaris2
>
> describe the bug and mention which patch fixes it, then close this PR?

Sure, will do.  It's on my list.

	Rainer
Comment 8 Rainer Orth 2010-01-29 17:34:30 UTC
Mine.
Comment 9 Rainer Orth 2010-01-29 17:37:28 UTC
Patch here:

  http://gcc.gnu.org/ml/gcc-patches/2010-01/msg01508.html
Comment 10 Rainer Orth 2010-02-01 13:35:23 UTC
Subject: Bug 29986

Author: ro
Date: Mon Feb  1 13:35:10 2010
New Revision: 156427

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156427
Log:
	PR libgomp/29986
	* doc/install.texi (Specific): Add sparc-sun-solaris2.10 entry.
	Document fix for TLS bug.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/install.texi

Comment 11 Rainer Orth 2010-02-01 13:36:56 UTC
Fixed for 4.5.0.