Skip to content
Snippets Groups Projects
Commit e48322a6 authored by Bruce Momjian's avatar Bruce Momjian
Browse files

Be more aggressive about adding flags to thread compiles. The configure

test only tests for building a binary, not building a shared library.

On Linux, you can build a binary with -pthread, but you can't build a
binary that uses a threaded shared library unless you also use -pthread
when building the binary, or adding -lpthread to the shared library
build.  This patch has the effect of doing the later by adding both
-pthread and -lpthread when building libpq.
parent 19f1370b
Branches
Tags
No related merge requests found
...@@ -89,26 +89,29 @@ for flag in $acx_pthread_flags; do ...@@ -89,26 +89,29 @@ for flag in $acx_pthread_flags; do
-*) -*)
AC_MSG_CHECKING([whether pthreads work with $flag]) AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag" tryPTHREAD_CFLAGS="$flag"
;; ;;
pthread-config) pthread-config)
# skip this if we already have flags defined, for PostgreSQL
if test x"$PTHREAD_CFLAGS" != x -o x"$PTHREAD_LIBS" != x; then continue; fi
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
if test x"$acx_pthread_config" = xno; then continue; fi if test x"$acx_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`" tryPTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" tryPTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
fi
;; ;;
*) *)
AC_MSG_CHECKING([for the pthreads library -l$flag]) AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag" tryPTHREAD_LIBS="-l$flag"
;; ;;
esac esac
save_LIBS="$LIBS" save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$tryPTHREAD_LIBS $PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h, # Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we # since some functions may be macros. (On the Sequent, we
...@@ -130,11 +133,13 @@ for flag in $acx_pthread_flags; do ...@@ -130,11 +133,13 @@ for flag in $acx_pthread_flags; do
AC_MSG_RESULT($acx_pthread_ok) AC_MSG_RESULT($acx_pthread_ok)
if test "x$acx_pthread_ok" = xyes; then if test "x$acx_pthread_ok" = xyes; then
break; # we continue with more flags because Linux needs -lpthread
# for libpq builds on PostgreSQL. The test above only
# tests for building binaries, not shared libraries.
PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
fi fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done done
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment