This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Configure does NOT set properly *FLAGS for thread support
Type: Stage:
Components: Build Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mmokrejs, nnorwitz
Priority: normal Keywords:

Created on 2003-05-21 18:53 by mmokrejs, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Messages (10)
msg16097 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-05-21 18:53
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.
msg16098 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-22 03:34
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?
msg16099 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-05-22 07:24
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 
msg16100 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-05-22 08:28
Logged In: YES 
user_id=696559

BTW: With gcc, I don't get even to the link step:

gcc  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I.
-I./Include  -DPy_BUILD_CORE  -c ./Modules/posixmodule.c -o
Modules/posixmodule.o
Modules/posixmodule.c: In function `posix_stat':
Modules/posixmodule.c:1851: `stat' undeclared (first use in
this function)
Modules/posixmodule.c:1851: (Each undeclared identifier is
reported only once
Modules/posixmodule.c:1851: for each function it appears in.)
Modules/posixmodule.c: In function `posix_plock':
Modules/posixmodule.c:2956: warning: implicit declaration of
function `plock'
Modules/posixmodule.c: In function `posix_lstat':
Modules/posixmodule.c:4683: `lstat' undeclared (first use in
this function)
Modules/posixmodule.c: In function `posix_unsetenv':
Modules/posixmodule.c:5431: warning: implicit declaration of
function `unsetenv'
make: *** [Modules/posixmodule.o] Error 1
msg16101 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-05-22 14:20
Logged In: YES 
user_id=696559

So, this is a solution:

CC="cc -pthread" CXX="cxx -pthread" CFLAGS="$CFLAGS
-pthread" CXXFLAGS=$CFLAGS ./configure

msg16102 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-25 16:44
Logged In: YES 
user_id=33168

This problem has a tentative solution.  Please test the
patch in http://python.org/sf/719359
Scroll to the bottom and click Download on the
osf-opts.patch line.  Thanks.
msg16103 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-26 14:02
Logged In: YES 
user_id=33168

A solution was already checked in that solves thread
problems for several architectures.  Please test current CVS
and report if it works or not.
msg16104 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-06-02 11:47
Logged In: YES 
user_id=696559

Sorry, but my  Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.3) Gecko/20030523  does not recognize the link to
download page (the "Download" word really is NOT clickable).
Trying to access
http://sourceforge.net/tracker/download.php?group_id=5470&amp;atid=305470&amp;file_id=47386&amp;aid=719359
manually gives me:


ERROR - No ID Passed

I'm sorry for the delay in communication, I was away for a
week from net. Could anyone send me the latest version of
patches I should use for Python-2.3b1? I'll try cvs as I
read that some stuff was already merged into ... I'm a bit
lost what is alread checked in and what not yet, so ...


msg16105 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-06-02 12:45
Logged In: YES 
user_id=696559

If you are curious about the status of gcc/g++ ability to
cpmpile python(current cvs on alpha-osf), then see below:

$ CC=gcc CXX=g++ CFLAGS=-g2 CXXFLAGS=-g2 ./configure
--prefix=/software/@sys/usr
$ make
gcc -pthread -c  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
-I. -I./Include  -DPy_BUILD_CORE -o Modules/main.o
Modules/main.c
gcc -pthread -c  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
-I. -I./Include  -DPy_BUILD_CORE -o Modules/gcmodule.o
Modules/gcmodule.c
gcc -pthread  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I.
-I./Include  -DPy_BUILD_CORE  -c ./Modules/threadmodule.c -o
Modules/threadmodule.o
gcc -pthread  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I.
-I./Include  -DPy_BUILD_CORE  -c ./Modules/signalmodule.c -o
Modules/signalmodule.o
gcc -pthread  -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I.
-I./Include  -DPy_BUILD_CORE  -c ./Modules/posixmodule.c -o
Modules/posixmodule.o
Modules/posixmodule.c: In function `posix_stat':
Modules/posixmodule.c:1775: `stat' undeclared (first use in
this function)
Modules/posixmodule.c:1775: (Each undeclared identifier is
reported only once
Modules/posixmodule.c:1775: for each function it appears in.)
Modules/posixmodule.c: In function `posix_plock':
Modules/posixmodule.c:2880: warning: implicit declaration of
function `plock'
Modules/posixmodule.c: In function `posix_lstat':
Modules/posixmodule.c:4607: `lstat' undeclared (first use in
this function)
Modules/posixmodule.c: In function `posix_unsetenv':
Modules/posixmodule.c:5351: warning: implicit declaration of
function `unsetenv'
make: *** [Modules/posixmodule.o] Error 1
$

from config.log:

configure:3774: checking whether pthreads are available
without options
configure:3800: gcc -o conftest -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c -L/usr/lo
cal/lib -L/software/@sys/usr/lib -L/usr/local/openssl/lib
-L/usr/lib >&5
In file included from configure:3784:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:3803: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 3782 "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:3823: result: no
configure:3836: checking whether gcc accepts -Kpthread
configure:3864: gcc -Kpthread -o conftest -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c
 -L/usr/local/lib -L/software/@sys/usr/lib
-L/usr/local/openssl/lib -L/usr/lib >&5
gcc: unrecognized option `-Kpthread'
In file included from configure:3848:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:3867: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 3846 "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:3887: result: no
configure:3898: checking whether gcc accepts -Kthread
configure:3926: gcc -Kthread -o conftest -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c 
-L/usr/local/lib -L/software/@sys/usr/lib
-L/usr/local/openssl/lib -L/usr/lib >&5
gcc: unrecognized option `-Kthread'
In file included from configure:3910:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:3929: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 3908 "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:3949: result: no
configure:3960: checking whether gcc accepts -pthread
configure:3988: gcc -pthread -o conftest -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c 
-L/usr/local/lib -L/software/@sys/usr/lib
-L/usr/local/openssl/lib -L/usr/lib >&5
configure:3991: $? = 0
configure:3993: ./conftest
configure:3996: $? = 0
configure:4011: result: yes


configure:4214: checking pthread.h usability
configure:4223: gcc -c -g2 -I/software/@sys/usr/include
-I/usr/local/include -I/usr/local/openssl/include conftest.c >&5
In file included from configure:4251:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:4226: $? = 1
[...]
configure:4241: result: no
configure:4245: checking pthread.h presence
configure:4252: gcc -E -I/software/@sys/usr/include
-I/usr/local/include -I/usr/local/openssl/include conftest.c
In file included from configure:4248:
/usr/include/pthread.h:312:4: #error "Please compile the
module including pthread.h with -pthread"
configure:4258: $? = 1
[...]
configure:9269: checking for pthread_t
configure:9291: gcc -pthread -c -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include conftest.c >&5
configure:9294: $? = 0
configure:9297: test -s conftest.o
configure:9300: $? = 0
configure:9308: result: yes
configure:9312: checking size of pthread_t
configure:9334: gcc -pthread -o conftest -g2
-I/software/@sys/usr/include -I/usr/local/include
-I/usr/local/openssl/include  conftest.c 
-L/usr/local/lib -L/software/@sys/usr/lib
-L/usr/local/openssl/lib -L/usr/lib >&5
configure:9337: $? = 0
configure:9339: ./conftest
configure:9342: $? = 0
configure:9357: result: 8
msg16106 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2003-06-04 14:53
Logged In: YES 
user_id=696559

OK, I can confirm this bug is fixed in cvs. I used
--with-dec-threads configure option and -pthread -ieee were
corrently appended to CFLAGS by configure itself. Thanks!
History
Date User Action Args
2022-04-10 16:08:51adminsetgithub: 38535
2003-05-21 18:53:18mmokrejscreate