Refactored OpenSSL library checks in Mesos. Since gRPC requires OpenSSL, we checks if libssl and libcrypto exist no matter if the `--enable-ssl` flag is on. This enables us to have a non-SSL-enabled Mesos build with gRPC support. Also fixed errors that a bad linker might link the configure tests with libssl unnecessarily, which would cause runtime failures if libssl is not in the runtime library search path.
Review: https://reviews.apache.org/r/61433 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fa8b3111 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fa8b3111 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fa8b3111 Branch: refs/heads/master Commit: fa8b311152cd5780db2fb962cb88e46333764991 Parents: f2b16ca Author: Chun-Hung Hsiao <[email protected]> Authored: Tue Aug 8 18:04:28 2017 -0700 Committer: Jie Yu <[email protected]> Committed: Thu Aug 10 16:55:06 2017 -0700 ---------------------------------------------------------------------- configure.ac | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/fa8b3111/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 08f4339..b6a6deb 100644 --- a/configure.ac +++ b/configure.ac @@ -1700,7 +1700,7 @@ __EOF__ # distcheck failure on OSX by leaking build artefacts (.dsym). AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], [SASL_TEST_CFLAGS=""], [SASL_TEST_CFLAGS=$CFLAGS]) -$CC crammd5_installed.c $CPPFLAGS $SASL_TEST_CFLAGS $LDFLAGS -lsasl2 $LIBS \ +$CC crammd5_installed.c $CPPFLAGS $SASL_TEST_CFLAGS $LDFLAGS -lsasl2 \ -o crammd5_installed 2>&1 >/dev/null # Run the test binary and get its output. @@ -1732,27 +1732,33 @@ if test -n "`echo $with_ssl`"; then LDFLAGS="-L${with_ssl}/lib $LDFLAGS" fi +AC_CHECK_LIB([crypto], [RAND_poll], [found_crypto=yes]) + +AC_CHECK_HEADERS([openssl/ssl.h], + [AC_CHECK_LIB([ssl], + [SSL_CTX_new], + [found_ssl=yes], + [], + [-lcrypto])]) + if test "x$enable_ssl" = "xyes"; then - AC_CHECK_HEADERS([openssl/ssl.h], - [AC_CHECK_LIB([ssl], - [SSL_CTX_new], - [], - [AC_MSG_ERROR([cannot find libssl -------------------------------------------------------------------- -libssl is required for an SSL-enabled build. -------------------------------------------------------------------- - ])])], - [AC_MSG_ERROR([cannot find libssl headers + if test "x$found_ssl" != "xyes"; then + AC_MSG_ERROR([cannot find libssl ------------------------------------------------------------------- libssl is required for an SSL-enabled build. ------------------------------------------------------------------- - ])]) + ]) + fi - AC_CHECK_LIB([crypto], [RAND_poll], [], [AC_MSG_ERROR([cannot find libcrypto + if test "x$found_crypto" != "xyes"; then + AC_MSG_ERROR([cannot find libcrypto ------------------------------------------------------------------- libcrypto is required for an SSL-enabled build. ------------------------------------------------------------------- - ])]) + ]) + fi + + LIBS="-lssl -lcrypto $LIBS" if test "x$enable_libevent" = "xyes"; then AC_CHECK_HEADERS([event2/bufferevent_ssl.h], @@ -1975,6 +1981,10 @@ AM_CONDITIONAL([WITH_BUNDLED_ZOOKEEPER], # affected by libcxx undefined behavior, # https://llvm.org/bugs/show_bug.cgi?id=28469. AC_MSG_CHECKING([C++ standard library for undefined behaviour with selected optimization level]) +# NOTE: We clear `LIBS` here to prevent linking in libraries unrelated +# to the test. These libraries might not be in the linker lookup paths. +saved_LIBS="$LIBS" +LIBS="" AC_LANG_PUSH([C++]) AC_RUN_IFELSE([ AC_LANG_SOURCE([[ @@ -2000,6 +2010,7 @@ AC_RUN_IFELSE([ ] ) AC_LANG_POP([C++]) +LIBS="$saved_LIBS" # NOTE: Do not update any compiler or linker settings (e.g. CXXFLAGS,
