- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: thread-local storage doesnt work with gcc
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 10:43 PM
тАО07-29-2007 10:43 PM
Is there a way to use thread-local storage with gcc compiler on HP-UX 11.11?
I am using gcc 3.3.3 and want to compile some test code:
thread_locals_sub.c:
--------------------------------------------------
#include
#include
static __thread int i;
void *t(void *x) {
for(i = 0; i<100; i++)
printf("%d: %d\n",pthread_self(),i);
return;
}
--------------------------------------------------
CC lets me compile the thread_globals_sub object:
cc -c -o thread_globals_sub.o thread_globals_sub.c -lpthread
But gcc comes up with an error:
gcc -c -o thread_globals_sub.o thread_globals_sub.c -lpthread
thread_globals_sub.c:5: error: thread-local storage not supported for this target
It would be nice if I could make the object with the gcc. Or if there is no way, then it would be nice to know the reason.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 03:32 PM
тАО07-30-2007 03:32 PM
Re: thread-local storage doesnt work with gcc
As the error message says, you can't, yet.
3.4.3 works, at least on IPF.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 03:12 AM
тАО07-31-2007 03:12 AM
Re: thread-local storage doesnt work with gcc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2007 05:06 AM
тАО08-02-2007 05:06 AM
Re: thread-local storage doesnt work with gcc
After vacation I will try to test it with a newer version of gcc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2007 06:00 AM
тАО08-02-2007 06:00 AM
Re: thread-local storage doesnt work with gcc
They are up to 4.2.1, now. I did better not
building Java, as there seems to be a known
out-of-memory problem in the middle of that,
but otherwise it seemed to go well enough on
11.11 (PA-RISC).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 07:58 PM
тАО08-27-2007 07:58 PM
Re: thread-local storage doesnt work with gcc
(/opt/hp-gcc-4.2.0/bin/gcc -c -pthread -o thread_globals_sub.o thread_globals_sub.c)
I assume that some of the system librarys are too old, or that the linker has the wrong version. Both, the librarys and the linker have to support TLS. But I'am not sure about it.
I will not update all these items. So I have to compile the object with the cc.
Thanks for trying to help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2007 07:10 AM
тАО08-28-2007 07:10 AM
Re: thread-local storage doesnt work with gcc
What do you meant doesn't work? You get the same error message?
>I assume that some of the system libraries are too old, or that the linker has the wrong version. Both, the libraries and the linker have to support TLS.
Static TLS should be supported on any 11.11. Dynamic TLS needs 11.23.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2007 08:32 PM
тАО08-29-2007 08:32 PM
Re: thread-local storage doesnt work with gcc
Yes, its the same error message with gcc 3.3.3 and 4.2.0:
thread_globals_sub.c:5: error: thread-local storage not supported for this target
This is the output of the -v option of gcc 4.2.0:
--------------------------------------------------
XXX@YYY: ./gcc -v
Using built-in specs.
Target: hppa1.1-hp-hpux11.11
Configured with: /tmp/gcc-4.2.0.tar.gz/gcc-4.2.0/configure --host=hppa1.1-hp-hpux11.11 --target=hppa1.1-hp-hpux11.11 --build=hppa1.1-hp-hpux11.11 --prefix=/opt/hp-gcc-4.2.0 --with-gnu-as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-threads=posix --enable-languages=c,c++
Thread model: posix
gcc version 4.2.0
--------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2007 08:49 PM
тАО08-29-2007 08:49 PM
Re: thread-local storage doesnt work with gcc
Steve would have to tell you why TLS doesn't seem to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 04:30 AM
тАО08-30-2007 04:30 AM
Re: thread-local storage doesnt work with gcc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:31 PM
тАО08-30-2007 08:31 PM
Re: thread-local storage doesnt work with gcc
That's not true. The following code does compile with gcc 4.2.0 and works:
--------------------------------------------------
#include
#include
#define NUM_THREADS 4
static void *Work(void *num);
int main(void) {
int NumberOfThreads = NUM_THREADS;
pthread_t Worker[NUM_THREADS];
int j, ret;
for(j = 0; j < NumberOfThreads; j++) {
ret = pthread_create(&Worker[j], NULL, (void *)&Work, (void *)j);
if(ret) {
fprintf(stderr, "Error while Creating Threads\n");
return -1;
}
}
for(j = 0; j < NumberOfThreads; j++) {
pthread_join(Worker[j], NULL);
}
return 0;
}
static void *Work(void *num) {
int i;
for(i = 0; i < 100; i++) {
int j;
char buf[256]= {'\0'};
for(j = 0; j < (int)num; j++) {
sprintf(buf,"%s\t\t",buf);
}
printf("%s%d\n",buf, i);
}
return;
}
--------------------------------------------------
/opt/hp-gcc-4.2.0/bin/gcc -pthread -o parallel parallel.c && ./parallel
--------------------------------------------------
So Pthreads work on my machine with GCC and CC, but TLS does only work with CC.
MfG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:42 PM
тАО08-30-2007 08:42 PM
Re: thread-local storage doesnt work with gcc
That's what Steve meant, gcc wasn't configured to handle the __thread keyword.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:51 PM
тАО08-30-2007 08:51 PM
Re: thread-local storage doesnt work with gcc
But maybe there is another Keyword that separately enables TLS-support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2007 03:26 AM
тАО09-04-2007 03:26 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2007 11:22 PM
тАО09-09-2007 11:22 PM
Re: thread-local storage doesnt work with gcc
Thank You