Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads - Mailing list pgsql-patches

From Larry Rosenman
Subject Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads
Date
Msg-id 22970000.1079703558@lerlaptop.lerctr.org
Whole thread Raw
Responses Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads
Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads
List pgsql-patches
[moved to -patches because of the patch]


--On Friday, March 19, 2004 08:01:53 -0500 Bruce Momjian
<pgman@candle.pha.pa.us> wrote:

> Larry Rosenman wrote:
>> > I thought that once you include libpthread in libpq, that you don't
>> > have to mention it again then you use libpq.  Is your platform
>> > different somehow in this regard?
>> >
>> > I seem to remember this problem with libcrypt and libpq.  Is this the
>> > same problem?
>> >
>> > I see that initdb is just the first of many /bin programs to be
>> > compiled, so if we have to add the thread lib, we will have to do it
>> > for all the bin programs.  Yikes.  Why wasn't this a problem for 7.4?
>> 7.4 had initdb as a Shell Script.
>> the 7.4.x libpq didn't have any pthread_* references in it, that I see
>> on my box.
>
> Ah, yes.  We added the thread-local storage to handle SIGPIPE.  The
> problem is that initdb isn't the only place.  If you comment out initdb
> from the Makefile in src/bin, does the next make fail too?  I bet it
> does.

Apparently, because of the way the wrappers work, having -lpthread on
libpq.so does NOT add it to the NEEDED list.

I made the following patch, and all compiles now:
Index: src/bin/initdb/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/Makefile,v
retrieving revision 1.35
diff -u -r1.35 Makefile
--- src/bin/initdb/Makefile    23 Dec 2003 21:56:20 -0000    1.35
+++ src/bin/initdb/Makefile    19 Mar 2004 13:35:19 -0000
@@ -20,7 +20,7 @@
 all: submake-libpq submake-libpgport initdb

 initdb: $(OBJS) $(libpq_builddir)/libpq.a
-    $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 install: all installdirs
     $(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
Index: src/bin/pg_dump/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/Makefile,v
retrieving revision 1.44
diff -u -r1.44 Makefile
--- src/bin/pg_dump/Makefile    7 Feb 2004 07:20:12 -0000    1.44
+++ src/bin/pg_dump/Makefile    19 Mar 2004 13:35:19 -0000
@@ -25,13 +25,13 @@
 all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore
pg_dumpall

 pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS)
$(libpq_builddir)/libpq.a
-    $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS)
$(libpq) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(EXTRA_OBJS)
$(libpq) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
-    $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS)
$(LIBS) -o $@
+    $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS)
$(LIBS) $(THREAD_LIBS) -o $@

 pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
-    $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq)
$(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq)
$(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 .PHONY: submake-backend
 submake-backend:
Index: src/bin/pg_encoding/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_encoding/Makefile,v
retrieving revision 1.16
diff -u -r1.16 Makefile
--- src/bin/pg_encoding/Makefile    29 Nov 2003 19:52:05 -0000    1.16
+++ src/bin/pg_encoding/Makefile    19 Mar 2004 13:35:19 -0000
@@ -17,7 +17,7 @@
 all: submake-libpq submake-libpgport pg_encoding

 pg_encoding: $(OBJS)
-    $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 install: all installdirs
     $(INSTALL_PROGRAM) pg_encoding$(X) $(DESTDIR)$(bindir)/pg_encoding$(X)
Index: src/bin/pgtclsh/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pgtclsh/Makefile,v
retrieving revision 1.43
diff -u -r1.43 Makefile
--- src/bin/pgtclsh/Makefile    19 Dec 2003 11:54:25 -0000    1.43
+++ src/bin/pgtclsh/Makefile    19 Mar 2004 13:35:20 -0000
@@ -33,10 +33,10 @@
 all: submake $(PROGRAMS)

 pgtclsh: pgtclAppInit.o
-    $(CC) $(CFLAGS) $^ $(libpgtcl) $(libpq) $(TCL_LIB_SPEC) $(TCL_LIBS)
$(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $^ $(libpgtcl) $(libpq) $(TCL_LIB_SPEC) $(TCL_LIBS)
$(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 pgtksh: pgtkAppInit.o
-    $(CC) $(CFLAGS) $^ $(libpgtcl) $(libpq) $(TK_LIB_SPEC) $(TK_LIBS)
$(TCL_LIB_SPEC) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $^ $(libpgtcl) $(libpq) $(TK_LIB_SPEC) $(TK_LIBS)
$(TCL_LIB_SPEC) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 .PHONY: submake
 submake:
Index: src/bin/psql/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/Makefile,v
retrieving revision 1.40
diff -u -r1.40 Makefile
--- src/bin/psql/Makefile    9 Mar 2004 19:47:05 -0000    1.40
+++ src/bin/psql/Makefile    19 Mar 2004 13:35:20 -0000
@@ -27,7 +27,7 @@
 all: submake-libpq submake-libpgport psql

 psql: $(OBJS) $(libpq_builddir)/libpq.a
-    $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 help.o: $(srcdir)/sql_help.h

Index: src/bin/scripts/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/scripts/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- src/bin/scripts/Makefile    29 Nov 2003 19:52:07 -0000    1.25
+++ src/bin/scripts/Makefile    19 Mar 2004 13:35:20 -0000
@@ -20,7 +20,7 @@
 all: submake-libpq submake-backend $(PROGRAMS)

 %: %.o
-    $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@
+    $(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) $(THREAD_LIBS) -o $@

 createdb: createdb.o common.o dumputils.o
$(top_builddir)/src/backend/parser/keywords.o
 createlang: createlang.o common.o print.o mbprint.o
Index: src/template/unixware
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/template/unixware,v
retrieving revision 1.30
diff -u -r1.30 unixware
--- src/template/unixware    11 Feb 2004 21:44:06 -0000    1.30
+++ src/template/unixware    19 Mar 2004 13:35:21 -0000
@@ -24,5 +24,10 @@
   THREAD_CPPFLAGS="-K pthread"
 fi

-# tools/thread/thread_test must be run
+THREAD_SUPPORT=yes
 THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"
+STRERROR_THREADSAFE=yes
+GETPWUID_THREADSAFE=yes
+GETHOSTBYNAME_THREADSAFE=yes
+THREAD_LIBS='-lpthread'
+
Index: src/tools/fsync/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/tools/fsync/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- src/tools/fsync/Makefile    18 Mar 2004 03:56:59 -0000    1.1
+++ src/tools/fsync/Makefile    19 Mar 2004 13:35:21 -0000
@@ -4,7 +4,7 @@
 #
 TARGET = test_fsync
 XFLAGS =
-CFLAGS = -g -Wall
+CFLAGS = -O
 LIBS =

 $(TARGET) : test_fsync.o


--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

pgsql-patches by date:

Previous
From: Robert Treat
Date:
Subject: FAQ updates
Next
From: Fabien COELHO
Date:
Subject: Re: syntax error position "CREATE FUNCTION" bug fix