[Python-checkins] CVS: python/dist/src configure,1.107,1.108 configure.in,1.115,1.116

Guido van Rossum guido@cnri.reston.va.us
Fri, 25 Feb 2000 14:26:34 -0500 (EST)


Update of /projects/cvsroot/python/dist/src
In directory eric:/projects/python/develop/guido/src

Modified Files:
	configure configure.in 
Log Message:
Pat Knight:

Solaris 2 has stub implementations of the POSIX thread functions such as 
pthread_detach in libc. This means that configure tries to use them without 
-lpthread, then the test of pthread_create fails and the configuration 
falls back to the Solaris thread library. This patch moves the test for 
pthread_create in -lpthread ahead of the test for pthread_detach in libc. 
The patch also ensures that -lpthread is at the start of the library list 
when linking, to pick up POSIX thread semantics for fork (see below).

Justification.
Use of POSIX threads on Solaris ensures that the fork() call only runs the 
thread that called fork() in the child. This is desirable to prevent (for 
example) parent server or database threads running in the child. Sun's 
-lthread library uses a traditional fork() which replicates all the 
parent's threads in the child. I find this undesirable.

Digression.
The configure.in seems to always test for -lthread even if a POSIX library 
is found. I'm not enough of a configure.in wizard to decide whether this is 
desirable or how to fix it. It is also irrelevant to this patch - I just 
spotted it while testing.
End of Digression.



Index: configure
===================================================================
RCS file: /projects/cvsroot/python/dist/src/configure,v
retrieving revision 1.107
retrieving revision 1.108
diff -C2 -r1.107 -r1.108
*** configure	2000/02/03 13:50:24	1.107
--- configure	2000/02/25 19:26:30	1.108
***************
*** 1,5 ****
  #! /bin/sh
  
! # From configure.in Revision: 1.115 
  
  # Guess values for system-dependent variables and create Makefiles.
--- 1,5 ----
  #! /bin/sh
  
! # From configure.in Revision: 1.116 
  
  # Guess values for system-dependent variables and create Makefiles.
***************
*** 2733,2743 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_detach""... $ac_c" 1>&6
! echo "configure:2737: checking for pthread_detach" >&5
  if eval "test \"`echo '$''{'ac_cv_func_pthread_detach'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2742 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
--- 2733,2791 ----
    echo "$ac_t""no" 1>&6
  
+ echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+ echo "configure:2737: checking for pthread_create in -lpthread" >&5
+ ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   ac_save_LIBS="$LIBS"
+ LIBS="-lpthread  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+ #line 2745 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+ char pthread_create();
+ 
+ int main() {
+ pthread_create()
+ ; return 0; }
+ EOF
+ if { (eval echo configure:2756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=no"
+ fi
+ rm -f conftest*
+ LIBS="$ac_save_LIBS"
+ 
+ fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+   cat >> confdefs.h <<\EOF
+ #define WITH_THREAD 1
+ EOF
+ 
+ cat >> confdefs.h <<\EOF
+ #define _POSIX_THREADS 1
+ EOF
+ 
+ LIBS="-lpthread $LIBS"
+ LIBOBJS="$LIBOBJS thread.o"
+ else
+   echo "$ac_t""no" 1>&6
+ 
  echo $ac_n "checking for pthread_detach""... $ac_c" 1>&6
! echo "configure:2785: checking for pthread_detach" >&5
  if eval "test \"`echo '$''{'ac_cv_func_pthread_detach'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2790 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
***************
*** 2762,2766 ****
  ; return 0; }
  EOF
! if { (eval echo configure:2765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_pthread_detach=yes"
--- 2810,2814 ----
  ; return 0; }
  EOF
! if { (eval echo configure:2813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_pthread_detach=yes"
***************
*** 2790,2804 ****
  ac_safe=`echo "kernel/OS.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for kernel/OS.h""... $ac_c" 1>&6
! echo "configure:2793: checking for kernel/OS.h" >&5
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2798 "configure"
  #include "confdefs.h"
  #include <kernel/OS.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:2803: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  if test -z "$ac_err"; then
--- 2838,2852 ----
  ac_safe=`echo "kernel/OS.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for kernel/OS.h""... $ac_c" 1>&6
! echo "configure:2841: checking for kernel/OS.h" >&5
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2846 "configure"
  #include "confdefs.h"
  #include <kernel/OS.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:2851: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  if test -z "$ac_err"; then
***************
*** 2829,2833 ****
  
  echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
! echo "configure:2832: checking for pthread_create in -lpthreads" >&5
  ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
--- 2877,2881 ----
  
  echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
! echo "configure:2880: checking for pthread_create in -lpthreads" >&5
  ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
***************
*** 2837,2888 ****
  LIBS="-lpthreads  $LIBS"
  cat > conftest.$ac_ext <<EOF
- #line 2840 "configure"
- #include "confdefs.h"
- /* Override any gcc2 internal prototype to avoid an error.  */
- /* We use char because int might match the return type of a gcc2
-     builtin and then its argument prototype would still apply.  */
- char pthread_create();
- 
- int main() {
- pthread_create()
- ; return 0; }
- EOF
- if { (eval echo configure:2851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-   rm -rf conftest*
-   eval "ac_cv_lib_$ac_lib_var=yes"
- else
-   echo "configure: failed program was:" >&5
-   cat conftest.$ac_ext >&5
-   rm -rf conftest*
-   eval "ac_cv_lib_$ac_lib_var=no"
- fi
- rm -f conftest*
- LIBS="$ac_save_LIBS"
- 
- fi
- if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-   echo "$ac_t""yes" 1>&6
-   cat >> confdefs.h <<\EOF
- #define WITH_THREAD 1
- EOF
- 
- cat >> confdefs.h <<\EOF
- #define _POSIX_THREADS 1
- EOF
- 
- LIBS="$LIBS -lpthreads"
- LIBOBJS="$LIBOBJS thread.o"
- else
-   echo "$ac_t""no" 1>&6
- 
- echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
- echo "configure:2880: checking for pthread_create in -lpthread" >&5
- ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
- if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
-   echo $ac_n "(cached) $ac_c" 1>&6
- else
-   ac_save_LIBS="$LIBS"
- LIBS="-lpthread  $LIBS"
- cat > conftest.$ac_ext <<EOF
  #line 2888 "configure"
  #include "confdefs.h"
--- 2885,2888 ----
***************
*** 2919,2923 ****
  EOF
  
! LIBS="$LIBS -lpthread"
  LIBOBJS="$LIBOBJS thread.o"
  else
--- 2919,2923 ----
  EOF
  
! LIBS="$LIBS -lpthreads"
  LIBOBJS="$LIBOBJS thread.o"
  else

Index: configure.in
===================================================================
RCS file: /projects/cvsroot/python/dist/src/configure.in,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -r1.115 -r1.116
*** configure.in	2000/02/03 13:42:50	1.115
--- configure.in	2000/02/25 19:26:31	1.116
***************
*** 1,4 ****
  dnl Process this file with autoconf 2.0 or later to make a configure script.
! AC_REVISION($Revision: 1.115 $)
  AC_PREREQ(2.0)
  AC_INIT(Include/object.h)
--- 1,4 ----
  dnl Process this file with autoconf 2.0 or later to make a configure script.
! AC_REVISION($Revision: 1.116 $)
  AC_PREREQ(2.0)
  AC_INIT(Include/object.h)
***************
*** 648,651 ****
--- 648,655 ----
  AC_DEFINE(C_THREADS)
  LIBOBJS="$LIBOBJS thread.o"],[
+ AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
+ AC_DEFINE(_POSIX_THREADS)
+ LIBS="-lpthread $LIBS"
+ LIBOBJS="$LIBOBJS thread.o"],[
  AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
  AC_DEFINE(_POSIX_THREADS)
***************
*** 657,664 ****
  AC_DEFINE(_POSIX_THREADS)
  LIBS="$LIBS -lpthreads"
- LIBOBJS="$LIBOBJS thread.o"], [
- AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
- AC_DEFINE(_POSIX_THREADS)
- LIBS="$LIBS -lpthread"
  LIBOBJS="$LIBOBJS thread.o"], [
  AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
--- 661,664 ----