From: Todd C. Miller Date: Tue, 11 May 2010 16:11:03 +0000 (-0400) Subject: Link with -lpthread on HP-UX since a plugin may be linked with -lpthread X-Git-Tag: SUDO_1_8_0~649 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7502a3d71f880f65f210c4871721127ae9a25b20;p=sudo Link with -lpthread on HP-UX since a plugin may be linked with -lpthread and dlopen() will fail if the shared object has a dependency on -lpthread but the main program is not linked with it. --- diff --git a/configure b/configure index c8626aed4..e368d741e 100755 --- a/configure +++ b/configure @@ -26404,6 +26404,75 @@ echo "$as_me: WARNING: Unable to locate gssapi.h, you will have to edit the Make LDFLAGS="$_LDFLAGS" fi +# On HP-UX, you cannot dlopen() a shared object that uses pthreads +# unless the main program is linked against -lpthread. Since we +# have no knowledge what libraries a plugin may depend on, we always +# link against -lpthread on HP-UX if it is available. +# This check should go after all other libraries tests. +case "$host" in + *-*-hpux*) + { echo "$as_me:$LINENO: checking for main in -lpthread" >&5 +echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6; } +if test "${ac_cv_lib_pthread_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +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_lib_pthread_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pthread_main=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6; } +if test $ac_cv_lib_pthread_main = yes; then + SUDO_LIBS="${SUDO_LIBS} -lpthread" +fi + + ;; +esac + if test X"$LIBVAS_RPATH" != X""; then if test -n "$blibpath"; then blibpath_add="${blibpath_add}:$LIBVAS_RPATH" diff --git a/configure.in b/configure.in index 546f89ad0..f6cf5777c 100644 --- a/configure.in +++ b/configure.in @@ -2618,6 +2618,17 @@ if test ${with_ldap-'no'} != "no"; then LDFLAGS="$_LDFLAGS" fi +# On HP-UX, you cannot dlopen() a shared object that uses pthreads +# unless the main program is linked against -lpthread. Since we +# have no knowledge what libraries a plugin may depend on, we always +# link against -lpthread on HP-UX if it is available. +# This check should go after all other libraries tests. +case "$host" in + *-*-hpux*) + AC_CHECK_LIB(pthread, main, [SUDO_LIBS="${SUDO_LIBS} -lpthread"]) + ;; +esac + dnl dnl Add LIBVAS_RPATH to LDFLAGS dnl GNU ld accepts -R/path/ as an alias for -rpath /path/