httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@raleigh.ibm.com>
Subject Re: cvs commit: apache-2.0/src/modules/mpm config.m4
Date Thu, 23 Dec 1999 22:04:27 GMT

Okay, I just committed this bit of logic to detect the best flags for
compiling threaded programs.  A few caveats.  This is tested only on Linux
2.2.10, but it should work everywhere.  It doesn't always come up with the
best possible flags, but it should alwyas work.  For example, on Linux, it
seems to come up with -lpthread in LDFLAGS instead of -pthread in CFLAGS,
but since this is what I have been using to compile the server since we
started, that should be okay.

I also have not started to use this logic to help us pick which MPM to
use.  For example, picking prefork if there is no threading library
defined.  That is work for after this has been tested by more people.

I would appreciate it if everybody who gave input on getting this test
working would extract the new code, and try to configure and compile it.
If there are no problems reported, then I will finish this work.  If there
are problems, we'll fix them when we know about them. :)

Thanks to everybody who helped me get this test right.  It does look like
I missed a -lpthread somewhere in the configure stuff, but I'll track it
down soon.

Ryan

On 23 Dec 1999 rbb@hyperreal.org wrote:

> rbb         99/12/23 13:01:32
> 
>   Modified:    src      acinclude.m4 configure.in
>                src/modules/mpm config.m4
>   Log:
>   First stab at logic to determine which threading library to use.  This also
>   gets rid of the hack of always putting -pthread in the CFLAGS variable.
>   
>   Revision  Changes    Path
>   1.8       +43 -0     apache-2.0/src/acinclude.m4
>   
>   Index: acinclude.m4
>   ===================================================================
>   RCS file: /home/cvs/apache-2.0/src/acinclude.m4,v
>   retrieving revision 1.7
>   retrieving revision 1.8
>   diff -u -r1.7 -r1.8
>   --- acinclude.m4	1999/12/20 03:09:43	1.7
>   +++ acinclude.m4	1999/12/23 21:01:27	1.8
>   @@ -95,3 +95,46 @@
>      fi
>    ])
>    
>   +dnl
>   +dnl APACHE_CHECK_THREADS()
>   +dnl
>   +dnl Determine the best flags for linking against a threading library.
>   +dnl
>   +AC_DEFUN(THREAD_TEST, [
>   +AC_TRY_RUN( [
>   +#include <pthread.h>
>   +
>   +void *thread_routine(void *data) {
>   +    return data;
>   +}
>   +
>   +int main() {
>   +    pthread_t thd;
>   +    int data = 1;
>   +    return pthread_create(&thd, NULL, thread_routine, &data);
>   +} ], [ 
>   +  THREADS_WORKING="yes"
>   +  ], [
>   +  THREADS_WORKING="no"
>   +  ], THREADS_WORKING="no" ) ] )
>   +
>   +define(APACHE_CHECK_THREADS, [dnl
>   +  cflags_orig="$CFLAGS"
>   +  ldflags_orig="$LDFLAGS"
>   +  for test_cflag in $1; do
>   +    for test_ldflag in $2; do
>   +      CFLAGS="$test_cflag $cflags_orig"
>   +      LDFLAGS="$test_ldflag $ldflags_orig"
>   +      THREAD_TEST()
>   +      if test "$THREADS_WORKING" = "yes"; then
>   +        break
>   +      fi
>   +    done
>   +    if test "$THREADS_WORKING" = "yes"; then
>   +      threads_result="Updating CFLAGS and LDFLAGS"
>   +      break
>   +    fi
>   +      threads_result="Threads not found"
>   +  done
>   +] )
>   +        
>   
>   
>   
>   1.15      +4 -0      apache-2.0/src/configure.in
>   
>   Index: configure.in
>   ===================================================================
>   RCS file: /home/cvs/apache-2.0/src/configure.in,v
>   retrieving revision 1.14
>   retrieving revision 1.15
>   diff -u -r1.14 -r1.15
>   --- configure.in	1999/12/21 21:41:40	1.14
>   +++ configure.in	1999/12/23 21:01:28	1.15
>   @@ -73,6 +73,10 @@
>    
>    dnl ## Check for library functions
>    
>   +AC_MSG_CHECKING([for which threading library to use])
>   +APACHE_CHECK_THREADS('' -pthread -D_REENTRANT, '' -lpthread -lc_r)
>   +AC_MSG_RESULT("$threads_result")
>   +
>    dnl See Comment #Spoon
>    
>    AC_CHECK_FUNCS( \
>   
>   
>   
>   1.5       +0 -2      apache-2.0/src/modules/mpm/config.m4
>   
>   Index: config.m4
>   ===================================================================
>   RCS file: /home/cvs/apache-2.0/src/modules/mpm/config.m4,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- config.m4	1999/12/20 03:09:50	1.4
>   +++ config.m4	1999/12/23 21:01:31	1.5
>   @@ -46,8 +46,6 @@
>    
>    dnl XXX - We should be checking for the proper flags to use on a particular 
>    dnl platform. This will cover a couple of them, anyway
>   -    CFLAGS="-pthread $CFLAGS"
>   -    CXXFLAGS="-pthread $CXXFLAGS"
>    
>        AC_CHECK_HEADER(pthread.h, [ ],[
>            AC_MSG_ERROR(This MPM requires pthreads. Try --with-mpm=prefork.)
>   
>   
>   
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		

Come to the first official Apache Software Foundation
Conference!  <http://ApacheCon.Com/>



Mime
View raw message