public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Understanding Threads
@ 2012-06-05 14:28 parc
  2012-06-05 17:54 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: parc @ 2012-06-05 14:28 UTC (permalink / raw)
  To: gcc-help


Hello,

I'm trying to install gcc-4.7 and have problems with the posix threads,
especially with the PTHREAD_ONCE_INIT decalration in the pthread.h file.
When installing, it often ends up with this 

error: ‘PTHREAD_ONCE_INIT’ undeclared here (not in a function)  static
pthread_once_t create_key_once = PTHREAD_ONCE_INIT;

So, it would be very helpful to understand what the definition of
"PTHREAD_ONCE_INIT" is about. If it's a fixed size or address value and what
it's role when handling threads. 
Moreover there are some different versions of pthread. The one wich created
the error above, i can't find now. 
-- 
View this message in context: http://old.nabble.com/Understanding-Threads-tp33964421p33964421.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Understanding Threads
  2012-06-05 14:28 Understanding Threads parc
@ 2012-06-05 17:54 ` Jonathan Wakely
  2012-06-06 19:14   ` parc
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2012-06-05 17:54 UTC (permalink / raw)
  To: parc; +Cc: gcc-help

On 5 June 2012 15:28, parc wrote:
>
> Hello,
>
> I'm trying to install gcc-4.7 and have problems with the posix threads,
> especially with the PTHREAD_ONCE_INIT decalration in the pthread.h file.
> When installing, it often ends up with this
>
> error: ‘PTHREAD_ONCE_INIT’ undeclared here (not in a function)  static
> pthread_once_t create_key_once = PTHREAD_ONCE_INIT;

That error message would have said which file and line the error came
from, but you have omitted that essential information.


> So, it would be very helpful to understand what the definition of
> "PTHREAD_ONCE_INIT" is about. If it's a fixed size or address value and what
> it's role when handling threads.

It doesn't come from GCC. See 'man pthread_once' or
http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_once.html for
details.

> Moreover there are some different versions of pthread. The one wich created
> the error above, i can't find now.

Noone will be able to help you unless you provide more information.
What are you trying to do?  You say installing GCC, but you also say
it "often ends up with" an error which shouldn't come from GCC.
Describe *exactly* what you are doing, provide the exact commands you
used and the exact output and what platform you are working on.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Understanding Threads
  2012-06-05 17:54 ` Jonathan Wakely
@ 2012-06-06 19:14   ` parc
  2012-06-06 22:36     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: parc @ 2012-06-06 19:14 UTC (permalink / raw)
  To: gcc-help


The error comes up, when xgcc, in the object directory, compiles the
libgcc/unwind-dw2.c file from the source directory into the object
directory. "/usr/local/zich" is the objdir ; "usr/local/gcc-4.7.0" the
srcdir. 
Maybe i setup something wrong on the configuration. But the libpthread.so
library seems to work fine when compiling code under gcc 4.6.1 with the
"-phtread" compiler option. I think this option should somehow be invoked
for the make scripts of gcc 4.7.0. But i don't know how and where to set it.


/usr/local/zich/./gcc/xgcc -B/usr/local/zich/./gcc/
-B/usr/i686-linux-gnu/bin/ -B/usr/i686-linux-gnu/lib/ -isystem
/usr/i686-linux-gnu/include -isystem /usr/i686-linux-gnu/sys-include    -g
-O2 -O2  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem
./include   -fpic -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  
-fpic -I. -I. -I../.././gcc -I../../../gcc-4.7.0/./libgcc
-I../../../gcc-4.7.0/./libgcc/. -I../../../gcc-4.7.0/./libgcc/../gcc
-I../../../gcc-4.7.0/./libgcc/../include
-I../../../gcc-4.7.0/./libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT  
-DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep
-fexceptions -c ../../../gcc-4.7.0/./libgcc/unwind-dw2.c -fvisibility=hidden
-DHIDE_EXPORTS
In file included from ../../../gcc-4.7.0/./libgcc/gthr.h:150:0,
                 from ../../../gcc-4.7.0/./libgcc/unwind-dw2.c:38:
./gthr-default.h:140:1: error: ‘pthread_once’ undeclared here (not in a
function)
./gthr-default.h:141:1: error: ‘pthread_getspecific’ undeclared here (not in
a function)
./gthr-default.h:142:1: error: ‘pthread_setspecific’ undeclared here (not in
a function)
./gthr-default.h:144:1: error: ‘pthread_create’ undeclared here (not in a
function)
./gthr-default.h:145:1: error: ‘pthread_join’ undeclared here (not in a
function)
./gthr-default.h:146:1: error: ‘pthread_equal’ undeclared here (not in a
function)
./gthr-default.h:147:1: error: ‘pthread_self’ undeclared here (not in a
function)
./gthr-default.h:148:1: error: ‘pthread_detach’ undeclared here (not in a
function)
./gthr-default.h:150:1: error: ‘pthread_cancel’ undeclared here (not in a
function)
./gthr-default.h:152:1: error: ‘sched_yield’ undeclared here (not in a
function)
./gthr-default.h:154:1: error: ‘pthread_mutex_lock’ undeclared here (not in
a function)
./gthr-default.h:155:1: error: ‘pthread_mutex_trylock’ undeclared here (not
in a function)
./gthr-default.h:157:1: error: ‘pthread_mutex_timedlock’ undeclared here
(not in a function)
./gthr-default.h:159:1: error: ‘pthread_mutex_unlock’ undeclared here (not
in a function)
./gthr-default.h:160:1: error: ‘pthread_mutex_init’ undeclared here (not in
a function)
./gthr-default.h:161:1: error: ‘pthread_mutex_destroy’ undeclared here (not
in a function)
./gthr-default.h:163:1: error: ‘pthread_cond_init’ undeclared here (not in a
function)
./gthr-default.h:164:1: error: ‘pthread_cond_broadcast’ undeclared here (not
in a function)
./gthr-default.h:165:1: error: ‘pthread_cond_signal’ undeclared here (not in
a function)
./gthr-default.h:166:1: error: ‘pthread_cond_wait’ undeclared here (not in a
function)
./gthr-default.h:167:1: error: ‘pthread_cond_timedwait’ undeclared here (not
in a function)
./gthr-default.h:168:1: error: ‘pthread_cond_destroy’ undeclared here (not
in a function)
./gthr-default.h:171:1: error: ‘pthread_key_create’ undeclared here (not in
a function)
./gthr-default.h:172:1: error: ‘pthread_key_delete’ undeclared here (not in
a function)
./gthr-default.h:173:1: error: ‘pthread_mutexattr_init’ undeclared here (not
in a function)
./gthr-default.h:174:1: error: ‘pthread_mutexattr_settype’ undeclared here
(not in a function)
./gthr-default.h:175:1: error: ‘pthread_mutexattr_destroy’ undeclared here
(not in a function)
./gthr-default.h: In function ‘__gthread_create’:
./gthr-default.h:681:35: error: called object ‘__gthrw_pthread_create’ is
not a function
./gthr-default.h: In function ‘__gthread_join’:
./gthr-default.h:687:33: error: called object ‘__gthrw_pthread_join’ is not
a function
./gthr-default.h: In function ‘__gthread_detach’:
./gthr-default.h:693:35: error: called object ‘__gthrw_pthread_detach’ is
not a function
./gthr-default.h: In function ‘__gthread_equal’:
./gthr-default.h:699:34: error: called object ‘__gthrw_pthread_equal’ is not
a function
./gthr-default.h: In function ‘__gthread_self’:
./gthr-default.h:705:33: error: called object ‘__gthrw_pthread_self’ is not
a function
./gthr-default.h: In function ‘__gthread_yield’:
./gthr-default.h:711:32: error: called object ‘__gthrw_sched_yield’ is not a
function
./gthr-default.h: In function ‘__gthread_once’:
./gthr-default.h:718:35: error: called object ‘__gthrw_pthread_once’ is not
a function
./gthr-default.h: In function ‘__gthread_key_create’:
./gthr-default.h:726:39: error: called object ‘__gthrw_pthread_key_create’
is not a function
./gthr-default.h: In function ‘__gthread_key_delete’:
./gthr-default.h:732:39: error: called object ‘__gthrw_pthread_key_delete’
is not a function
./gthr-default.h: In function ‘__gthread_getspecific’:
./gthr-default.h:738:40: error: called object ‘__gthrw_pthread_getspecific’
is not a function
./gthr-default.h: In function ‘__gthread_setspecific’:
./gthr-default.h:744:40: error: called object ‘__gthrw_pthread_setspecific’
is not a function
./gthr-default.h: In function ‘__gthread_mutex_destroy’:
./gthr-default.h:760:44: error: called object
‘__gthrw_pthread_mutex_destroy’ is not a function
./gthr-default.h: In function ‘__gthread_mutex_lock’:
./gthr-default.h:769:41: error: called object ‘__gthrw_pthread_mutex_lock’
is not a function
./gthr-default.h: In function ‘__gthread_mutex_trylock’:
./gthr-default.h:778:44: error: called object
‘__gthrw_pthread_mutex_trylock’ is not a function
./gthr-default.h: In function ‘__gthread_mutex_timedlock’:
./gthr-default.h:789:46: error: called object
‘__gthrw_pthread_mutex_timedlock’ is not a function
./gthr-default.h: In function ‘__gthread_mutex_unlock’:
./gthr-default.h:799:43: error: called object ‘__gthrw_pthread_mutex_unlock’
is not a function
./gthr-default.h: In function ‘__gthread_recursive_mutex_init_function’:
./gthr-default.h:814:46: error: called object
‘__gthrw_pthread_mutexattr_init’ is not a function
./gthr-default.h:817:10: error: ‘PTHREAD_MUTEX_RECURSIVE’ undeclared (first
use in this function)
./gthr-default.h:817:10: note: each undeclared identifier is reported only
once for each function it appears in
./gthr-default.h:816:44: error: called object
‘__gthrw_pthread_mutexattr_settype’ is not a function
./gthr-default.h:819:37: error: called object ‘__gthrw_pthread_mutex_init’
is not a function
./gthr-default.h:821:44: error: called object
‘__gthrw_pthread_mutexattr_destroy’ is not a function
./gthr-default.h: In function ‘__gthread_cond_broadcast’:
./gthr-default.h:867:43: error: called object
‘__gthrw_pthread_cond_broadcast’ is not a function
./gthr-default.h: In function ‘__gthread_cond_signal’:
./gthr-default.h:873:40: error: called object ‘__gthrw_pthread_cond_signal’
is not a function
./gthr-default.h: In function ‘__gthread_cond_wait’:
./gthr-default.h:879:38: error: called object ‘__gthrw_pthread_cond_wait’ is
not a function
./gthr-default.h: In function ‘__gthread_cond_timedwait’:
./gthr-default.h:886:43: error: called object
‘__gthrw_pthread_cond_timedwait’ is not a function
./gthr-default.h: In function ‘__gthread_cond_destroy’:
./gthr-default.h:907:41: error: called object ‘__gthrw_pthread_cond_destroy’
is not a function
../../../gcc-4.7.0/./libgcc/unwind-dw2.c: In function ‘uw_init_context_1’:
../../../gcc-4.7.0/./libgcc/unwind-dw2.c:1505:45: error: ‘PTHREAD_ONCE_INIT’
undeclared (first use in this function)
In file included from ../../../gcc-4.7.0/./libgcc/gthr.h:150:0,
                 from ../../../gcc-4.7.0/./libgcc/unwind-dw2.c:38:
../../../gcc-4.7.0/./libgcc/unwind-dw2.c: In function ‘__gthread_once’:
./gthr-default.h:721:1: warning: control reaches end of non-void function
[-Wreturn-type]
make[3]: *** [unwind-dw2.o] Error 1
make[3]: Leaving directory `/usr/local/zich/i686-linux-gnu/libgcc'
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory `/usr/local/zich'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/local/zich'
make: *** [all] Error 2


These are the configure options i made:

  $ ../gcc-4.7.0/./configure --disable-multilib --enable-threads=posix
--with-tune=generic --prefix=/usr --with-pkgversion=Ubuntu/Linaro
4.7.0-9ubuntu3 --enable-shared --libexecdir=/usr/lib --with-sysroot=/
--enable-plugin --enable-libgomp --enable-objc-gc -disable-tls
--enable-version-specific-runtime-libs --with-gmp=/usr/local/5.0.5
--with-mpfr-include=/usr/include --with-mpfr-lib=/usr/lib
--with-mpc-include=/usr/include --with-mpc-lib=/usr/lib
--enable-gather-detailed-mem-stats --enable-coverage=opt
--enable-checking=all --with-dwarf2 --with-fpmath=sse
--with-endian=little,big --with-arch-32=i686
--enable-languages=c,ada,c++,fortran,go,java,lto,objc,obj-c++
--build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu

 I want to build the compiler on a i686 architecture with
Linux-3.0.0-19-generic kernel and Ubuntu 11.10 (oneiric).
-- 
View this message in context: http://old.nabble.com/Understanding-Threads-tp33964421p33971969.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Understanding Threads
  2012-06-06 19:14   ` parc
@ 2012-06-06 22:36     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2012-06-06 22:36 UTC (permalink / raw)
  To: parc; +Cc: gcc-help

On 6 June 2012 20:14, parc wrote:
>
> The error comes up, when xgcc, in the object directory, compiles the
> libgcc/unwind-dw2.c file from the source directory into the object
> directory. "/usr/local/zich" is the objdir ; "usr/local/gcc-4.7.0" the
> srcdir.
> Maybe i setup something wrong on the configuration. But the libpthread.so
> library seems to work fine when compiling code under gcc 4.6.1 with the
> "-phtread" compiler option. I think this option should somehow be invoked
> for the make scripts of gcc 4.7.0. But i don't know how and where to set it.

You don't need to.

Your problem is not a linker error.

> /usr/local/zich/./gcc/xgcc -B/usr/local/zich/./gcc/
> -B/usr/i686-linux-gnu/bin/ -B/usr/i686-linux-gnu/lib/ -isystem
> /usr/i686-linux-gnu/include -isystem /usr/i686-linux-gnu/sys-include    -g
> -O2 -O2  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual
> -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem
> ./include   -fpic -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector
> -fpic -I. -I. -I../.././gcc -I../../../gcc-4.7.0/./libgcc
> -I../../../gcc-4.7.0/./libgcc/. -I../../../gcc-4.7.0/./libgcc/../gcc
> -I../../../gcc-4.7.0/./libgcc/../include
> -I../../../gcc-4.7.0/./libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT
> -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep
> -fexceptions -c ../../../gcc-4.7.0/./libgcc/unwind-dw2.c -fvisibility=hidden
> -DHIDE_EXPORTS
> In file included from ../../../gcc-4.7.0/./libgcc/gthr.h:150:0,
>                 from ../../../gcc-4.7.0/./libgcc/unwind-dw2.c:38:
> ./gthr-default.h:140:1: error: ‘pthread_once’ undeclared here (not in a
> function)

Something is wrong with your system, gthr-default.h should be a
symlink to gthr-posix.h which includes <pthread.h> which declares
pthread_once.  If pthread_once is undeclared then your <pthread.h> is
broken or there is another file of that name somewhere on your system.


> These are the configure options i made:
>
>  $ ../gcc-4.7.0/./configure --disable-multilib --enable-threads=posix
> --with-tune=generic --prefix=/usr --with-pkgversion=Ubuntu/Linaro
> 4.7.0-9ubuntu3 --enable-shared --libexecdir=/usr/lib --with-sysroot=/
> --enable-plugin --enable-libgomp --enable-objc-gc -disable-tls
> --enable-version-specific-runtime-libs --with-gmp=/usr/local/5.0.5
> --with-mpfr-include=/usr/include --with-mpfr-lib=/usr/lib
> --with-mpc-include=/usr/include --with-mpc-lib=/usr/lib

These options are unnecessary, /usr/include will always be searched
for headers and /usr/lib will be searched for libraries.

> --enable-gather-detailed-mem-stats --enable-coverage=opt
> --enable-checking=all --with-dwarf2 --with-fpmath=sse

Are you sure you want --enable-checking=all enabled?

> --with-endian=little,big --with-arch-32=i686

--with-endian doesn't do anything for i686, why are you using it?

> --enable-languages=c,ada,c++,fortran,go,java,lto,objc,obj-c++
> --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu

Have you tried simplifying your configure command, instead of using a
load of redundant or invalid options?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-06 22:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-05 14:28 Understanding Threads parc
2012-06-05 17:54 ` Jonathan Wakely
2012-06-06 19:14   ` parc
2012-06-06 22:36     ` Jonathan Wakely

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).