From 06e266e0a5c877e692eab8a653a1ea47adfae43e Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 20 May 2020 23:36:21 +0200 Subject: configure: fix pthread check with static boringssl A shared boringssl/OpenSSL library requires -lcrypto only for linking. A static build additionally requires `-ldl -lpthread`. In the latter case `-lpthread` is added to LIBS which prevented `-pthread` from being added to CFLAGS. Clear LIBS to fix linking failures for libtest tests. --- configure.ac | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 9e1fdbeba..0c1decc72 100755 --- a/configure.ac +++ b/configure.ac @@ -1744,6 +1744,8 @@ if test -z "$ssl_backends" -o "x$OPT_SSL" != xno && # only set this if pkg-config wasn't used CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include" fi + # Linking previously failed, try extra paths from --with-ssl or pkg-config. + # Use a different function name to avoid reusing the earlier cached result. AC_CHECK_LIB(crypto, HMAC_Init_ex,[ HAVECRYPTO="yes" LIBS="-lcrypto $LIBS"], [ @@ -1765,6 +1767,7 @@ if test -z "$ssl_backends" -o "x$OPT_SSL" != xno && [ AC_MSG_RESULT(no) dnl ok, so what about both -ldl and -lpthread? + dnl This may be necessary for static libraries. AC_MSG_CHECKING([OpenSSL linking with -ldl and -lpthread]) LIBS="$CLEANLIBS -lcrypto -ldl -lpthread" @@ -4312,9 +4315,17 @@ if test "$want_pthreads" != "no"; then AC_CHECK_HEADER(pthread.h, [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have ]) save_CFLAGS="$CFLAGS" - - dnl first check for function without lib + dnl When statically linking against boringssl, -lpthread is added to LIBS. + dnl Make sure to that this does not pass the check below, we really want + dnl -pthread in CFLAGS as recommended for GCC. This also ensures that + dnl lib1541 and lib1565 tests are built with these options. Otherwise + dnl they fail the build since tests/libtest/Makefile.am clears LIBS. + save_LIBS="$LIBS" + + LIBS= + dnl Check for libc variants without a separate pthread lib like bionic AC_CHECK_FUNC(pthread_create, [USE_THREADS_POSIX=1] ) + LIBS="$save_LIBS" dnl on HPUX, life is more complicated... case $host in -- cgit v1.2.3