diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 113 |
1 files changed, 91 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac index de53b1ab25..32a0750e74 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_CANONICAL_HOST PKG_PROG_PKG_CONFIG AC_ARG_ENABLE(openbsd-malloc, - AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD. Linux only])) + AS_HELP_STRING(--enable-openbsd-malloc, [use malloc code from OpenBSD. Linux only. Deprecated: see --with-malloc])) AC_ARG_ENABLE(static-openssl, AS_HELP_STRING(--enable-static-openssl, [link against a static openssl library. Requires --with-openssl-dir])) AC_ARG_ENABLE(static-libevent, @@ -94,8 +94,6 @@ if test "$enable_memory_sentinels" = "no"; then [Defined if we're turning off memory safety code to look for bugs]) fi -AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes") - AC_ARG_ENABLE(asciidoc, AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]), [case "${enableval}" in @@ -193,13 +191,6 @@ if test "$enable_local_appdata" = "yes"; then [Defined if we default to host local appdata paths on Windows]) fi -# Tor2web mode flag -AC_ARG_ENABLE(tor2web-mode, - AS_HELP_STRING(--enable-tor2web-mode, [support tor2web non-anonymous mode]), -[if test "x$enableval" = "xyes"; then - CFLAGS="$CFLAGS -D ENABLE_TOR2WEB_MODE=1" -fi]) - AC_ARG_ENABLE(tool-name-check, AS_HELP_STRING(--disable-tool-name-check, [check for sanely named toolchain when cross-compiling])) @@ -577,8 +568,10 @@ if test "$LIBS" != "$saved_LIBS"; then have_rt=yes fi -AC_SEARCH_LIBS(pthread_create, [pthread]) -AC_SEARCH_LIBS(pthread_detach, [pthread]) +if test "$bwin32" = "false"; then + AC_SEARCH_LIBS(pthread_create, [pthread]) + AC_SEARCH_LIBS(pthread_detach, [pthread]) +fi AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true") AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false") @@ -1690,6 +1683,26 @@ AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT() AC_CHECK_SIZEOF(cell_t) +# Let's see if stdatomic works. (There are some debian clangs that screw it +# up; see Tor bug #26779 and debian bug 903709.) +AC_CACHE_CHECK([whether C11 stdatomic.h actually works], + tor_cv_stdatomic_works, +[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#include <stdatomic.h> +struct x { atomic_size_t y; }; +void try_atomic_init(struct x *xx) +{ + atomic_init(&xx->y, 99); + atomic_fetch_add(&xx->y, 1); +} +]])], [tor_cv_stdatomic_works=yes], [tor_cv_stdatomic_works=no])]) + +if test "$tor_cv_stdatomic_works" = "yes"; then + AC_DEFINE(STDATOMIC_WORKS, 1, [Set to 1 if we can compile a simple stdatomic example.]) +elif test "$ac_cv_header_stdatomic_h" = "yes"; then + AC_MSG_WARN([Your compiler provides the stdatomic.h header, but it doesn't seem to work. I'll pretend it isn't there. If you are using Clang on Debian, maybe this is because of https://bugs.debian.org/903709 ]) +fi + # Now make sure that NULL can be represented as zero bytes. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero, [AC_RUN_IFELSE([AC_LANG_SOURCE( @@ -1820,22 +1833,78 @@ if test "$tor_cv_uint8_uchar" = "no"; then fi AC_ARG_WITH(tcmalloc, -AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]), +AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library. Deprecated; see --with-malloc]), [ tcmalloc=yes ], [ tcmalloc=no ]) -if test "x$tcmalloc" = "xyes"; then - LDFLAGS="-ltcmalloc $LDFLAGS" -fi +default_malloc=system -using_custom_malloc=no -if test "x$enable_openbsd_malloc" = "xyes"; then - using_custom_malloc=yes +if test "x$enable_openbsd_malloc" = "xyes" ; then + AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.]) + default_malloc=openbsd fi + if test "x$tcmalloc" = "xyes"; then - using_custom_malloc=yes + AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.]) + default_malloc=tcmalloc +fi + +AC_ARG_WITH(malloc, + AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]], + [select special malloc implementation [system]]), + [ malloc="$with_malloc" ], [ malloc="$default_malloc" ]) + +AS_CASE([$malloc], + [tcmalloc], [ + PKG_CHECK_MODULES([TCMALLOC], + [libtcmalloc], + have_tcmalloc=yes, + have_tcmalloc=no) + + if test "x$have_tcmalloc" = "xno" ; then + AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc.]) + fi + + CFLAGS="$CFLAGS $TCMALLOC_CFLAGS" + LIBS="$TCMALLOC_LIBS $LIBS" + ], + + [jemalloc], [ + PKG_CHECK_MODULES([JEMALLOC], + [jemalloc], + have_jemalloc=yes, + have_jemalloc=no) + + if test "x$have_tcmalloc" = "xno" ; then + AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc.]) + fi + + CFLAGS="$CFLAGS $JEMALLOC_CFLAGS" + LIBS="$JEMALLOC_LIBS $LIBS" + using_custom_malloc=yes + ], + + [openbsd], [ + AC_MSG_WARN([The openbsd malloc port is deprecated in Tor 0.3.5 and will be removed in a future version.]) + enable_openbsd_malloc=yes + ], + + [system], [ + # handle this later, including the jemalloc fallback + AC_CHECK_FUNCS(mallinfo) + ], + + [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help]) +]) + +AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes") + +if test "$malloc" != "system"; then + # Tell the C compiler not to use the system allocator functions. + TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free]) fi -if test "$using_custom_malloc" = "no"; then - AC_CHECK_FUNCS(mallinfo) +if test "$using_custom_malloc" = "yes"; then + # Tell the C compiler not to use the system allocator functions. + TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free]) fi # By default, we're going to assume we don't have mlockall() |