Merge branch 'ew/autoconf-pthread'
authorJunio C Hamano <gitster@pobox.com>
Mon, 25 Jul 2016 21:13:46 +0000 (14:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Jul 2016 21:13:46 +0000 (14:13 -0700)
Existing autoconf generated test for the need to link with pthread
library did not check all the functions from pthread libraries;
recent FreeBSD has some functions in libc but not others, and we
mistakenly thought linking with libc is enough when it is not.

* ew/autoconf-pthread:
configure.ac: stronger test for pthread linkage

1  2 
configure.ac
diff --combined configure.ac
index c279025747349c19039b0e061954ae67b91b735a,a06177577c92b7e963cdbeb9a008bf1d7242bfa7..aa9c91d20d86fad78c6e2f85d281ad417975a189
@@@ -471,13 -471,6 +471,13 @@@ if test -n "$ASCIIDOC"; the
        esac
  fi
  
 +if grep -a ascii configure.ac >/dev/null; then
 +  AC_MSG_RESULT([Using 'grep -a' for sane_grep])
 +  SANE_TEXT_GREP=-a
 +else
 +  SANE_TEXT_GREP=
 +fi
 +GIT_CONF_SUBST([SANE_TEXT_GREP])
  
  ## Checks for libraries.
  AC_MSG_NOTICE([CHECKS for libraries])
@@@ -528,33 -521,10 +528,33 @@@ AC_CHECK_LIB([curl], [curl_global_init]
  [NO_CURL=],
  [NO_CURL=YesPlease])
  
 +if test -z "${NO_CURL}" && test -z "${NO_OPENSSL}"; then
 +
 +AC_CHECK_LIB([curl], [Curl_ssl_init],
 +[NEEDS_SSL_WITH_CURL=YesPlease],
 +[NEEDS_SSL_WITH_CURL=])
 +
 +GIT_CONF_SUBST([NEEDS_SSL_WITH_CURL])
 +
 +fi
 +
  GIT_UNSTASH_FLAGS($CURLDIR)
  
  GIT_CONF_SUBST([NO_CURL])
  
 +if test -z "$NO_CURL"; then
 +
 +AC_CHECK_PROG([CURL_CONFIG], [curl-config],
 +[curl-config],
 +[no])
 +
 +if test $CURL_CONFIG != no; then
 +    GIT_CONF_SUBST([CURL_CONFIG])
 +fi
 +
 +fi
 +
 +
  #
  # Define NO_EXPAT if you do not have expat installed.  git-http-push is
  # not built, and you cannot push using http:// and https:// transports.
@@@ -797,6 -767,13 +797,6 @@@ elif test x$ac_cv_member_struct_stat_st
        GIT_CONF_SUBST([NO_NSEC])
  fi
  #
 -# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 -AC_CHECK_MEMBER(struct dirent.d_ino,
 -[NO_D_INO_IN_DIRENT=],
 -[NO_D_INO_IN_DIRENT=YesPlease],
 -[#include <dirent.h>])
 -GIT_CONF_SUBST([NO_D_INO_IN_DIRENT])
 -#
  # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
  # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
  AC_CHECK_MEMBER(struct dirent.d_type,
@@@ -970,6 -947,10 +970,6 @@@ AC_CHECK_LIB([iconv], [locale_charset]
                       [CHARSET_LIB=-lcharset])])
  GIT_CONF_SUBST([CHARSET_LIB])
  #
 -# Define NO_HMAC_CTX_CLEANUP=YesPlease if HMAC_CTX_cleanup is missing.
 -AC_CHECK_LIB([crypto], [HMAC_CTX_cleanup],
 -      [], [GIT_CONF_SUBST([NO_HMAC_CTX_CLEANUP], [YesPlease])])
 -#
  # Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
  GIT_CHECK_FUNC(clock_gettime,
        [HAVE_CLOCK_GETTIME=YesPlease],
@@@ -1060,12 -1041,6 +1060,12 @@@ GIT_CHECK_FUNC(initgroups
  [NO_INITGROUPS=YesPlease])
  GIT_CONF_SUBST([NO_INITGROUPS])
  #
 +# Define HAVE_GETDELIM if you have getdelim in the C library.
 +GIT_CHECK_FUNC(getdelim,
 +[HAVE_GETDELIM=YesPlease],
 +[HAVE_GETDELIM=])
 +GIT_CONF_SUBST([HAVE_GETDELIM])
 +#
  #
  # Define NO_MMAP if you want to avoid mmap.
  #
@@@ -1108,14 -1083,19 +1108,19 @@@ GIT_CONF_SUBST([HAVE_BSD_SYSCTL]
  AC_DEFUN([PTHREADTEST_SRC], [
  AC_LANG_PROGRAM([[
  #include <pthread.h>
+ static void *noop(void *ignore) { return ignore; }
  ]], [[
        pthread_mutex_t test_mutex;
        pthread_key_t test_key;
+       pthread_t th;
        int retcode = 0;
+       void *ret = (void *)0;
        retcode |= pthread_key_create(&test_key, (void *)0);
        retcode |= pthread_mutex_init(&test_mutex,(void *)0);
        retcode |= pthread_mutex_lock(&test_mutex);
        retcode |= pthread_mutex_unlock(&test_mutex);
+       retcode |= pthread_create(&th, ret, noop, ret);
+       retcode |= pthread_join(th, &ret);
        return retcode;
  ]])])
  
@@@ -1145,12 -1125,7 +1150,12 @@@ elif test -z "$PTHREAD_CFLAGS"; the
    # would then trigger compiler warnings on every single file we compile.
    for opt in "" -mt -pthread -lpthread; do
       old_CFLAGS="$CFLAGS"
 -     CFLAGS="$opt $CFLAGS"
 +     old_LIBS="$LIBS"
 +     case "$opt" in
 +        -l*)  LIBS="$opt $LIBS" ;;
 +        *)    CFLAGS="$opt $CFLAGS" ;;
 +     esac
 +
       AC_MSG_CHECKING([for POSIX Threads with '$opt'])
       AC_LINK_IFELSE([PTHREADTEST_SRC],
        [AC_MSG_RESULT([yes])
        ],
        [AC_MSG_RESULT([no])])
        CFLAGS="$old_CFLAGS"
 +      LIBS="$old_LIBS"
    done
    if test $threads_found != yes; then
      AC_CHECK_LIB([pthread], [pthread_create],