Sun Oct 7 10:24:54 2012 UTC ()
databases/postgresql91(-client): Fix build for gcc46 and gcc47

Postgresql91 uses non-constant array sizes in record definitions which
gcc enforces starting with 4.6.  These index sizes are defined as macros
using functions such as offsetof.  These patches introduce enums where
the macros become constant expressions which gcc 4.6+ will accept.

GCC 4.7 also introduces the unused-but-set-variable warning which is
popping up all over the place in pgsql91, so silence these warnings -
they are harmless and get optimized out anyway.

No revbump because functionality won't change on binaries generated with
gcc4.5 and below.


(marino)
diff -r1.9 -r1.10 pkgsrc/databases/postgresql91/distinfo
diff -r1.8 -r1.9 pkgsrc/databases/postgresql91-client/Makefile
diff -r0 -r1.1 pkgsrc/databases/postgresql91/patches/patch-src_backend_access_gist_gistutil.c
diff -r0 -r1.1 pkgsrc/databases/postgresql91/patches/patch-src_include_access_htup.h
diff -r0 -r1.1 pkgsrc/databases/postgresql91/patches/patch-src_include_access_itup.h

cvs diff -r1.9 -r1.10 pkgsrc/databases/postgresql91/Attic/distinfo (expand / switch to unified diff)

--- pkgsrc/databases/postgresql91/Attic/distinfo 2012/10/05 22:15:36 1.9
+++ pkgsrc/databases/postgresql91/Attic/distinfo 2012/10/07 10:24:54 1.10
@@ -1,18 +1,21 @@ @@ -1,18 +1,21 @@
1$NetBSD: distinfo,v 1.9 2012/10/05 22:15:36 adam Exp $ 1$NetBSD: distinfo,v 1.10 2012/10/07 10:24:54 marino Exp $
2 2
3SHA1 (postgresql-9.1.6.tar.bz2) = a24b7c002463572ee7371f055e566b69e39cda3e 3SHA1 (postgresql-9.1.6.tar.bz2) = a24b7c002463572ee7371f055e566b69e39cda3e
4RMD160 (postgresql-9.1.6.tar.bz2) = 83ef4c516658c18c1e2937eee89b05a938aa8620 4RMD160 (postgresql-9.1.6.tar.bz2) = 83ef4c516658c18c1e2937eee89b05a938aa8620
5Size (postgresql-9.1.6.tar.bz2) = 15621370 bytes 5Size (postgresql-9.1.6.tar.bz2) = 15621370 bytes
6SHA1 (patch-config_perl.m4) = c7e5aaff1c47d2e33df7692a412ef984c77ffcc0 6SHA1 (patch-config_perl.m4) = c7e5aaff1c47d2e33df7692a412ef984c77ffcc0
7SHA1 (patch-configure) = dab79533dac06a79a5aa8439d6b15830d8d2fba7 7SHA1 (patch-configure) = dab79533dac06a79a5aa8439d6b15830d8d2fba7
8SHA1 (patch-contrib_dblink_Makefile) = 4960ad57d42465fae203870548e4c53f8a32ce04 8SHA1 (patch-contrib_dblink_Makefile) = 4960ad57d42465fae203870548e4c53f8a32ce04
9SHA1 (patch-contrib_dblink_dblink.c) = 4d7c40d107d4c13c63ef2908d9a02be319863657 9SHA1 (patch-contrib_dblink_dblink.c) = 4d7c40d107d4c13c63ef2908d9a02be319863657
10SHA1 (patch-src_Makefile.shlib) = 2370e3c4260ba7f947b0c15b9bdc43e4820e01a4 10SHA1 (patch-src_Makefile.shlib) = 2370e3c4260ba7f947b0c15b9bdc43e4820e01a4
11SHA1 (patch-src_backend_Makefile) = 76ddd3015d93b19cdd6000eaffc4f53cbd4965b5 11SHA1 (patch-src_backend_Makefile) = 76ddd3015d93b19cdd6000eaffc4f53cbd4965b5
 12SHA1 (patch-src_backend_access_gist_gistutil.c) = 915f545f3cec156cc20b356feb5dd2fdd849dafc
 13SHA1 (patch-src_include_access_htup.h) = 5c057067a55f19af280e500f676583e5b653225e
 14SHA1 (patch-src_include_access_itup.h) = 140981895f4ec05cc0073cd4538721ab43602380
12SHA1 (patch-src_makefiles_Makefile.solaris) = 0168f5bc105ffc89d5db40907a08966d8465f5a0 15SHA1 (patch-src_makefiles_Makefile.solaris) = 0168f5bc105ffc89d5db40907a08966d8465f5a0
13SHA1 (patch-src_pl_plperl_GNUmakefile) = 2b7448d6dd8550e2ea61f40728a2780068b93d07 16SHA1 (patch-src_pl_plperl_GNUmakefile) = 2b7448d6dd8550e2ea61f40728a2780068b93d07
14SHA1 (patch-src_pl_plperl_plperl.h) = bd663fa80a47f7b82ce689060750fa6e631fbc61 17SHA1 (patch-src_pl_plperl_plperl.h) = bd663fa80a47f7b82ce689060750fa6e631fbc61
15SHA1 (patch-src_timezone_localtime.c) = a73769cf05223d2ee06249c9e69c85038c2cd936 18SHA1 (patch-src_timezone_localtime.c) = a73769cf05223d2ee06249c9e69c85038c2cd936
16SHA1 (patch-src_timezone_private.h) = 85dac95e40efc16270885087f868aeb76e1b9214 19SHA1 (patch-src_timezone_private.h) = 85dac95e40efc16270885087f868aeb76e1b9214
17SHA1 (patch-src_timezone_strftime.c) = 25102dce1b9b22385353af23500636fb18e3bf64 20SHA1 (patch-src_timezone_strftime.c) = 25102dce1b9b22385353af23500636fb18e3bf64
18SHA1 (patch-src_timezone_zic.c) = 0d6f536f7593e362ec216eafa73c718ad6bed8fc 21SHA1 (patch-src_timezone_zic.c) = 0d6f536f7593e362ec216eafa73c718ad6bed8fc

cvs diff -r1.8 -r1.9 pkgsrc/databases/postgresql91-client/Attic/Makefile (expand / switch to unified diff)

--- pkgsrc/databases/postgresql91-client/Attic/Makefile 2012/10/02 21:25:46 1.8
+++ pkgsrc/databases/postgresql91-client/Attic/Makefile 2012/10/07 10:24:54 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.8 2012/10/02 21:25:46 asau Exp $ 1# $NetBSD: Makefile,v 1.9 2012/10/07 10:24:54 marino Exp $
2 2
3PKGNAME= ${DISTNAME:C/-/91-client-/} 3PKGNAME= ${DISTNAME:C/-/91-client-/}
4COMMENT= PostgreSQL database client programs 4COMMENT= PostgreSQL database client programs
5 5
6.include "../../databases/postgresql91/Makefile.common" 6.include "../../databases/postgresql91/Makefile.common"
7 7
8USE_TOOLS+= gzip tar 8USE_TOOLS+= gzip tar
9CONFIGURE_ARGS+= --with-openssl 9CONFIGURE_ARGS+= --with-openssl
10CONFIGURE_ARGS+= --with-readline 10CONFIGURE_ARGS+= --with-readline
11CONFIGURE_ARGS+= --with-zlib 11CONFIGURE_ARGS+= --with-zlib
12 12
13# 1. The thread-safety test in ${WRSRC}/src/tools/thread does not pass on 13# 1. The thread-safety test in ${WRSRC}/src/tools/thread does not pass on
14# NetBSD earler than 4.0 or DragonFly. 14# NetBSD earler than 4.0 or DragonFly.
@@ -32,26 +32,29 @@ INSTALL_DIRS+= src/interfaces @@ -32,26 +32,29 @@ INSTALL_DIRS+= src/interfaces
32INSTALL_DIRS+= src/bin 32INSTALL_DIRS+= src/bin
33INSTALL_DIRS+= src/port 33INSTALL_DIRS+= src/port
34BUILD_DIRS= ${INSTALL_DIRS} 34BUILD_DIRS= ${INSTALL_DIRS}
35# Without this, the Darwin build fails (related to -bundle_loader). 35# Without this, the Darwin build fails (related to -bundle_loader).
36BUILD_DIRS+= src/backend 36BUILD_DIRS+= src/backend
37 37
38.for f in pg_service.conf psqlrc 38.for f in pg_service.conf psqlrc
39CONF_FILES+= share/postgresql/${f}.sample ${PKG_SYSCONFDIR}/${f} 39CONF_FILES+= share/postgresql/${f}.sample ${PKG_SYSCONFDIR}/${f}
40.endfor 40.endfor
41 41
42# XXX work around core dumps with the native libedit 42# XXX work around core dumps with the native libedit
43USE_GNU_READLINE= yes 43USE_GNU_READLINE= yes
44 44
 45# Silence unused but set variable warnings from GCC4.7
 46CFLAGS+= -Wno-unused-but-set-variable
 47
45.include "../../devel/readline/buildlink3.mk" 48.include "../../devel/readline/buildlink3.mk"
46.include "../../devel/zlib/buildlink3.mk" 49.include "../../devel/zlib/buildlink3.mk"
47.include "../../security/openssl/buildlink3.mk" 50.include "../../security/openssl/buildlink3.mk"
48 51
49SUBST_CLASSES+= pgxs 52SUBST_CLASSES+= pgxs
50SUBST_STAGE.pgxs= post-build 53SUBST_STAGE.pgxs= post-build
51SUBST_MESSAGE.pgxs= Fixing workdir tools references in pgxs Makefile 54SUBST_MESSAGE.pgxs= Fixing workdir tools references in pgxs Makefile
52SUBST_FILES.pgxs= src/Makefile.global 55SUBST_FILES.pgxs= src/Makefile.global
53SUBST_SED.pgxs= -e 's,${TOOLS_CMD.bison},${TOOLS_PATH.bison},' 56SUBST_SED.pgxs= -e 's,${TOOLS_CMD.bison},${TOOLS_PATH.bison},'
54SUBST_SED.pgxs+= -e 's,${TOOLS_CMD.lex},${TOOLS_PATH.lex},' 57SUBST_SED.pgxs+= -e 's,${TOOLS_CMD.lex},${TOOLS_PATH.lex},'
55SUBST_SED.pgxs+= -e 's,${TOOLS_CMD.mkdir},${TOOLS_PATH.mkdir},' 58SUBST_SED.pgxs+= -e 's,${TOOLS_CMD.mkdir},${TOOLS_PATH.mkdir},'
56SUBST_SED.pgxs+= -e 's,${WRKDIR}/.wrapper/bin/ld,${LD},' 59SUBST_SED.pgxs+= -e 's,${WRKDIR}/.wrapper/bin/ld,${LD},'
57SUBST_SED.pgxs+= -e 's,${WRKDIR}/.wrapper,${PREFIX},' 60SUBST_SED.pgxs+= -e 's,${WRKDIR}/.wrapper,${PREFIX},'

File Added: pkgsrc/databases/postgresql91/patches/Attic/patch-src_backend_access_gist_gistutil.c
$NetBSD: patch-src_backend_access_gist_gistutil.c,v 1.1 2012/10/07 10:24:54 marino Exp $

GCC 4.6 and GCC 4.7 do not consider the storage array has having a constant
size due to the macro definition of GEVHDRSZ found in gist.h
"gistutil.c:248:14: error: storage size of `storage` isn't constant"
Using an enumeration satisfies these compilers.

--- src/backend/access/gist/gistutil.c.orig	2012-09-19 21:50:31.000000000 +0000
+++ src/backend/access/gist/gistutil.c
@@ -244,8 +244,11 @@ gistMakeUnionKey(GISTSTATE *giststate, i
 {
 
 	int			dstsize;
+	enum {
+		GEV_STORAGE_SIZE = 2 * sizeof(GISTENTRY) + GEVHDRSZ
+	};
 
-	static char storage[2 * sizeof(GISTENTRY) + GEVHDRSZ];
+	static char storage[GEV_STORAGE_SIZE];
 	GistEntryVector *evec = (GistEntryVector *) storage;
 
 	evec->n = 2;

File Added: pkgsrc/databases/postgresql91/patches/Attic/patch-src_include_access_htup.h
$NetBSD: patch-src_include_access_htup.h,v 1.1 2012/10/07 10:24:54 marino Exp $

Fixes GCC 4.7 warning and error
Also see comments about similar problems in patch-src_include_access_ihup.h
htup.h:464:2: warning: variably modified 'mt_padding' at file scope
       [enabled by default]
relscan.h:51:15: error: variably modified 'rs_vistuples' at file scope

The relscan.h error is caused by the MaxHeapTuplesPerPage definition found
in htup.h.  Use enum method to satisfy gcc.

--- src/include/access/htup.h.orig	2012-09-19 21:50:31.000000000 +0000
+++ src/include/access/htup.h
@@ -16,6 +16,7 @@
 
 #include "access/tupdesc.h"
 #include "access/tupmacs.h"
+#include "storage/bufpage.h"
 #include "storage/itemptr.h"
 #include "storage/relfilenode.h"
 
@@ -405,9 +406,10 @@ do { \
  * pointers to this anyway, to avoid excessive line-pointer bloat and not
  * require increases in the size of work arrays.
  */
-#define MaxHeapTuplesPerPage	\
-	((int) ((BLCKSZ - SizeOfPageHeaderData) / \
-			(MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData))))
+#define MaxHeapTuplesPerPageInt \
+	(BLCKSZ - SizeOfPageHeaderData) / \
+		(MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + \
+		sizeof(ItemIdData))
 
 /*
  * MaxAttrSize is a somewhat arbitrary upper limit on the declared size of
@@ -452,11 +454,16 @@ do { \
  */
 #define MINIMAL_TUPLE_OFFSET \
 	((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) / MAXIMUM_ALIGNOF * MAXIMUM_ALIGNOF)
-#define MINIMAL_TUPLE_PADDING \
+#define MINIMAL_TUPLE_PADDING_MACRO \
 	((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) % MAXIMUM_ALIGNOF)
 #define MINIMAL_TUPLE_DATA_OFFSET \
 	offsetof(MinimalTupleData, t_infomask2)
 
+enum {
+	MINIMAL_TUPLE_PADDING = MINIMAL_TUPLE_PADDING_MACRO,
+	MaxHeapTuplesPerPage = MaxHeapTuplesPerPageInt
+};
+
 typedef struct MinimalTupleData
 {
 	uint32		t_len;			/* actual length of minimal tuple */

File Added: pkgsrc/databases/postgresql91/patches/Attic/patch-src_include_access_itup.h
$NetBSD: patch-src_include_access_itup.h,v 1.1 2012/10/07 10:24:54 marino Exp $

GCC 4.7 fails on nbtree.h:509:16 with this message:
error: variably modified 'items' at file scope
It does like defining records with "variable" array lengths
Use the enum trick to convertMaxIndexTuplesPerPage into a constant

--- src/include/access/itup.h.orig	2012-09-19 21:50:31.000000000 +0000
+++ src/include/access/itup.h
@@ -133,10 +133,13 @@ typedef IndexAttributeBitMapData *IndexA
  * IndexTupleData struct.  We arrive at the divisor because each tuple
  * must be maxaligned, and it must have an associated item pointer.
  */
-#define MaxIndexTuplesPerPage	\
-	((int) ((BLCKSZ - SizeOfPageHeaderData) / \
-			(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))
+#define MaxIndexTuplesPerPageInt \
+	(BLCKSZ - SizeOfPageHeaderData) / \
+                (MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))
 
+enum {
+	MaxIndexTuplesPerPage = MaxIndexTuplesPerPageInt
+};
 
 /* routines in indextuple.c */
 extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor,