While trying to build current mainline with Sun as and GNU ld 2.19 on
sparc-sun-solaris2.11, libgomp failed to link with the following error:

/vol/gcc/lib/gld-2.19: gomp_thread_attr: TLS reference in .libs/team.o
mismatches non-TLS reference in .libs/env.o
.libs/team.o: could not read symbols: Bad value

Further investigation revealed that this is due to a gcc bug: consider the
following testcase:

__thread int tsd;
int non_tsd;

[EMAIL PROTECTED] 1510 > ./xgcc -B./ -c ~/tls.c 
[EMAIL PROTECTED] 1511 > readelf -s tls.o|grep tsd
     3: 00000004     4 TLS     GLOBAL DEFAULT  COM non_tsd
     4: 00000000     4 TLS     GLOBAL DEFAULT    2 tsd
[EMAIL PROTECTED] 1512 > /opt/onstudio12/SUNWspro/bin/cc -c ~/tls.c 
[EMAIL PROTECTED] 1513 > readelf -s tls.o|grep tsd
     9: 00000004     4 TLS     GLOBAL DEFAULT  COM tsd
    10: 00000004     4 OBJECT  GLOBAL DEFAULT  COM non_tsd

I.e. if compiled with gcc, both objects are marked as tls, while Sun Studio 12
cc correctly only marks tsd as TLS.

The same bug exists in gcc 4.3, 4.2 and 4.1.


-- 
           Summary: gcc emits non-TLS data as TLS on Solaris 11/SPARC
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ro at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.11
  GCC host triplet: sparc-sun-solaris2.11
GCC target triplet: sparc-sun-solaris2.11


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38118

Reply via email to