Re: Threading with non-shared libraries

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Threading with non-shared libraries
Date: 2004-12-16 18:13:45
Message-ID: 200412161813.iBGIDjJ23208@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches


OK, applied. I got a private email from the poster stating the patch
works for him. The final patch is slightly different because of the AIX
test.

---------------------------------------------------------------------------

Index: Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.206
diff -c -r1.206 Makefile.global.in
*** Makefile.global.in 16 Dec 2004 17:48:29 -0000 1.206
--- Makefile.global.in 16 Dec 2004 18:12:55 -0000
***************
*** 308,318 ****
--- 308,324 ----

libpq = -L$(libpq_builddir) -lpq

+ # If doing static linking, shared library dependency can't be
+ # used so we specify pthread libs for every usage of libpq
+ ifeq ($(enable_shared), no)
+ libpq += $(PTHREAD_LIBS)
+ else
# AIX libraries do not remember their required libs so we have to force
# thread dependent libraires in the link
ifeq ($(PORTNAME), aix)
libpq += $(PTHREAD_LIBS)
endif
+ endif

submake-libpq:
$(MAKE) -C $(libpq_builddir) all

---------------------------------------------------------------------------

Bruce Momjian wrote:
>
> OK, it took me a while to figure this out, but it is similar to the
> problem we have on AIX. AIX shared libraries don't track other
> libraries needed by the shared library, and non-shared libraries also
> have no such dependency information.
>
> I have attached a patch that is very similar to the AIX fix. It
> basically propagates the thread library flags to all uses of libpq.
>
> Would you please test and report back? Thanks.
>
> ---------------------------------------------------------------------------
>
> Frank van Vugt wrote:
> > L.S.
> >
> > I noticed the following :
> >
> >
> > Workstation used to build RC1:
> >
> > 2.4.21-260-athlon, i686 athlon i386 GNU/Linux
> >
> >
> > Configured with :
> >
> > ./configure
> > --enable-thread-safety
> > --disable-shared
> > --prefix=/usr/src/postgresql/install
> >
> >
> > Error during make install :
> >
> > in directory src/bin/pg_ctl
> >
> > gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
> > -fno-strict-aliasing pg_ctl.o -L../../../src/interfaces/libpq -lpq
> > -L../../../src/port -Wl,-rpath,/usr/src/postgresql/install/lib -lpgport -lz
> > -lreadline -lcrypt -lresolv -lnsl -ldl -lm -o pg_ctl
> > ../../../src/interfaces/libpq/libpq.a(fe-secure.o)(.text+0x140): In function
> > `pq_block_sigpipe':
> > : undefined reference to `pthread_sigmask'
> > ../../../src/interfaces/libpq/libpq.a(fe-secure.o)(.text+0x1e0): In function
> > `pq_reset_sigpipe':
> > : undefined reference to `pthread_sigmask'
> > collect2: ld gaf exit-status 1 terug
> >
> >
> > There seems to be a missing option '-lpthread' here, adding it properly links
> > the file.
> >
> > The same goes for pg_restore, pg_dumpall, psql, createdb, createlang,
> > createuser, dropdb, droplang, dropuser, clusterdb and vacuumdb.
> >

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2004-12-16 18:16:19 Re: pl/pgsql oddity
Previous Message Steve Atkins 2004-12-16 17:37:04 Re: Scheduler in Postgres

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-12-16 23:38:42 Re: Patch to add version numbers to libpq.rc
Previous Message Bruce Momjian 2004-12-16 18:08:36 Re: Threading fix for AIX