multiple defs. of TLS common symbols?
Gary Funck
gary@intrepid.com
Wed Jan 13 19:33:00 GMT 2010
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?
More information about the Gcc
mailing list