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%
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?
> 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.
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?
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
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.
(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?
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
Mine.
Patch here: http://gcc.gnu.org/ml/gcc-patches/2010-01/msg01508.html
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
Fixed for 4.5.0.