This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
multiple defs. of TLS common symbols?
- From: Gary Funck <gary at intrepid dot com>
- To: GCC List <gcc at gcc dot gnu dot org>
- Date: Wed, 13 Jan 2010 11:33:06 -0800
- Subject: multiple defs. of TLS common symbols?
We use TLS relocated symbols to create thread-local symbols
in the GCC UPC compiler, and have run into an issue illustrated
by the following program, on a test case that defines a
common symbol in several files, and uses it in a single file.
The following program fails to link, with multiple defs:
% head s.c t.c main.c
==> s.c <==
__thread int x;
==> t.c <==
__thread int x;
==> main.c <==
__thread int x;
int main()
{
x = 1;
}
% gcc s.c t.c main.c
/tmp/ccK5Aj3k.o:(.tbss+0x0): multiple definition of `x'
/tmp/ccm0kY5f.o:(.tbss+0x0): first defined here
/tmp/ccchPiAt.o:(.tbss+0x0): multiple definition of `x'
/tmp/ccm0kY5f.o:(.tbss+0x0): first defined here
collect2: ld returned 1 exit status
But if we don't use TLS storage, it all links just fine:
% gcc -D__thread= s.c t.c main.c
Off-hand this looks like it might be a linker issue, but
perhaps there's an issue with the use of __thread in
in the context above?