Re: solaris libpq threaded build fails - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: solaris libpq threaded build fails
Date
Msg-id 200901141643.n0EGhQS18861@momjian.us
Whole thread Raw
In response to Re: solaris libpq threaded build fails  (Andrew Chernow <ac@esilo.com>)
Responses Re: solaris libpq threaded build fails  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-hackers
Andrew Chernow wrote:
>
> >>>
> >> Forgot to mention, there is an easy fix:
> >>
> >> ~]# LDFLAGS="-lnsl" ./configure --enable-thread-safety
> >
> > But I assume that only works if I use gethostbyname_r(), right?
>
> No, works for gethostbyname as well.  They are all in libnsl.
>
> > But we do check for that in thread_test.c.
>
> The problem with the current check is its only an AC_CHECK_FUNCS.
> We need an AC_SEARCH_LIBS first so the proper -llibrary is
> appended to LIBS, which is used by AC_CHECK_FUNCS.
>
> AC_SEARCH_LIBS(gethostbyname_r, c nsl) AC_CHECK_FUNCS([strerror_r
> getpwuid_r gethostbyname_r])
>
> (AC_CHECK_FUNCS from configure.in line 1371)

OK, patch attached and applied to CVS HEAD.  The nsl (not 'nls') library
check was removed in Postgres 8.2 here:

    http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/configure.in.diff?r1=1.448;r2=1.445;f=h

The new code is more specific by testing for gethostbyname_r() and only
on Solaris.  I also added a comment about why it was re-added.

The next question is do we backpatch this back to 8.2?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: configure
===================================================================
RCS file: /cvsroot/pgsql/configure,v
retrieving revision 1.626
diff -c -c -r1.626 configure
*** configure    11 Jan 2009 18:02:15 -0000    1.626
--- configure    14 Jan 2009 16:37:21 -0000
***************
*** 7743,7748 ****
--- 7743,7836 ----

  fi

+ # Required for thread_test.c on Solaris 2.5:
+ case $host_os in
+      solaris*)
+     { echo "$as_me:$LINENO: checking for library containing gethostbyname_r" >&5
+ echo $ECHO_N "checking for library containing gethostbyname_r... $ECHO_C" >&6; }
+ if test "${ac_cv_search_gethostbyname_r+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_func_search_save_LIBS=$LIBS
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+
+ /* Override any GCC internal prototype to avoid an error.
+    Use char because int might match the return type of a GCC
+    builtin and then its argument prototype would still apply.  */
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ char gethostbyname_r ();
+ int
+ main ()
+ {
+ return gethostbyname_r ();
+   ;
+   return 0;
+ }
+ _ACEOF
+ for ac_lib in '' nsl; do
+   if test -z "$ac_lib"; then
+     ac_res="none required"
+   else
+     ac_res=-l$ac_lib
+     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+   fi
+   rm -f conftest.$ac_objext conftest$ac_exeext
+ if { (ac_try="$ac_link"
+ case "(($ac_try" in
+   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+   *) ac_try_echo=$ac_try;;
+ esac
+ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+   (eval "$ac_link") 2>conftest.er1
+   ac_status=$?
+   grep -v '^ *+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } && {
+      test -z "$ac_c_werror_flag" ||
+      test ! -s conftest.err
+        } && test -s conftest$ac_exeext &&
+        $as_test_x conftest$ac_exeext; then
+   ac_cv_search_gethostbyname_r=$ac_res
+ else
+   echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+
+ fi
+
+ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+       conftest$ac_exeext
+   if test "${ac_cv_search_gethostbyname_r+set}" = set; then
+   break
+ fi
+ done
+ if test "${ac_cv_search_gethostbyname_r+set}" = set; then
+   :
+ else
+   ac_cv_search_gethostbyname_r=no
+ fi
+ rm conftest.$ac_ext
+ LIBS=$ac_func_search_save_LIBS
+ fi
+ { echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname_r" >&5
+ echo "${ECHO_T}$ac_cv_search_gethostbyname_r" >&6; }
+ ac_res=$ac_cv_search_gethostbyname_r
+ if test "$ac_res" != no; then
+   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+ fi
+
+     ;;
+ esac
  # Cygwin:
  { echo "$as_me:$LINENO: checking for library containing shmget" >&5
  echo $ECHO_N "checking for library containing shmget... $ECHO_C" >&6; }
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql/configure.in,v
retrieving revision 1.585
diff -c -c -r1.585 configure.in
*** configure.in    11 Jan 2009 18:02:17 -0000    1.585
--- configure.in    14 Jan 2009 16:37:21 -0000
***************
*** 870,875 ****
--- 870,881 ----
  AC_SEARCH_LIBS(crypt, crypt)
  # Solaris:
  AC_SEARCH_LIBS(fdatasync, [rt posix4])
+ # Required for thread_test.c on Solaris 2.5:
+ case $host_os in
+      solaris*)
+     AC_SEARCH_LIBS(gethostbyname_r, nsl)
+     ;;
+ esac
  # Cygwin:
  AC_SEARCH_LIBS(shmget, cygipc)


pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: A single escape required for log_filename
Next
From: "Merlin Moncure"
Date:
Subject: Re: solaris libpq threaded build fails