X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A84BC14B28C1 for ; Thu, 12 Aug 2004 03:42:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87159-02 for ; Thu, 12 Aug 2004 06:42:39 +0000 (GMT) Received: from mail2.trustcenter.de (mail2.trustcenter.de [193.194.157.2]) by svr1.postgresql.org (Postfix) with ESMTP id 84A5C14B27FF for ; Thu, 12 Aug 2004 03:42:37 -0300 (ADT) Received: from hermes.trustcenter.de (hermes.trustcenter.de [192.168.202.5]) by mail2.trustcenter.de (8.12.11/8.12.11) with ESMTP id i7C6gK9t012386; Thu, 12 Aug 2004 08:42:20 +0200 (CEST) Received: from [192.168.201.14] (titan.trustcenter.de [192.168.200.244]) by hermes.trustcenter.de (8.12.10/8.12.10/Debian-5) with ESMTP id i7C6gFmX000478; Thu, 12 Aug 2004 08:42:15 +0200 Message-ID: <411B1147.9000303@betrusted.com> Date: Thu, 12 Aug 2004 08:42:15 +0200 From: =?ISO-8859-1?Q?Martin_M=FCnstermann?= User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en, de-de, it MIME-Version: 1.0 To: Bruce Momjian Cc: Robert Treat , pgsql-bugs@postgresql.org Subject: Re: 8.0.0beta1: -lpthread missing References: <200408111554.i7BFsa609431@candle.pha.pa.us> In-Reply-To: <200408111554.i7BFsa609431@candle.pha.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/116 X-Sequence-Number: 8906 Bruce Momjian wrote: > OK, I have some more information. Basically, the config/acx_pthread.m4 > manual page (http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.h= > tml) > says: > =09 > NOTE: You are assumed to not only compile your program with these flags, > but also link it with them as well. e.g. you should link with > $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS > > meaning if -lpthread is defined in PTHREAD_CFLAGS, it also has to be > included in the link. Now, from your reports you said -lpthread was in > PTHREAD_CFLAGS, so why isn't it also included in the libpq link line. I > need to see your link line output for libpq. OK, here are parts of the output from configure --enable-thread-safety on Debian: [...] checking for the pthreads library -lpthreads... no checking whether pthreads work without any flags... no checking whether pthreads work with -Kthread... no checking whether pthreads work with -kthread... no checking for the pthreads library -llthread... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking if more special flags are required for pthreads... no checking for cc_r... gcc checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes [...] --> configure thays, thate the CFLAG -pthread is sufficient. Makefile.global: PTHREAD_CFLAGS = -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS PTHREAD_LIBS = Let's look what make is doing: [...] gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -I../../src/port -I../../src/include -D_GNU_SOURCE -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -c thread.c ar crs libpgport.a dirmod.o exec.o noblock.o path.o pipe.o pgsleep.o pgstrcasecmp.o sprompt.o thread.o [...] make[2]: Entering directory `/home/user/checkout/postgresql-8.0.0beta1/src/interfaces' make[3]: Entering directory `/home/user/checkout/postgresql-8.0.0beta1/src/interfaces/libpq' gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-auth.o fe-auth.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-connect.o fe-connect.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-exec.o fe-exec.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-misc.o fe-misc.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-print.o fe-print.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-lobj.o fe-lobj.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-protocol2.o fe-protocol2.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-protocol3.o fe-protocol3.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o pqexpbuffer.o pqexpbuffer.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o pqsignal.o pqsignal.c gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o fe-secure.o fe-secure.c rm -f dllist.c && ln -s ../../../src/backend/lib/dllist.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o dllist.o dllist.c rm -f md5.c && ln -s ../../../src/backend/libpq/md5.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o md5.o md5.c rm -f ip.c && ln -s ../../../src/backend/libpq/ip.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o ip.o ip.c rm -f wchar.c && ln -s ../../../src/backend/utils/mb/wchar.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o wchar.o wchar.c rm -f encnames.c && ln -s ../../../src/backend/utils/mb/encnames.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o encnames.o encnames.c rm -f noblock.c && ln -s ../../../src/port/noblock.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o noblock.o noblock.c rm -f pgstrcasecmp.c && ln -s ../../../src/port/pgstrcasecmp.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o pgstrcasecmp.o pgstrcasecmp.c rm -f thread.c && ln -s ../../../src/port/thread.c . gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -I. -I../../../src/include -D_GNU_SOURCE -I../../../src/port -DFRONTEND -c -o thread.o thread.c ar crs libpq.a `lorder fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o dllist.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o | tsort` ranlib libpq.a gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -shared -Wl,-soname,libpq.so.3 fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o dllist.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o -L../../../src/port -lcrypt -lresolv -lnsl -Wl,-rpath,/opt/postgresql-800beta1/lib -o libpq.so.3.2 rm -f libpq.so.3 ln -s libpq.so.3.2 libpq.so.3 rm -f libpq.so ln -s libpq.so.3.2 libpq.so make[3]: Leaving directory `/home/user/checkout/postgresql-8.0.0beta1/src/interfaces/libpq' So the shared library is built with "-pthread" [...] gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations initdb.o dirmod.o exec.o -L../../../src/interfaces/libpq -lpq -L../../../src/port -Wl,-rpath,/opt/postgresql-800beta1/lib -lpgport -lz -lreadline -lcrypt -lresolv -lnsl -ldl -lm -o initdb [--> results in linker error as described in the first posting] The problem can be resolved, if I modify my Makefile.global to PTHREAD_LIBS = -lpthread Then libpq.so is built with -lpthread (note the "l"): gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -fpic -shared -Wl,-soname,libpq.so.3 fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o dllist.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o -L../../../src/port -lcrypt -lresolv -lnsl -lpthread -Wl,-rpath,/opt/postgresql-800beta1/lib -o libpq.so.3.2 The link line of initdb is unchanged, with the difference that there is no error: gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations initdb.o dirmod.o exec.o -L../../../src/interfaces/libpq -lpq -L../../../src/port -Wl,-rpath,/opt/postgresql-800beta1/lib -lpgport -lz -lreadline -lcrypt -lresolv -lnsl -ldl -lm -o initdb So for me it looks like in my case it's not sufficient to have the compiler flag "-pthread", but also (or instead?) the linker flag "-lpthread". Maybe the case of a shared library using pthreads is not handled correctly in the m4 macro? Regards, Martin