diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-01-09 12:56:20 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-01-09 12:56:20 +0000 |
commit | c6d8e37674e56ce3a93d68dbba1089ecd7790d19 (patch) | |
tree | 3732a96317418d3a8866c7adccf05537753f9b58 /acinclude.m4 | |
parent | da20c322ca11c421a48472fb6d7ca6df5d3be8f8 (diff) | |
download | mpfr-c6d8e37674e56ce3a93d68dbba1089ecd7790d19.tar.gz |
Cleaned up configure code related to threading and the shared cache.
* acinclude.m4:
- detect incompatibilities between configure options at the
beginning of MPFR_CONFIGS, forcing enable_thread_safe to
"no" or "yes" when necessary, so that the subsequent code
can rely on that;
- check ISO C11 thread support and/or POSIX thread support
only when necessary;
- handle --enable-shared-cache early in MPFR_CONFIGS, because
the use of POSIX threads (pthread) may need to change CC,
CFLAGS, and LIBS (thus affecting other tests);
- test $enable_shared_cache instead of $mpfr_want_shared_cache;
- removed the now useless MPFR_CHECK_SHARED_CACHE function.
* configure.ac: no longer set the mpfr_want_shared_cache variable,
as enable_shared_cache (now used) already has the same usage.
Note: currently,
./configure --enable-shared-cache CFLAGS="-std=c99"
still succeeds and still makes the compilation fail. This seems to
be due to a limitation of AX_PTHREAD, which just tests linking, not
compilation.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13392 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 120 |
1 files changed, 62 insertions, 58 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 767b26bf1..3bcf342c8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -38,12 +38,74 @@ dnl - Libtool stuff. dnl - Handling of special arguments of MPFR's configure. AC_DEFUN([MPFR_CONFIGS], [ +dnl First, detect incompatibilities between configure options. +if test "$enable_logging" = yes; then + if test "$enable_thread_safe" = yes; then + AC_MSG_ERROR([enable either logging or thread-safe, not both]) + fi +dnl The following test is done only to output a specific error message, +dnl as there would otherwise be an error due to enable_thread_safe=no. + if test "$enable_shared_cache" = yes; then + AC_MSG_ERROR([shared cache does not work with logging support]) + fi + enable_thread_safe=no +fi +if test "$enable_shared_cache" = yes; then + if test "$enable_thread_safe" = no; then + AC_MSG_ERROR([shared cache needs thread-safe support]) + fi + enable_thread_safe=yes +fi + AC_REQUIRE([AC_OBJEXT]) AC_REQUIRE([MPFR_CHECK_LIBM]) AC_REQUIRE([MPFR_CHECK_LIBQUADMATH]) AC_REQUIRE([AC_HEADER_TIME]) AC_REQUIRE([AC_CANONICAL_HOST]) +dnl Features for the MPFR shared cache. This needs to be done +dnl quite early since this may change CC, CFLAGS and LIBS, which +dnl may affect the other tests. + +if test "$enable_shared_cache" = yes; then + +dnl Prefer ISO C11 threads (as in mpfr-thread.h). + MPFR_CHECK_C11_THREAD() + + if test "$mpfr_c11_thread_ok" != yes; then +dnl Check for POSIX threads. Since the AX_PTHREAD macro is not standard +dnl (it is provided by autoconf-archive), we need to detect whether it +dnl is left unexpanded, otherwise the configure script won't fail and +dnl "make distcheck" won't give any error, yielding buggy tarballs! +dnl The \b is necessary to avoid an error with recent ax_pthread.m4 +dnl (such as with Debian's autoconf-archive 20160320-1), which contains +dnl AX_PTHREAD_ZOS_MISSING, etc. It is not documented, but see: +dnl https://lists.gnu.org/archive/html/autoconf/2015-03/msg00011.html +dnl +dnl Note: each time a change is done in m4_pattern_forbid, autogen.sh +dnl should be tested with and without ax_pthread.m4 availability (in +dnl the latter case, there should be an error). + m4_pattern_forbid([AX_PTHREAD\b]) + AX_PTHREAD([]) + fi + + AC_MSG_CHECKING(if shared cache can be supported) + if test "$mpfr_c11_thread_ok" = yes; then + AC_MSG_RESULT([yes, with ISO C11 threads]) + elif test "$ax_pthread_ok" = yes; then + AC_MSG_RESULT([yes, with pthread]) + CC="$PTHREAD_CC" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$LIBS $PTHREAD_LIBS" + else + AC_MSG_RESULT(no) + AC_MSG_ERROR([shared cache needs C11 threads or pthread support]) + fi + +fi + +dnl End of features for the MPFR shared cache. + AC_CHECK_HEADER([limits.h],, AC_MSG_ERROR([limits.h not found])) AC_CHECK_HEADER([float.h],, AC_MSG_ERROR([float.h not found])) AC_CHECK_HEADER([string.h],, AC_MSG_ERROR([string.h not found])) @@ -209,24 +271,6 @@ fi dnl Check for attribute constructor and destructor MPFR_CHECK_CONSTRUCTOR_ATTR() -dnl Check for POSIX Thread. Since the AX_PTHREAD macro is not standard -dnl (it is provided by autoconf-archive), we need to detect whether it -dnl is left unexpanded, otherwise the configure script won't fail and -dnl "make distcheck" won't give any error, yielding buggy tarballs! -dnl The \b is necessary to avoid an error with recent ax_pthread.m4 -dnl (such as with Debian's autoconf-archive 20160320-1), which contains -dnl AX_PTHREAD_ZOS_MISSING, etc. It is not documented, but see: -dnl https://lists.gnu.org/archive/html/autoconf/2015-03/msg00011.html -dnl -dnl Note: each time a change is done in m4_pattern_forbid, autogen.sh -dnl should be tested with and without ax_pthread.m4 availability (in -dnl the latter case, there should be an error). -m4_pattern_forbid([AX_PTHREAD\b]) -AX_PTHREAD([]) - -dnl Check for ISO C11 Thread -MPFR_CHECK_C11_THREAD() - dnl Check for fesetround AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [ saved_LIBS="$LIBS" @@ -507,14 +551,6 @@ LIBS="$saved_LIBS" dnl Now try to check the long double format MPFR_C_LONG_DOUBLE_FORMAT -if test "$enable_logging" = yes; then - if test "$enable_thread_safe" = yes; then - AC_MSG_ERROR([enable either `Logging' or `thread-safe', not both]) - else - enable_thread_safe=no - fi -fi - dnl Check if thread-local variables are supported. dnl At least two problems can occur in practice: dnl 1. The compilation fails, e.g. because the compiler doesn't know @@ -754,11 +790,6 @@ if test "$enable_lto" = "yes" ; then MPFR_LTO fi -dnl Check if the shared cache was requested and its requirements are ok. -if test "$mpfr_want_shared_cache" = yes ;then - MPFR_CHECK_SHARED_CACHE() -fi - ]) dnl end of MPFR_CONFIGS @@ -1622,33 +1653,6 @@ mpfr_compile_and_link() rm -f conftest* ]) -dnl MPFR_CHECK_SHARED_CACHE -dnl ---------------------- -dnl Check if the conditions for the shared cache are met: -dnl * either pthread / C11 are available. -dnl * either constructor or once. -AC_DEFUN([MPFR_CHECK_SHARED_CACHE], [ - AC_MSG_CHECKING(if shared cache is supported) - if test "$enable_logging" = yes ; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([shared cache does not work with logging support.]) -dnl because logging support disables threading support - elif test "$enable_thread_safe" != yes ; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([shared cache needs thread attribute.]) - elif test "$ax_pthread_ok" != yes && "$mpfr_c11_thread_ok" != yes ; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([shared cache needs pthread/C11 library.]) - else - AC_MSG_RESULT(yes) - if test "$ax_pthread_ok" = yes ; then - CC="$PTHREAD_CC" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$LIBS $PTHREAD_LIBS" - fi - fi -]) - dnl MPFR_CHECK_CONSTRUCTOR_ATTR dnl --------------------------- dnl Check for constructor/destructor attributes to function. |