7.4.2 Build broken on (Sparc) Solaris 7 and 8
Environment:
SunOS 5.8 Generic_108528-27 sun4u sparc SUNW,Ultra-250
gcc version 3.3.1
PostgreSQL-7.4.2
./configure --with-java --enable-thread-safety"make" results in:
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations -fPIC -I. -I../../../src/include
-DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/etc"' -c -o thread.o
thread.c
thread.c: In function `pqGetpwuid':
thread.c:116: error: too many arguments to function `*getpwuid_r*'Environment:
SunOS 5.7 Generic_106541-29 sun4u sparc SUNW,UltraSPARC-IIi-Engine
gcc version 3.3.1
PostgreSQL-7.4.2
./configure --with-java --enable-thread-safety"make' results in:
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations -fPIC -I. -I../../../src/include
-DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/etc"' -c -o thread.o
thread.c
thread.c: In function `pqGetpwuid':
thread.c:116: error: too many arguments to function `*getpwuid_r*'
thread.c: In function `pqGethostbyname':
thread.c:189: error: `resbuf' undeclared (first use in this function)
thread.c:189: error: (Each undeclared identifier is reported only once
thread.c:189: error: for each function it appears in.)Diff'ing thread.c between 7.4.1 and 7.4.2, it *looks* like, at first
blush, nothing changed that should affect the relevant code.Anybody got any idea what's broken?
Unfortunately, I know exactly what is broken. First, pre7.4.2 didn't
use thread.c properly. Now that it does, you are breaking on this
issue:
/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
* Do we need to support it? bjm 2003-08-14
*/
/* POSIX version */
getpwuid_r(uid, resultbuf, buffer, buflen, result);
Notice the comment. Do we have to support getpwuid_r that returns
passwd *, and doesn't take a fourth argument? Yea, for Solaris 7 & 8,
we now we now do. I think you can get yours working by just changing
the call to:
result = getpwuid_r(uid, resultbuf, buffer, buflen);
I will have to add configure tests for this and it will work properly
for you in 7.4.3.
--
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
Bruce Momjian wrote:
"make' results in:
gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes
-Wmissing-declarations -fPIC -I. -I../../../src/include
-DFRONTEND -DSYSCONFDIR='"/usr/local/pgsql/etc"' -c -o thread.o
thread.c
thread.c: In function `pqGetpwuid':
thread.c:116: error: too many arguments to function `*getpwuid_r*'
thread.c: In function `pqGethostbyname':
thread.c:189: error: `resbuf' undeclared (first use in this function)
thread.c:189: error: (Each undeclared identifier is reported only once
thread.c:189: error: for each function it appears in.)Diff'ing thread.c between 7.4.1 and 7.4.2, it *looks* like, at first
blush, nothing changed that should affect the relevant code.Anybody got any idea what's broken?
Unfortunately, I know exactly what is broken. First, pre7.4.2 didn't
use thread.c properly. Now that it does, you are breaking on this
issue:/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
* Do we need to support it? bjm 2003-08-14
*/
/* POSIX version */
getpwuid_r(uid, resultbuf, buffer, buflen, result);Notice the comment. Do we have to support getpwuid_r that returns
passwd *, and doesn't take a fourth argument? Yea, for Solaris 7 & 8,
we now we now do. I think you can get yours working by just changing
the call to:result = getpwuid_r(uid, resultbuf, buffer, buflen);
I will have to add configure tests for this and it will work properly
for you in 7.4.3.
OK, patch attached and applied. It adds configure tests for the 5-arg
version of getpwuid_r() and properly falls back to the Posix draft
version you have on Solaris. Seems Solaris 9 also still has the draft
version.
This is backpatched to 7.4.X so it will be in the next release. I have
attached the CVS head and 7.4.X versions of the patch for your testing.
You will need to re-run configure once you apply the patch.
--
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
Attachments:
/bjm/diff.HEADtext/plainDownload
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.331
diff -c -c -r1.331 configure
*** configure 9 Mar 2004 22:40:09 -0000 1.331
--- configure 20 Mar 2004 14:51:42 -0000
***************
*** 13247,13252 ****
--- 13247,13311 ----
#define GETPWUID_THREADSAFE 1
_ACEOF
+ else echo "$as_me:$LINENO: checking whether getpwuid_r takes a fifth argument" >&5
+ echo $ECHO_N "checking whether getpwuid_r takes a fifth argument... $ECHO_C" >&6
+ if test "${pgac_func_getpwuid_r_5arg+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <pwd.h>
+ #ifdef F77_DUMMY_MAIN
+ # ifdef __cplusplus
+ extern "C"
+ # endif
+ int F77_DUMMY_MAIN() { return 1; }
+ #endif
+ int
+ main ()
+ {
+ uid_t uid;
+ struct passwd *space;
+ char *buf;
+ size_t bufsize;
+ struct passwd **result;
+ getpwuid_r(uid, space, buf, bufsize, result);
+ ;
+ return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ pgac_func_getpwuid_r_5arg=yes
+ else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ pgac_func_getpwuid_r_5arg=no
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ echo "$as_me:$LINENO: result: $pgac_func_getpwuid_r_5arg" >&5
+ echo "${ECHO_T}$pgac_func_getpwuid_r_5arg" >&6
+ if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+
+ cat >>confdefs.h <<\_ACEOF
+ #define GETPWUID_R_5ARG
+ _ACEOF
+
+ fi
+
fi
if test "$enable_thread_safety" = yes -a "$GETHOSTBYNAME_THREADSAFE" = yes ; then
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.319
diff -c -c -r1.319 configure.in
*** configure.in 9 Mar 2004 22:40:10 -0000 1.319
--- configure.in 20 Mar 2004 14:51:43 -0000
***************
*** 999,1004 ****
--- 999,1005 ----
fi
if test "$enable_thread_safety" = yes -a "$GETPWUID_THREADSAFE" = yes ; then
AC_DEFINE(GETPWUID_THREADSAFE, 1, [Define if getpwuid is not thread safe])
+ else PGAC_FUNC_GETPWUID_R_5ARG
fi
if test "$enable_thread_safety" = yes -a "$GETHOSTBYNAME_THREADSAFE" = yes ; then
AC_DEFINE(GETHOSTBYNAME_THREADSAFE, 1, [Define if gethostbyname is not thread safe])
Index: config/c-library.m4
===================================================================
RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
retrieving revision 1.24
diff -c -c -r1.24 c-library.m4
*** config/c-library.m4 29 Nov 2003 19:51:17 -0000 1.24
--- config/c-library.m4 20 Mar 2004 14:51:43 -0000
***************
*** 73,78 ****
--- 73,101 ----
])# PGAC_FUNC_GETTIMEOFDAY_1ARG
+ # PGAC_FUNC_GETPWUID_R_5ARG
+ # ---------------------------
+ # Check if getpwuid_r() takes a fifth argument (later POSIX standard, not draft version)
+ # If so, define GETPWUID_R_5ARG
+ AC_DEFUN([PGAC_FUNC_GETPWUID_R_5ARG],
+ [AC_CACHE_CHECK(whether getpwuid_r takes a fifth argument,
+ pgac_func_getpwuid_r_5arg,
+ [AC_TRY_COMPILE([#include <sys/types.h>
+ #include <pwd.h>],
+ [uid_t uid;
+ struct passwd *space;
+ char *buf;
+ size_t bufsize;
+ struct passwd **result;
+ getpwuid_r(uid, space, buf, bufsize, result);],
+ [pgac_func_getpwuid_r_5arg=yes],
+ [pgac_func_getpwuid_r_5arg=no])])
+ if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+ AC_DEFINE(GETPWUID_R_5ARG,, [Define to 1 if getpwuid_r() takes a 5th argument.])
+ fi
+ ])# PGAC_FUNC_GETPWUID_R_5ARG
+
+
# PGAC_UNION_SEMUN
# ----------------
# Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.68
diff -c -c -r1.68 pg_config.h.in
*** src/include/pg_config.h.in 11 Feb 2004 21:44:04 -0000 1.68
--- src/include/pg_config.h.in 20 Mar 2004 14:51:45 -0000
***************
*** 46,51 ****
--- 46,54 ----
/* Define if gethostbyname is not thread safe */
#undef GETHOSTBYNAME_THREADSAFE
+ /* Define to 1 if getpwuid_r() takes a 5th argument. */
+ #undef GETPWUID_R_5ARG
+
/* Define if getpwuid is not thread safe */
#undef GETPWUID_THREADSAFE
Index: src/port/thread.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/thread.c,v
retrieving revision 1.17
diff -c -c -r1.17 thread.c
*** src/port/thread.c 14 Mar 2004 14:01:43 -0000 1.17
--- src/port/thread.c 20 Mar 2004 14:51:46 -0000
***************
*** 97,109 ****
size_t buflen, struct passwd **result)
{
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETPWUID_R)
/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
- * Do we need to support it? bjm 2003-08-14
*/
! /* POSIX version */
! getpwuid_r(uid, resultbuf, buffer, buflen, result);
#else
--- 97,113 ----
size_t buflen, struct passwd **result)
{
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETPWUID_R)
+
+ #ifdef GETPWUID_R_5ARG
+ /* POSIX version */
+ getpwuid_r(uid, resultbuf, buffer, buflen, result);
+ #else
/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
*/
! result = getpwuid_r(uid, resultbuf, buffer, buflen);
! #endif
#else
/bjm/diff.7.4text/plainDownload
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.310.2.8
diff -c -c -r1.310.2.8 configure
*** configure 5 Mar 2004 19:57:18 -0000 1.310.2.8
--- configure 20 Mar 2004 15:36:01 -0000
***************
*** 13484,13489 ****
--- 13484,13548 ----
CFLAGS="$_CFLAGS"
LIBS="$_LIBS"
+ echo "$as_me:$LINENO: checking whether getpwuid_r takes a fifth argument" >&5
+ echo $ECHO_N "checking whether getpwuid_r takes a fifth argument... $ECHO_C" >&6
+ if test "${pgac_func_getpwuid_r_5arg+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <pwd.h>
+ #ifdef F77_DUMMY_MAIN
+ # ifdef __cplusplus
+ extern "C"
+ # endif
+ int F77_DUMMY_MAIN() { return 1; }
+ #endif
+ int
+ main ()
+ {
+ uid_t uid;
+ struct passwd *space;
+ char *buf;
+ size_t bufsize;
+ struct passwd **result;
+ getpwuid_r(uid, space, buf, bufsize, result);
+ ;
+ return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ pgac_func_getpwuid_r_5arg=yes
+ else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ pgac_func_getpwuid_r_5arg=no
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ echo "$as_me:$LINENO: result: $pgac_func_getpwuid_r_5arg" >&5
+ echo "${ECHO_T}$pgac_func_getpwuid_r_5arg" >&6
+ if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+
+ cat >>confdefs.h <<\_ACEOF
+ #define GETPWUID_R_5ARG
+ _ACEOF
+
+ fi
+
fi
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.301.2.6
diff -c -c -r1.301.2.6 configure.in
*** configure.in 5 Mar 2004 19:57:20 -0000 1.301.2.6
--- configure.in 20 Mar 2004 15:36:02 -0000
***************
*** 1061,1066 ****
--- 1061,1067 ----
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
CFLAGS="$_CFLAGS"
LIBS="$_LIBS"
+ PGAC_FUNC_GETPWUID_R_5ARG
fi
Index: config/c-library.m4
===================================================================
RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
retrieving revision 1.23
diff -c -c -r1.23 c-library.m4
*** config/c-library.m4 23 Jul 2003 23:30:39 -0000 1.23
--- config/c-library.m4 20 Mar 2004 15:36:03 -0000
***************
*** 73,78 ****
--- 73,101 ----
])# PGAC_FUNC_GETTIMEOFDAY_1ARG
+ # PGAC_FUNC_GETPWUID_R_5ARG
+ # ---------------------------
+ # Check if getpwuid_r() takes a fifth argument (later POSIX standard, not draft version)
+ # If so, define GETPWUID_R_5ARG
+ AC_DEFUN([PGAC_FUNC_GETPWUID_R_5ARG],
+ [AC_CACHE_CHECK(whether getpwuid_r takes a fifth argument,
+ pgac_func_getpwuid_r_5arg,
+ [AC_TRY_COMPILE([#include <sys/types.h>
+ #include <pwd.h>],
+ [uid_t uid;
+ struct passwd *space;
+ char *buf;
+ size_t bufsize;
+ struct passwd **result;
+ getpwuid_r(uid, space, buf, bufsize, result);],
+ [pgac_func_getpwuid_r_5arg=yes],
+ [pgac_func_getpwuid_r_5arg=no])])
+ if test x"$pgac_func_getpwuid_r_5arg" = xyes ; then
+ AC_DEFINE(GETPWUID_R_5ARG,, [Define to 1 if getpwuid_r() takes a 5th argument.])
+ fi
+ ])# PGAC_FUNC_GETPWUID_R_5ARG
+
+
# PGAC_UNION_SEMUN
# ----------------
# Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.64.2.2
diff -c -c -r1.64.2.2 pg_config.h.in
*** src/include/pg_config.h.in 11 Feb 2004 17:32:09 -0000 1.64.2.2
--- src/include/pg_config.h.in 20 Mar 2004 15:36:04 -0000
***************
*** 43,48 ****
--- 43,51 ----
(--enable-thread-safety) */
#undef ENABLE_THREAD_SAFETY
+ /* Define to 1 if getpwuid_r() takes a 5th argument. */
+ #undef GETPWUID_R_5ARG
+
/* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG
Index: src/port/thread.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/thread.c,v
retrieving revision 1.12.2.3
diff -c -c -r1.12.2.3 thread.c
*** src/port/thread.c 14 Mar 2004 14:01:54 -0000 1.12.2.3
--- src/port/thread.c 20 Mar 2004 15:36:05 -0000
***************
*** 107,120 ****
size_t buflen, struct passwd **result)
{
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && defined(HAVE_GETPWUID_R)
/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
- * Do we need to support it? bjm 2003-08-14
*/
! /* POSIX version */
! getpwuid_r(uid, resultbuf, buffer, buflen, result);
!
#else
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && !defined(HAVE_GETPWUID_R)
--- 107,123 ----
size_t buflen, struct passwd **result)
{
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && defined(HAVE_GETPWUID_R)
+
+ #ifdef GETPWUID_R_5ARG
+ /* POSIX version */
+ getpwuid_r(uid, resultbuf, buffer, buflen, result);
+ #else
/*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen)
*/
! result = getpwuid_r(uid, resultbuf, buffer, buflen);
! #endif
#else
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(NEED_REENTRANT_FUNCS) && !defined(HAVE_GETPWUID_R)
Bruce Momjian <pgman@candle.pha.pa.us> wrote:
[snip]
OK, patch attached and applied. It adds configure tests for the 5-arg
version of getpwuid_r() and properly falls back to the Posix draft
version you have on Solaris. Seems Solaris 9 also still has the draft
version.
[snip]
Well, yes and no. If you define _POSIX_PTHREAD_SEMANTICS, you get the
5-arg version. It looks like this has been the case at least back to
Solaris 2.5.1.
I didn't really expect anything prior to 2.5.1 to be an issue, so I
didn't bother looking into fixes for anything beyond that.
Regards,
Jim
Jim Seymour wrote:
Bruce Momjian <pgman@candle.pha.pa.us> wrote:
[snip]
OK, patch attached and applied. It adds configure tests for the 5-arg
version of getpwuid_r() and properly falls back to the Posix draft
version you have on Solaris. Seems Solaris 9 also still has the draft
version.[snip]
Well, yes and no. If you define _POSIX_PTHREAD_SEMANTICS, you get the
5-arg version. It looks like this has been the case at least back to
Solaris 2.5.1.I didn't really expect anything prior to 2.5.1 to be an issue, so I
didn't bother looking into fixes for anything beyond that.
Oh, very interesting. CVS HEAD has in template/solaris:
# tools/thread/thread_test must be run
if test "$GCC" = yes
then THREAD_CPPFLAGS="-D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-pthread"
else THREAD_CPPFLAGS="-mt -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"
fi
I added the "-D_POSIX_PTHREAD_SEMANTICS" flags into post-7.4.2, so it
seems this platform would work even without checking for the 4-arg
getpwuid_r version. However, I noticed that 'man getpwuid_r' only
mentions the 4-arg version.
I will leave the 4-arg check in. The original author thought it might be
needed, and the Solaris manual mentions it, so odds are some other
platforms will hit it too, and perhaps not have the 5-arg version.
Thanks for the research. I will add a mention in the solaris template
file.
--
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