<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: thread-local storage doesnt work with gcc in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046200#M94658</link>
    <description>&amp;gt;I am using gcc 3.3.3 and want to compile some test code:&lt;BR /&gt;&lt;BR /&gt;As the error message says, you can't, yet.&lt;BR /&gt;3.4.3 works, at least on IPF.</description>
    <pubDate>Mon, 30 Jul 2007 22:32:39 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-07-30T22:32:39Z</dc:date>
    <item>
      <title>thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046199#M94657</link>
      <description>Hi all,&lt;BR /&gt;Is there a way to use thread-local storage with gcc compiler on HP-UX 11.11?&lt;BR /&gt;I am using gcc 3.3.3 and want to compile some test code:&lt;BR /&gt;&lt;BR /&gt;thread_locals_sub.c:&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;PTHREAD.H&gt;&lt;BR /&gt;&lt;BR /&gt;static __thread int i;&lt;BR /&gt;void *t(void *x) {&lt;BR /&gt; for(i = 0; i&amp;lt;100; i++)&lt;BR /&gt;  printf("%d: %d\n",pthread_self(),i);&lt;BR /&gt; return;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;CC lets me compile the thread_globals_sub object:&lt;BR /&gt;cc -c -o thread_globals_sub.o thread_globals_sub.c -lpthread&lt;BR /&gt;&lt;BR /&gt;But gcc comes up with an error:&lt;BR /&gt;gcc -c -o thread_globals_sub.o thread_globals_sub.c -lpthread&lt;BR /&gt;thread_globals_sub.c:5: error: thread-local storage not supported for this target&lt;BR /&gt;&lt;BR /&gt;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.&lt;/PTHREAD.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Mon, 30 Jul 2007 05:43:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046199#M94657</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-07-30T05:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046200#M94658</link>
      <description>&amp;gt;I am using gcc 3.3.3 and want to compile some test code:&lt;BR /&gt;&lt;BR /&gt;As the error message says, you can't, yet.&lt;BR /&gt;3.4.3 works, at least on IPF.</description>
      <pubDate>Mon, 30 Jul 2007 22:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046200#M94658</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-07-30T22:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046201#M94659</link>
      <description>With GCC you should use -pthread or -mt options instead of -lpthread.  -lpthread will add the pthread library but -pthread will add the library and add the -D_REENTRANT -D_THREAD_SAFE and -D_POSIX_C_SOURCE=199506L macro definitions during the compilation.  You still probably need a newer version of GCC than 3.3.3.</description>
      <pubDate>Tue, 31 Jul 2007 10:12:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046201#M94659</guid>
      <dc:creator>Steve Ellcey</dc:creator>
      <dc:date>2007-07-31T10:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046202#M94660</link>
      <description>I have tried it with the -pthread option, but it still does not work.&lt;BR /&gt;&lt;BR /&gt;After vacation I will try to test it with a newer version of gcc.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Aug 2007 12:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046202#M94660</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-08-02T12:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046203#M94661</link>
      <description>&amp;gt; [...] a newer version of gcc.&lt;BR /&gt;&lt;BR /&gt;They are up to 4.2.1, now.  I did better not&lt;BR /&gt;building Java, as there seems to be a known&lt;BR /&gt;out-of-memory problem in the middle of that,&lt;BR /&gt;but otherwise it seemed to go well enough on&lt;BR /&gt;11.11 (PA-RISC).</description>
      <pubDate>Thu, 02 Aug 2007 13:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046203#M94661</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-08-02T13:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046204#M94662</link>
      <description>I have installed the gcc-4.2.0, but it still doesn't work. &lt;BR /&gt;(/opt/hp-gcc-4.2.0/bin/gcc -c -pthread -o thread_globals_sub.o thread_globals_sub.c)&lt;BR /&gt;&lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;I will not update all these items. So I have to compile the object with the cc.&lt;BR /&gt;&lt;BR /&gt;Thanks for trying to help me.</description>
      <pubDate>Tue, 28 Aug 2007 02:58:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046204#M94662</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-08-28T02:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046205#M94663</link>
      <description>&amp;gt;I have installed the gcc-4.2.0, but it still doesn't work. &lt;BR /&gt;&lt;BR /&gt;What do you meant doesn't work?  You get the same error message?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;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.&lt;BR /&gt;&lt;BR /&gt;Static TLS should be supported on any 11.11.  Dynamic TLS needs 11.23.</description>
      <pubDate>Tue, 28 Aug 2007 14:10:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046205#M94663</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-08-28T14:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046206#M94664</link>
      <description>&amp;gt;What do you meant doesn't work? You get the same error message?&lt;BR /&gt;Yes, its the same error message with gcc 3.3.3 and 4.2.0:&lt;BR /&gt;thread_globals_sub.c:5: error: thread-local storage not supported for this target&lt;BR /&gt;&lt;BR /&gt;This is the output of the -v option of gcc 4.2.0:&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;XXX@YYY: ./gcc -v&lt;BR /&gt;Using built-in specs.&lt;BR /&gt;Target: hppa1.1-hp-hpux11.11&lt;BR /&gt;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++&lt;BR /&gt;Thread model: posix&lt;BR /&gt;gcc version 4.2.0&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Aug 2007 03:32:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046206#M94664</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-08-30T03:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046207#M94665</link>
      <description>Perhaps this is hinting you need to go to Integrity?  ;-)&lt;BR /&gt;&lt;BR /&gt;Steve would have to tell you why TLS doesn't seem to work.</description>
      <pubDate>Thu, 30 Aug 2007 03:49:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046207#M94665</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-08-30T03:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046208#M94666</link>
      <description>It looks like existing GCC's on the HP web site, including 4.2.1, were built without posix threads being enabled.  This is a configuration option specified when GCC is built.  The next (4.2.2, 4.3) GCC's will default to having posix threads being enabled by on HPPA 11.*.  If you build GCC yourself you could set --enable-threads=posix during configuration and then you would be able to use threads and thread local storage.</description>
      <pubDate>Thu, 30 Aug 2007 11:30:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046208#M94666</guid>
      <dc:creator>Steve Ellcey</dc:creator>
      <dc:date>2007-08-30T11:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046209#M94667</link>
      <description>&amp;gt;  It looks like existing GCC's on the HP web site, including 4.2.1, were built without posix threads being enabled.&lt;BR /&gt;&lt;BR /&gt;That's not true. The following code does compile with gcc 4.2.0 and works:&lt;BR /&gt;&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;PTHREAD.H&gt;&lt;BR /&gt;#define NUM_THREADS 4&lt;BR /&gt;&lt;BR /&gt;static void *Work(void *num);&lt;BR /&gt;&lt;BR /&gt;int main(void) {&lt;BR /&gt; int NumberOfThreads = NUM_THREADS;&lt;BR /&gt; pthread_t Worker[NUM_THREADS];&lt;BR /&gt;&lt;BR /&gt; int j, ret;&lt;BR /&gt; for(j = 0; j &amp;lt; NumberOfThreads; j++) {&lt;BR /&gt;  ret = pthread_create(&amp;amp;Worker[j], NULL, (void *)&amp;amp;Work, (void *)j);&lt;BR /&gt;  if(ret) {&lt;BR /&gt;   fprintf(stderr, "Error while Creating Threads\n");&lt;BR /&gt;   return -1;&lt;BR /&gt;  }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; for(j = 0; j &amp;lt; NumberOfThreads; j++) {&lt;BR /&gt;  pthread_join(Worker[j], NULL);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;static void *Work(void *num) {&lt;BR /&gt; int i;&lt;BR /&gt; for(i = 0; i &amp;lt; 100; i++) {&lt;BR /&gt;  int j;&lt;BR /&gt;  char buf[256]= {'\0'};&lt;BR /&gt;  for(j = 0; j &amp;lt; (int)num; j++) {&lt;BR /&gt;   sprintf(buf,"%s\t\t",buf);&lt;BR /&gt;  }&lt;BR /&gt;  printf("%s%d\n",buf, i);&lt;BR /&gt; }&lt;BR /&gt; return;&lt;BR /&gt;}&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;/opt/hp-gcc-4.2.0/bin/gcc -pthread -o parallel parallel.c &amp;amp;&amp;amp; ./parallel&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;So Pthreads work on my machine with GCC and CC, but TLS does only work with CC.&lt;BR /&gt;&lt;BR /&gt;MfG&lt;/PTHREAD.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Fri, 31 Aug 2007 03:31:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046209#M94667</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-08-31T03:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046210#M94668</link>
      <description>&amp;gt;but TLS does only work with cc.&lt;BR /&gt;&lt;BR /&gt;That's what Steve meant, gcc wasn't configured to handle the __thread keyword.</description>
      <pubDate>Fri, 31 Aug 2007 03:42:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046210#M94668</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-08-31T03:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046211#M94669</link>
      <description>Yes, but I thought that --enable-threads=posix enables Posix-Threads (including TLS). This option seems to be set in my version of GCC. Pthreads work in both compilers, instead for TLS.&lt;BR /&gt;&lt;BR /&gt;But maybe there is another Keyword that separately enables TLS-support.</description>
      <pubDate>Fri, 31 Aug 2007 03:51:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046211#M94669</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-08-31T03:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046212#M94670</link>
      <description>I did some more investigation and it looks like GCC only allows thread local storage if it sees that the assembler being used also supports it.  The 2.17 GNU assembler did not support thread local storage on PA and that is  why GCC is not allowing it (even if compiled with --enable-threads=posix.  The 2.18 GNU assembler has just recently been released and that assembler does allow thread local storage.</description>
      <pubDate>Tue, 04 Sep 2007 10:26:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046212#M94670</guid>
      <dc:creator>Steve Ellcey</dc:creator>
      <dc:date>2007-09-04T10:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: thread-local storage doesnt work with gcc</title>
      <link>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046213#M94671</link>
      <description>I think this answers my question.&lt;BR /&gt;Thank You</description>
      <pubDate>Mon, 10 Sep 2007 06:22:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/thread-local-storage-doesnt-work-with-gcc/m-p/4046213#M94671</guid>
      <dc:creator>Frank Mehlhose</dc:creator>
      <dc:date>2007-09-10T06:22:08Z</dc:date>
    </item>
  </channel>
</rss>

