[Python-bugs-list] [ python-Bugs-741307 ] Configure does NOT set properly *FLAGS for thread support

SourceForge.net noreply@sourceforge.net
Thu, 22 May 2003 00:24:59 -0700


Bugs item #741307, was opened at 2003-05-21 20:53
Message generated for change (Comment added) made by mmokrejs
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=741307&group_id=5470

Category: Build
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Mokrejs (mmokrejs)
Assigned to: Nobody/Anonymous (nobody)
Summary: Configure does NOT set properly *FLAGS for thread support

Initial Comment:
On Tru64Unix 5.1A(but also older version like Digital
Unix 4.0 for example), there have to be specified
CFLAGS="-pthread" and CXXFLAGS="-pthread", so that
configure can detect working pthread.h.

In case of Python-2.3b1 even when user set those both
variables before running configure, at the link step gets:

cc   -o python \
                Modules/ccpython.o \
                libpython2.3.a -lrt -L/usr/local/lib
-L/software/@sys/usr/lib -L/usr/local/openssl/lib
-L/usr/lib   -lm  
ld:
Unresolved:
__pthread_self
__pthread_create
__pthread_detach
make: *** [python] Error 1
$

This can be easily fixed:

$ cc -pthread -o python Modules/ccpython.o
libpython2.3.a -lrt -L/usr/local/lib
-L/software/@sys/usr/lib -L/usr/local/openssl/lib
-L/usr/lib -lm 
$

I guess in this case LDFLAGS are in effect. So,
configure should make sure -pthread is appended to all,
CFLAGS, CXXFLAGS and LDFLAGS.

----------------------------------------------------------------------

>Comment By: Martin Mokrejs (mmokrejs)
Date: 2003-05-22 09:24

Message:
Logged In: YES 
user_id=696559

This is specific for Dec/Compaq/HP compiler. The manpage for
cc says:

  -pthread
      Directs the linker to use the threadsafe version of
any library speci-
      fied with the -l option when linking programs. This
option also tells
      the linker to include the POSIX 1003.1c-conformant
DECthreads inter-
      faces in libpthread when linking the program. This
option also defines
      the _REENTRANT macro.


As I remeber from experience, it's not enough to use it
really as LDFLAG supplied to ld. The code has to be compiled
with that flag already and therefore I set CC or CFLAGS to
contain this value. Same applies for CXX or CXXFLAGS.

Actually, there's a configure macro check, I saw it
somewhere in documentation on the web. I posted that once
into some my bugreport in GNOME bugzilla. You can dig out
from there that URL. Unfortunately, bugzilla searches never
worked for me. :(

As for gcc:
$ CFLAGS="-O2" CXXFLAGS="-O2" CC=gcc CXX=g++ ./configure
[...]
checking whether pthreads are available without options... no
checking whether gcc accepts -Kpthread... no
[...]
checking for --with-dec-threads... no
checking for --with-threads... yes
checking for _POSIX_THREADS in unistd.h... yes
checking cthreads.h usability... no
checking cthreads.h presence... no
checking for cthreads.h... no
checking mach/cthreads.h usability... no
checking mach/cthreads.h presence... no
checking for mach/cthreads.h... no
checking for --with-pth... no
checking for pthread_create in -lpthread... yes
checking if PTHREAD_SCOPE_SYSTEM is supported... yes
checking for pthread_sigmask... yes

from config.log:

configure:3753: checking whether pthreads are available
without options
configure:3779: gcc -o conftest -O2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c -L/usr/l
ocal/lib -L/software/@sys/usr/lib -L/usr/local/openssl/lib
-L/usr/lib >&5
In file included from configure:3763:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:3782: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 3761 "configure"
#include "confdefs.h"

#include <pthread.h>

void* routine(void* p){return NULL;}

int main(){
  pthread_t p;
  if(pthread_create(&p,NULL,routine,NULL)!=0)
    return 1;
  (void)pthread_detach(p);
  return 0;
}

configure:3802: result: no



So, to conclude, -pthread has to be specified even for
gcc/g++. Simply, always on 

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-05-22 05:34

Message:
Logged In: YES 
user_id=33168

Is this only with the Dec/Compaq/HP compiler (cc/cxx)?  Do
you know if python links ok with gcc?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=741307&group_id=5470