[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: configure.in thread support for Solaris



On Wed, Jun 02, 1999 at 06:32:15PM -0700, Kurt D. Zeilenga wrote:
> > > With OpenLDAP 1.2.x, you must tell configure to ignore the
> > > bogus pthread_create in $LIBS.  See the FAQ for details.
> > >   http://www.OpenLDAP.org/faq/index.cgi?file=11
> > What is suggested here does not work.
> 
> It apparently does for some folks on some version of Solaris.
> 
> > You also need to set
> >         ol_cv_kthread_flag=no
> 
> Are you using a vendor provided compiler? or gcc/egcs or other?

On Solaris 2.5.1 with EGCS 1.1.2, it it sufficient to have
	ac_cv_func_pthread_create=no ./configure
  checking POSIX thread version... final
  checking for LinuxThreads... no
  checking for pthread_create... (cached) no
  checking for pthread_create with -kthread... no
  checking for pthread_create with -pthread... no
  checking for pthread_create with -pthreads... yes
  checking for sched_yield... no
  checking for pthread_yield... no
  checking for sched_yield in -lrt... no
  checking for thr_yield... yes
  checking for pthread_kill... yes
  checking for pthread_detach with <pthread.h>... yes
  checking for pthread_setconcurrency... no
  checking for pthread_getconcurrency... no
  checking for thr_setconcurrency... yes
  checking for thr_getconcurrency... yes
  checking if pthread_create() works... yes

On Solaris 2.6, and 2.7, it fails with EGCS 1.1.2.
On Solaris 2.6, and 2.7, it fails with SunPro C 5.0.

> I wasn't aware that the Solaris compiler/linker grok'ed -kthread.
> If it does and it's not generating an error, I recommend updating
> the Solaris hint (in the FAQ) with the additional requirement.

For Solaris 2.6 and 2.7 with
	ac_cv_func_pthread_create=no CC=gcc ./configure
  checking POSIX thread version... final
  checking for LinuxThreads... no
  checking for pthread_create... (cached) no
  checking for pthread_create with -kthread... yes
  checking for sched_yield... no
  checking for pthread_yield... no
  checking for sched_yield in -lrt... no
  checking for thr_yield... yes
  checking for pthread_kill... yes
  checking for pthread_detach with <pthread.h>... yes
  checking for pthread_setconcurrency... no
  checking for pthread_getconcurrency... no
  checking for thr_setconcurrency... yes
  checking for thr_getconcurrency... yes
  checking if pthread_create() works... no
  configure: error: pthread.h and pthread_create are not compatible

>From config.log with gcc:
  configure:3733: checking for pthread_create with -kthread
  configure:3748: gcc -o conftest -O2 -I/opt/TWWfsw/libdb2/include \
    -I/opt/TWWfsw/tcpwrap/include -L/opt/TWWfsw/libdb2/lib \
    -L/opt/TWWfsw/tcpwrap/lib conftest.c -kthread -lresolv -lgen \
    -lnsl -lsocket  1>&5
  gcc: unrecognized option `-kthread'

>From config.log with Sun cc:
  configure:3733: checking for pthread_create with -kthread
  configure:3748: cc -o conftest -mr -Qn -xdepend -xO3 \
    -I/opt/TWWfsw/libdb2/include -I/opt/TWWfsw/tcpwrap/include \
    -L/opt/TWWfsw/libdb2/lib -L/opt/TWWfsw/tcpwrap/lib conftest.c \
    -kthread -lresolv -lgen -lnsl -lsocket  1>&5
  cc: Warning: illegal option -kthread

So, -kthread is ignored and it's treated just like searching for
pthread_create in libc which we know works. Since we only force
autoconf to ignore searching for pthread_create in libc, we also need
to disable it for the search against -kthread.

FYI, 2.6 and 2.7 have pthread_create in libc. 2.5.1 does not so all
the tests to find pthread_create in:
	1. libc
	2. -kthread
	3. -pthread
	4. -pthreads
fail. Because the compiler gives a warning about a bad argument for
-kthread, -pthread, and -pthreads, it reverts to finding it in libc
which we don't want.

> If using gcc/egcs or something else, I suggest adding
> an additional answer under Solaris hint (in the FAQ) with
> appropriate instructions.  (In this case, you may also want to
> submit a patch to the gcc/egcs folks that implements
> -kthread/-pthread behavior).
> 
> (note: the FAQ is interactive, feel free to add appropriate answers)

Ok, I'll add to the FAQ.

The Sun CC doesn't interpret -pthread or -pthreads in any way. The test
against -pthread and -pthreads fails:
  configure:3772: checking for pthread_create with -pthread
  configure:3787: cc -o conftest -mr -Qn -xdepend -xO3
    -I/opt/TWWfsw/libdb2/include -I/opt/TWWfsw/tcpwrap/include \
    -L/opt/TWWfsw/libdb2/lib -L/opt/TWWfsw/tcpwrap/lib conftest.c \
    -pthread -lresolv -lgen -lnsl -lsocket  1>&5
  ld: fatal: option -h and building a dynamic executable are incompatible
  ld: fatal: Flags processing errors
  configure: failed program was:
  #line 3780 "configure"
  #include "confdefs.h"
  #include <pthread.h>
  int main() {
  pthread_create(NULL,NULL,NULL,NULL);
  ; return 0; }

As gcc ignores the flags -pthread and -pthreads, compiling OpenLDAP
1.2.x with gcc requires unsetting more autoconf flags:
	ol_cv_kthread_flag=no
	ol_cv_pthread_flag=no
	ol_cv_pthreads_flag=no
	ol_cv_thread_flag=no
We then get, from configure:
  checking POSIX thread version... final
  checking for LinuxThreads... no
  checking for pthread_create... (cached) no
  checking for pthread_create with -kthread... (cached) no
  checking for pthread_create with -pthread... (cached) no
  checking for pthread_create with -pthreads... (cached) no
  checking for pthread_create with -thread... (cached) no
  checking for pthread_create with -mt... (cached) no
  checking for pthread_mutex_unlock in -lpthread... no
  checking for pthread_mutex_lock in -lpthread... no
  checking for pthread_mutex_trylock in -lpthread... no
  checking for pthread_create in -lpthread... yes
  checking for sched_yield... no
  checking for pthread_yield... no
  checking for sched_yield in -lrt... yes
  checking for pthread_kill... yes
  checking for pthread_detach with <pthread.h>... yes
  checking for pthread_setconcurrency... yes
  checking for pthread_getconcurrency... yes
  checking for thr_setconcurrency... yes
  checking for thr_getconcurrency... yes
  checking if pthread_create() works... yes

> > BTW, are there any intentions of a document describing all the options
> > to configure? I saw nothing on the web page to help explain them (and
> > I know next to nothing about LDAP so I'm real confused).
> 
> The intention is to have them documented in the guide.
> 	cvs co openldap-guide
>
> You are welcomed to contribute to the guide.

Should I add to openldap-guide/release/autoconf.sdf?

-- 
albert chin (china@thewrittenword.com)