* [3.3.1]: thread local storage - what do I need?
@ 2003-08-20 18:58 Marshall, Simon
2003-08-20 19:32 ` gcc 3.2 Irix6.5 compiler error Vadim Iosifovich Vaynerman
0 siblings, 1 reply; 2+ messages in thread
From: Marshall, Simon @ 2003-08-20 18:58 UTC (permalink / raw)
To: 'gcc-help@gcc.gnu.org'
Hi, I've been trying to use the thread local storage "__thread"
attribute with gcc (gcc-3.3.1) and SuSE 8.2 (Linux 2.4.20-4GB) without
any success. The GCC manual says TLS requires support from ld, ld.so,
libc.so and libpthread.so, but I cannot find out exactly what I need,
whether I have it and how I get it.
I have a function defined in file __thread.cpp as:
#include <stdio.h>
#include <pthread.h>
__thread // make "p" thread-local.
pthread_t p = 0;
extern "C" void *foo (void *)
{
int j = 0;
p = pthread_self();
printf ("thread %d starts\n", p); fflush (stdout);
for (int i = 0; i < 10 * 1000 * 1000; i++)
j += i;
printf ("thread %d ends\n", p); fflush (stdout);
return NULL;
}
I build a shared library like this:
gcc -g -D_REENTRANT -fpic -W -c __thread.cpp -o __thread.o # don't
need -ftls-model= here
gcc -shared __thread.o -o lib__thread.so
I then link the library to a file containing main() that creates several
threads running function foo() like this:
gcc -g -D_REENTRANT -fpic -W -L. -l__thread -lpthread __threadmain.cpp
./lib__thread.so: undefined reference to `___tls_get_addr'
collect2: ld returned 1 exit status
Does this mean I don't have the necessary support for TLS? What do I
need to get support for it? If I build without the __thread attribute
it works (except that p has a single value of course). With that
executable I also get:
% ldd ./a.out
libpthread.so.0 => /lib/libpthread.so.0 (0x40022000)
libc.so.6 => /lib/libc.so.6 (0x40073000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Please can you shed any light on this or show me where to look? Thanks,
Simon.
Simon Marshall, Misys Risk Management Systems
1 St. George's Road, Wimbledon, London SW19 4DR, UK
Email: simon.marshall@misys.com Web: www.misys.com
Phone: +44 20 8879 1188 Fax: +44 20 8879 1764
NB: FWIW, if I just build an executable from a file with both main() and
foo(), i.e., not a shared library, then the build is OK but SEGVs at the
call to pthread_self() like this:
% gcc -g -D_REENTRANT -fpic -lpthread thread__.cpp
% ./a.out
Segmentation fault
% ldd ./a.out # Get this!?
not a dynamic executable
% gdb ./a.out
(gdb) run
Starting program: /home/marshals/tmp/a.out
[New Thread 16384 (LWP 9493)]
[New Thread 32769 (LWP 9494)]
[New Thread 16386 (LWP 9495)]
[New Thread 32771 (LWP 9496)]
[New Thread 49156 (LWP 9497)]
[New Thread 65541 (LWP 9498)]
BFD: BFD 2.13.90 20020903 assertion fail libbfd.c:1132
[repeats]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 65541 (LWP 9498)]
0x08048635 in foo () at thread__.cpp:12
12 p = pthread_self();
^ permalink raw reply [flat|nested] 2+ messages in thread
* gcc 3.2 Irix6.5 compiler error
2003-08-20 18:58 [3.3.1]: thread local storage - what do I need? Marshall, Simon
@ 2003-08-20 19:32 ` Vadim Iosifovich Vaynerman
0 siblings, 0 replies; 2+ messages in thread
From: Vadim Iosifovich Vaynerman @ 2003-08-20 19:32 UTC (permalink / raw)
To: Marshall, Simon; +Cc: 'gcc-help@gcc.gnu.org'
Hello all,
I was building gcc 3.2 as a cross-compiler from i686 linux to
mips-sgi-irix6.5. I used the following configure command:
./configure --target=mips-sgi-irix6.5 --with-bfd-assembler --with-gnu-as
--with-gnu-ld --program-suffix=-mips --prefix=/home/dimav/mipsgcc
--enable-targets=mips-sgi-irix6.5
Binutils configured and built fine, I configured the gcc 3.2 core, but
when I did make, i got the following error:
/include -g -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I.
-I. -I./. -I./config
-I./../include -DL_muldi3 -c ./libgcc2.c -o libgcc/./_muldi3.oas:
unrecognized option `-O0'
make[2]: *** [libgcc/./_muldi3.o] Error 1
What went wrong, and is there a way for me to create a MIPS
cross-compiler for i686-linux by using GCC 3.2?
Thanks for everybody's help.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-20 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-20 18:58 [3.3.1]: thread local storage - what do I need? Marshall, Simon
2003-08-20 19:32 ` gcc 3.2 Irix6.5 compiler error Vadim Iosifovich Vaynerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).