Re: CVS tip compiler error with --enable-thread-safety - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: CVS tip compiler error with --enable-thread-safety
Date
Msg-id 200405301407.i4UE7bJ03989@candle.pha.pa.us
Whole thread Raw
In response to CVS tip compiler error with --enable-thread-safety  (Shridhar Daithankar <shridhar@frodo.hserus.net>)
Responses Re: CVS tip compiler error with --enable-thread-safety
List pgsql-hackers
Shridhar Daithankar wrote:
> Hi,
>
> Platform Slackware linux 9.1/ Linux 2.6.4
>
> I did a make distclean and ./configure --enable-thread-safety. The build
> aborted with following error messages
>
> make[4]: Leaving directory `/home/shridhar/postgresql/pgsql/src/port'
> gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations
> -DFRONTEND -I../../../src/interfaces/libpq -I../../../src/include
> -D_GNU_SOURCE   -c -o initdb.o initdb.c
> rm -f exec.c && ln -s ../../../src/port/exec.c .
> gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations
> -DFRONTEND -I../../../src/interfaces/libpq -I../../../src/include
> -D_GNU_SOURCE   -c -o exec.o exec.c
> gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations
> initdb.o exec.o -L../../../src/interfaces/libpq -lpq -L../../../src/port
> -Wl,-rpath,/usr/local/pgsql/lib -lz -lreadline -ltermcap -lcrypt -lresolv
> -lnsl -ldl -lm  -lpgport -o initdb
> ../../../src/interfaces/libpq/libpq.so: undefined reference to
> `pthread_getspecific'
> ../../../src/interfaces/libpq/libpq.so: undefined reference to `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
> make[3]: *** [initdb] Error 1
> make[3]: Leaving directory `/home/shridhar/postgresql/pgsql/src/bin/initdb'
>
> The relevant configure messages read
> -------------
> 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
> -------------
>
> Here is relevant portion of src/Makefile.global
>
> -------------
> PTHREAD_CFLAGS        = -pthread -D_REENTRANT -D_THREAD_SAFE
> -D_POSIX_PTHREAD_SEMANTICS
> PTHREAD_LIBS        =
> LIBS = -lz -lreadline -ltermcap -lcrypt -lresolv -lnsl -ldl -lm
> -------------
>
> It worked after I manually added -lpthread to LIBS and did a make clean;make

OK, I have applied the following patch which should fix it.  Turns out I
wasn't using the thread libs as part of library creation.

--
  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
? pg_config_paths.h
? _xlk
Index: Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/Makefile,v
retrieving revision 1.14
diff -c -c -r1.14 Makefile
*** Makefile    25 May 2004 01:00:30 -0000    1.14
--- Makefile    30 May 2004 14:06:29 -0000
***************
*** 16,25 ****
  include $(top_builddir)/src/Makefile.global

  override CPPFLAGS := -I$(top_builddir)/src/port $(CPPFLAGS)

- ifdef LIBOBJS
  all: libpgport.a
- endif

  libpgport.a: $(LIBOBJS)
      $(AR) $(AROPT) $@ $^
--- 16,24 ----
  include $(top_builddir)/src/Makefile.global

  override CPPFLAGS := -I$(top_builddir)/src/port $(CPPFLAGS)
+ LIBS += $(PTHREAD_LIBS)

  all: libpgport.a

  libpgport.a: $(LIBOBJS)
      $(AR) $(AROPT) $@ $^

pgsql-hackers by date:

Previous
From: Shridhar Daithankar
Date:
Subject: CVS tip compiler error with --enable-thread-safety
Next
From: Tom Lane
Date:
Subject: Re: v3 protocol & string encoding