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 CC71C14B281B for ; Wed, 11 Aug 2004 12:55:17 -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 06883-02 for ; Wed, 11 Aug 2004 15:55:13 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 8489114B286D for ; Wed, 11 Aug 2004 12:55:10 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i7BFsa609431; Wed, 11 Aug 2004 11:54:36 -0400 (EDT) From: Bruce Momjian Message-Id: <200408111554.i7BFsa609431@candle.pha.pa.us> Subject: Re: 8.0.0beta1: -lpthread missing In-Reply-To: <4119D11C.5010206@betrusted.com> To: =?ISO-8859-1?Q?Martin_M=FCnstermann?= Date: Wed, 11 Aug 2004 11:54:36 -0400 (EDT) Cc: Robert Treat , pgsql-bugs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UNKNOWN-8BIT 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/76 X-Sequence-Number: 8866 OK, I have some more information. Basically, the config/acx_pthread.m4 manual page (http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html) says: 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. If I add -g3 in interfaces/libpq/Makefile: override CFLAGS += $(PTHREAD_CFLAGS) -g3 I see -g3 in the libpq link line: gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -g3 -fpic -shared ^^^ -Wl,-x,-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 -L/usr/local/lib -L/usr/contrib/lib -lintl -lssl -lcrypto -lc -Wl,-rpath,/usr/local/pgsql/lib -o libpq.so.3.2 Do you see similar behavior in Slackware? I assumed all compilers would use $CFLAGS in their link lines. --------------------------------------------------------------------------- Martin Münstermann wrote: > Hello! > > Bruce Momjian wrote: > > Robert Treat wrote: > > > >>>`pthread_once' > >>>../../../src/interfaces/libpq/libpq.so: undefined reference to > >>>`pthread_key_create' > >>>../../../src/interfaces/libpq/libpq.so: undefined reference to > >>>`pthread_setspecific' > >>>collect2: ld returned 1 exit status > >>> > >>> > >>> > >>>Please describe a way to repeat the problem. Please try to provide a > >>>concise reproducible example, if at all possible: > >>>---------------------------------------------------------------------- > >>># ./configure --prefix=/opt/postgresql-800beta1 --enable-thread-safety > >>># make > >>> > >>> > >>>If you know how this problem might be fixed, list the solution below: > >>>--------------------------------------------------------------------- > >>>The binaries must be linked with pthread (-lpthread). > >>> > >> > >>Can you take a look at the thread below and report back if that fixes your > >>problem? http://archives.postgresql.org/pgsql-hackers/2004-08/msg00525.php > > Yes, adding -lpthread to PTHREAD_LIBS and rebuilding solved the problem. > Note: when doing so, libpq.so is built with -lpthread, PTHREAD_LIBS is > *not* used in the makefiles of the client binaries like initdb and psql. > > > I looked at that. The line that does the tests is in > > config/acx_pthread.m4: > > > > acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread > > -pthreads -mthreads pthread --thread-safe -mt pthread-conf ig" > > > > so you should see that list tried. Does that help? > > > > I am majorly concerned that Slackware has the same problem as Unixware, > > meaning that if you use threading in the lib, you now need the flags on > > every applicaiton that uses the lib. > > At least on debian this is not the case (see above): > -lpthread is used when building libpq.so.3.2. > So the shared library contains a dependency on libpthread.so. > Then the client apps do not need a -lpthread at build time. The dynamic > linker will resolve the dependency on libpthread.so (via libpq.so) at > runtime. > > Regards, > Martin > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073