diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 590 |
1 files changed, 393 insertions, 197 deletions
diff --git a/configure.ac b/configure.ac index d00e1f74be..31e41c3bbc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ dnl Copyright (c) 2001-2004, Roger Dingledine dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -dnl Copyright (c) 2007-2017, The Tor Project, Inc. +dnl Copyright (c) 2007-2018, The Tor Project, Inc. dnl See LICENSE for licensing information AC_PREREQ([2.63]) -AC_INIT([tor],[0.3.4.0-alpha-dev]) -AC_CONFIG_SRCDIR([src/or/main.c]) +AC_INIT([tor],[0.4.0.0-alpha-dev]) +AC_CONFIG_SRCDIR([src/app/main/tor_main.c]) AC_CONFIG_MACRO_DIR([m4]) # "foreign" means we don't follow GNU package layout standards @@ -21,18 +21,8 @@ AC_CANONICAL_HOST PKG_PROG_PKG_CONFIG -if test -f "/etc/redhat-release"; then - if test -f "/usr/kerberos/include"; then - CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include" - fi -fi - -# Not a no-op; we want to make sure that CPPFLAGS is set before we use -# the += operator on it in src/or/Makefile.am -CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src/common" - 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, @@ -63,6 +53,10 @@ AC_ARG_ENABLE(restart-debugging, AS_HELP_STRING(--enable-restart-debugging, [Build Tor with support for debugging in-process restart. Developers only.])) AC_ARG_ENABLE(zstd-advanced-apis, AS_HELP_STRING(--disable-zstd-advanced-apis, [Build without support for zstd's "static-only" APIs.])) +AC_ARG_ENABLE(nss, + AS_HELP_STRING(--enable-nss, [Use Mozilla's NSS TLS library. (EXPERIMENTAL)])) +AC_ARG_ENABLE(pic, + AS_HELP_STRING(--enable-pic, [Build Tor's binaries as position-independent code, suitable to link as a library.])) if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then AC_MSG_ERROR([Can't disable assertions outside of coverage build]) @@ -74,6 +68,16 @@ AM_CONDITIONAL(DISABLE_ASSERTS_IN_UNIT_TESTS, test "x$enable_asserts_in_tests" = AM_CONDITIONAL(LIBFUZZER_ENABLED, test "x$enable_libfuzzer" = "xyes") AM_CONDITIONAL(OSS_FUZZ_ENABLED, test "x$enable_oss_fuzz" = "xyes") AM_CONDITIONAL(USE_RUST, test "x$enable_rust" = "xyes") +AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes") +AM_CONDITIONAL(USE_OPENSSL, test "x$enable_nss" != "xyes") + +if test "x$enable_nss" = "xyes"; then + AC_DEFINE(ENABLE_NSS, 1, + [Defined if we're building with NSS.]) +else + AC_DEFINE(ENABLE_OPENSSL, 1, + [Defined if we're building with OpenSSL or LibreSSL]) +fi if test "$enable_static_tor" = "yes"; then enable_static_libevent="yes"; @@ -92,8 +96,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 @@ -176,6 +178,7 @@ AC_ARG_ENABLE(fragile-hardening, AS_HELP_STRING(--enable-fragile-hardening, [enable more fragile and expensive compiler hardening; makes Tor slower])) if test "x$enable_expensive_hardening" = "xyes" || test "x$enable_fragile_hardening" = "xyes"; then fragile_hardening="yes" + AC_DEFINE(DEBUG_SMARTLIST, 1, [Enable smartlist debugging]) fi dnl Linker hardening options @@ -190,13 +193,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])) @@ -230,6 +226,31 @@ if test "x$enable_android" = "xyes"; then fi +dnl --- +dnl Tor modules options. These options are namespaced with --disable-module-XXX +dnl --- + +dnl All our modules. +m4_define(MODULES, dirauth) + +dnl Directory Authority module. +AC_ARG_ENABLE([module-dirauth], + AS_HELP_STRING([--disable-module-dirauth], + [Do not build tor with the dirauth module]), + [], dnl Action if-given + AC_DEFINE([HAVE_MODULE_DIRAUTH], [1], + [Compile with Directory Authority feature support])) +AM_CONDITIONAL(BUILD_MODULE_DIRAUTH, [test "x$enable_module_dirauth" != "xno"]) + +dnl Helper variables. +TOR_MODULES_ALL_ENABLED= +AC_DEFUN([ADD_MODULE], [ + MODULE=m4_toupper($1) + TOR_MODULES_ALL_ENABLED="${TOR_MODULES_ALL_ENABLED} -DHAVE_MODULE_${MODULE}=1" +]) +m4_foreach_w([module], MODULES, [ADD_MODULE([module])]) +AC_SUBST(TOR_MODULES_ALL_ENABLED) + dnl check for the correct "ar" when cross-compiling. dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require, dnl so kludge up a replacement for the case where it isn't there yet.) @@ -274,14 +295,21 @@ AM_PROG_CC_C_O AC_PROG_CC_C99 AC_ARG_VAR([PYTHON], [path to Python binary]) -AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3]) +AC_CHECK_PROGS(PYTHON, [ \ + python3 \ + python3.8 python3.7 python3.6 python3.5 python3.4 \ + python \ + python2 python2.7]) if test "x$PYTHON" = "x"; then AC_MSG_WARN([Python unavailable; some tests will not be run.]) fi AM_CONDITIONAL(USEPYTHON, [test "x$PYTHON" != "x"]) dnl List all external rust crates we depend on here. Include the version -rust_crates="libc-0.2.22" +rust_crates=" \ + digest-0.7.2 \ + libc-0.2.39 \ +" AC_SUBST(rust_crates) ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [ @@ -399,7 +427,7 @@ AH_BOTTOM([ #endif ]) - +AM_CONDITIONAL(WIN32, test "x$bwin32" = "xtrue") AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue") AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue") @@ -420,6 +448,8 @@ fi AC_C_BIGENDIAN +AC_ARG_VAR([TOR_RUST_TARGET], [Rust target, must be specified when cross-compiling (HOST != BUILD). example: i686-pc-windows-gnu]) + if test "x$enable_rust" = "xyes"; then AC_ARG_VAR([RUSTC], [path to the rustc binary]) AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no]) @@ -434,6 +464,11 @@ if test "x$enable_rust" = "xyes"; then fi AC_DEFINE([HAVE_RUST], 1, [have Rust]) + if test "x$enable_fatal_warnings" = "xyes"; then + RUST_WARN= + else + RUST_WARN=# + fi if test "x$enable_cargo_online_mode" = "xyes"; then CARGO_ONLINE= RUST_DL=# @@ -446,23 +481,23 @@ if test "x$enable_rust" = "xyes"; then AC_MSG_CHECKING([rust crate dependencies]) AC_ARG_VAR([TOR_RUST_DEPENDENCIES], [path to directory with local crate mirror]) if test "x$TOR_RUST_DEPENDENCIES" = "x"; then - TOR_RUST_DEPENDENCIES="$srcdir/src/ext/rust/" - NEED_MOD=1 + TOR_RUST_DEPENDENCIES="${srcdir}/src/ext/rust/crates" fi + dnl Check whether the path exists before we try to cd into it. if test ! -d "$TOR_RUST_DEPENDENCIES"; then AC_MSG_ERROR([Rust dependency directory $TOR_RUST_DEPENDENCIES does not exist. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.]) ERRORED=1 fi + dnl Make the path absolute, since we'll be using it from within a + dnl subdirectory. + TOR_RUST_DEPENDENCIES=$(cd "$TOR_RUST_DEPENDENCIES" ; pwd) + for dep in $rust_crates; do if test ! -d "$TOR_RUST_DEPENDENCIES"/"$dep"; then AC_MSG_ERROR([Failure to find rust dependency $TOR_RUST_DEPENDENCIES/$dep. Specify a dependency directory using the TOR_RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.]) ERRORED=1 fi done - if test "x$NEED_MOD" = "x1"; then - dnl When looking for dependencies from cargo, pick right directory - TOR_RUST_DEPENDENCIES="../../src/ext/rust" - fi if test "x$ERRORED" = "x"; then AC_MSG_RESULT([yes]) fi @@ -471,13 +506,31 @@ if test "x$enable_rust" = "xyes"; then dnl For now both MSVC and MinGW rust libraries will output static libs with dnl the MSVC naming convention. if test "$bwin32" = "true"; then - TOR_RUST_STATIC_NAME=tor_rust.lib + tor_rust_static_name=tor_rust.lib + else + tor_rust_static_name=libtor_rust.a + fi + + AC_CANONICAL_BUILD + + if test -n "$TOR_RUST_TARGET"; then + if test "$host" = "$build"; then + AC_MSG_ERROR([HOST = BUILD is invalid if TOR_RUST_TARGET is specified, see configure --help for more information.]) + fi + RUST_TARGET_PROP="target = '$TOR_RUST_TARGET'" + TOR_RUST_LIB_PATH="src/rust/target/$TOR_RUST_TARGET/release/$tor_rust_static_name" else - TOR_RUST_STATIC_NAME=libtor_rust.a + if test "$host" != "$build"; then + AC_MSG_ERROR([TOR_RUST_TARGET must be specified when cross-compiling with Rust enabled.]) + fi + RUST_TARGET_PROP= + TOR_RUST_LIB_PATH="src/rust/target/release/$tor_rust_static_name" fi - AC_SUBST(TOR_RUST_STATIC_NAME) + AC_SUBST(RUST_TARGET_PROP) + AC_SUBST(TOR_RUST_LIB_PATH) AC_SUBST(CARGO_ONLINE) + AC_SUBST(RUST_WARN) AC_SUBST(RUST_DL) dnl Let's check the rustc version, too @@ -506,68 +559,101 @@ 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") AC_CHECK_FUNCS( - _NSGetEnviron \ + _NSGetEnviron \ RtlSecureZeroMemory \ SecureZeroMemory \ - accept4 \ - backtrace \ - backtrace_symbols_fd \ + accept4 \ + backtrace \ + backtrace_symbols_fd \ eventfd \ explicit_bzero \ timingsafe_memcmp \ - flock \ - ftime \ - get_current_dir_name \ - getaddrinfo \ - getifaddrs \ - getpass \ - getrlimit \ - gettimeofday \ - gmtime_r \ + flock \ + ftime \ + get_current_dir_name \ + getaddrinfo \ + getdelim \ + getifaddrs \ + getline \ + getpass \ + getrlimit \ + gettimeofday \ + gmtime_r \ gnu_get_libc_version \ htonll \ - inet_aton \ - ioctl \ - issetugid \ - llround \ - localtime_r \ - lround \ - mach_approximate_time \ - memmem \ - memset_s \ + inet_aton \ + ioctl \ + issetugid \ + llround \ + localtime_r \ + lround \ + memmem \ + memset_s \ + mmap \ pipe \ pipe2 \ - prctl \ + prctl \ readpassphrase \ - rint \ - sigaction \ - socketpair \ + rint \ + sigaction \ + socketpair \ statvfs \ - strlcat \ - strlcpy \ + strncasecmp \ + strcasecmp \ + strlcat \ + strlcpy \ strnlen \ - strptime \ - strtok_r \ - strtoull \ - sysconf \ + strptime \ + strtok_r \ + strtoull \ + sysconf \ sysctl \ truncate \ - uname \ + uname \ usleep \ - vasprintf \ + vasprintf \ _vscprintf ) -# Apple messed up when they added two functions functions in Sierra: they +# Apple messed up when they added some functions: they # forgot to decorate them with appropriate AVAILABLE_MAC_OS_VERSION -# checks. So we should only probe for those functions if we are sure that we +# checks. + +# We should only probe for these functions if we are sure that we +# are not targeting OS X 10.9 or earlier. +AC_MSG_CHECKING([for a pre-Yosemite OS X build target]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef __APPLE__ +# include <AvailabilityMacros.h> +# ifndef MAC_OS_X_VERSION_10_10 +# define MAC_OS_X_VERSION_10_10 101000 +# endif +# if defined(MAC_OS_X_VERSION_MIN_REQUIRED) +# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 +# error "Running on Mac OS X 10.9 or earlier" +# endif +# endif +#endif +]], [[]])], + [on_macos_pre_10_10=no ; AC_MSG_RESULT([no])], + [on_macos_pre_10_10=yes; AC_MSG_RESULT([yes])]) + +if test "$on_macos_pre_10_10" = "no"; then + AC_CHECK_FUNCS( + mach_approximate_time \ + ) +fi + +# We should only probe for these functions if we are sure that we # are not targeting OSX 10.11 or earlier. AC_MSG_CHECKING([for a pre-Sierra OSX build target]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @@ -670,7 +756,8 @@ TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $STATIC_LIBEVENT_FLAGS $T #include <winsock2.h> #endif struct event_base; -struct event_base *event_base_new(void);], +struct event_base *event_base_new(void); +void event_base_free(struct event_base *);], [ #ifdef _WIN32 {WSADATA d; WSAStartup(0x101,&d); } @@ -714,6 +801,8 @@ fi dnl Now check for particular libevent functions. AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \ evutil_secure_rng_add_bytes \ + evdns_base_get_nameserver_addr \ + ]) LIBS="$save_LIBS" @@ -757,8 +846,21 @@ LIBS="$save_LIBS" AC_SUBST(TOR_LIB_MATH) dnl ------------------------------------------------------ +dnl Hello, NSS. You're new around here. +if test "x$enable_nss" = "xyes"; then + PKG_CHECK_MODULES(NSS, + [nss], + [have_nss=yes], + [have_nss=no; AC_MSG_ERROR([You asked for NSS but I can't find it.])]) + AC_SUBST(NSS_CFLAGS) + AC_SUBST(NSS_LIBS) +fi + +dnl ------------------------------------------------------ dnl Where do you live, openssl? And how do we call you? +if test "x$enable_nss" != "xyes"; then + tor_openssl_pkg_redhat="openssl" tor_openssl_pkg_debian="libssl-dev" tor_openssl_devpkg_redhat="openssl-devel" @@ -775,9 +877,18 @@ AC_ARG_WITH(ssl-dir, AC_MSG_NOTICE([Now, we'll look for OpenSSL >= 1.0.1]) TOR_SEARCH_LIBRARY(openssl, $tryssldir, [-lssl -lcrypto $TOR_LIB_GDI $TOR_LIB_WS32], - [#include <openssl/ssl.h>], - [struct ssl_method_st; const struct ssl_method_st *TLSv1_1_method(void);], - [TLSv1_1_method();], [], + [#include <openssl/ssl.h> + char *getenv(const char *);], + [struct ssl_cipher_st; + unsigned SSL_CIPHER_get_id(const struct ssl_cipher_st *); + char *getenv(const char *);], + dnl This funny-looking test program calls getenv, so that the compiler + dnl will neither make code that call SSL_CIPHER_get_id(NULL) [producing + dnl a crash], nor optimize out the call to SSL_CIPHER_get_id(). + dnl We look for SSL_cipher_get_id() because it is present in + dnl OpenSSL >=1.0.1, because it is not deprecated, and because Tor + dnl depends on it. + [if (getenv("THIS_SHOULDNT_BE_SET_X201803")) SSL_CIPHER_get_id((void *)0);], [], [/usr/local/opt/openssl /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /opt/openssl]) dnl XXXX check for OPENSSL_VERSION_NUMBER == SSLeay() @@ -828,11 +939,14 @@ AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , , ]) AC_CHECK_FUNCS([ \ + ERR_load_KDF_strings \ SSL_SESSION_get_master_key \ SSL_get_server_random \ SSL_get_client_ciphers \ SSL_get_client_random \ + SSL_CTX_set1_groups_list \ SSL_CIPHER_find \ + SSL_CTX_set_security_level \ TLS_method ]) @@ -848,6 +962,11 @@ AC_CHECK_SIZEOF(SHA_CTX, , [AC_INCLUDES_DEFAULT() #include <openssl/sha.h> ]) +fi # enable_nss + +dnl ====================================================================== +dnl Can we use KIST? + dnl Define the set of checks for KIST scheduler support. AC_DEFUN([CHECK_KIST_SUPPORT],[ dnl KIST needs struct tcp_info and for certain members to exist. @@ -1013,6 +1132,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ #error #endif])], have_clang=yes, have_clang=no) +if test "x$enable_pic" = "xyes"; then + TOR_CHECK_CFLAGS(-fPIC) +fi + if test "x$enable_gcc_hardening" != "xno"; then CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" if test "x$have_clang" = "xyes"; then @@ -1032,7 +1155,13 @@ m4_ifdef([AS_VAR_IF],[ TOR_CHECK_CFLAGS(-Wstack-protector) TOR_CHECK_CFLAGS(--param ssp-buffer-size=1) if test "$bwin32" = "false" && test "$enable_libfuzzer" != "yes" && test "$enable_oss_fuzz" != "yes"; then - TOR_CHECK_CFLAGS(-fPIE) + if test "$enable_pic" != "yes"; then + # If we have already enabled -fPIC, then we don't also need to + # compile with -fPIE... + TOR_CHECK_CFLAGS(-fPIE) + fi + # ... but we want to link our executables with -pie in any case, since + # they're executables, not a library. TOR_CHECK_LDFLAGS(-pie, "$all_ldflags_for_check", "$all_libs_for_check") fi TOR_TRY_COMPILE_WITH_CFLAGS(-fwrapv, also_link, CFLAGS_FWRAPV="-fwrapv", true) @@ -1061,6 +1190,33 @@ if test "$fragile_hardening" = "yes"; then TOR_CHECK_CFLAGS([-fno-omit-frame-pointer]) fi +dnl Find the correct libraries to add in order to use the sanitizers. +dnl +dnl When building Rust, Cargo will run the linker with the -nodefaultlibs +dnl option, which will prevent the compiler from linking the sanitizer +dnl libraries it needs. We need to specify them manually. +dnl +dnl What's more, we need to specify them in a linker script rather than +dnl from build.rs: these options aren't allowed in the cargo:rustc-flags +dnl variable. +RUST_LINKER_OPTIONS="" +if test "x$have_clang" = "xyes"; then + if test "x$CFLAGS_ASAN" != "x"; then + RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries" + fi + if test "x$CFLAGS_UBSAN" != "x"; then + RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries" + fi +else + if test "x$CFLAGS_ASAN" != "x"; then + RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries" + fi + if test "x$CFLAGS_UBSAN" != "x"; then + RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries" + fi +fi +AC_SUBST(RUST_LINKER_OPTIONS) + CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN" CFLAGS_CONSTTIME="$CFLAGS_FWRAPV" @@ -1265,60 +1421,58 @@ AC_SUBST(CURVE25519_LIBS) dnl Make sure to enable support for large off_t if available. AC_SYS_LARGEFILE -AC_CHECK_HEADERS([assert.h \ - errno.h \ - fcntl.h \ - signal.h \ - string.h \ - sys/capability.h \ - sys/fcntl.h \ - sys/stat.h \ - sys/time.h \ - sys/types.h \ - time.h \ - unistd.h \ - arpa/inet.h \ - crt_externs.h \ - execinfo.h \ - gnu/libc-version.h \ - grp.h \ - ifaddrs.h \ - inttypes.h \ - limits.h \ - linux/types.h \ - machine/limits.h \ - malloc.h \ - malloc/malloc.h \ - malloc_np.h \ - netdb.h \ - netinet/in.h \ - netinet/in6.h \ - pwd.h \ - readpassphrase.h \ - stdint.h \ - stdatomic.h \ - sys/eventfd.h \ - sys/file.h \ - sys/ioctl.h \ - sys/limits.h \ - sys/mman.h \ - sys/param.h \ - sys/prctl.h \ +AC_CHECK_HEADERS([errno.h \ + fcntl.h \ + signal.h \ + string.h \ + sys/capability.h \ + sys/fcntl.h \ + sys/stat.h \ + sys/time.h \ + sys/types.h \ + time.h \ + unistd.h \ + arpa/inet.h \ + crt_externs.h \ + execinfo.h \ + gnu/libc-version.h \ + grp.h \ + ifaddrs.h \ + inttypes.h \ + limits.h \ + linux/types.h \ + machine/limits.h \ + malloc.h \ + malloc/malloc.h \ + malloc_np.h \ + netdb.h \ + netinet/in.h \ + netinet/in6.h \ + pwd.h \ + readpassphrase.h \ + stdatomic.h \ + sys/eventfd.h \ + sys/file.h \ + sys/ioctl.h \ + sys/limits.h \ + sys/mman.h \ + sys/param.h \ + sys/prctl.h \ sys/random.h \ - sys/resource.h \ - sys/select.h \ - sys/socket.h \ - sys/statvfs.h \ - sys/syscall.h \ - sys/sysctl.h \ - sys/syslimits.h \ - sys/time.h \ - sys/types.h \ - sys/un.h \ - sys/utime.h \ - sys/wait.h \ - syslog.h \ - utime.h]) + sys/resource.h \ + sys/select.h \ + sys/socket.h \ + sys/statvfs.h \ + sys/syscall.h \ + sys/sysctl.h \ + sys/syslimits.h \ + sys/time.h \ + sys/types.h \ + sys/un.h \ + sys/utime.h \ + sys/wait.h \ + syslog.h \ + utime.h]) AC_CHECK_HEADERS(sys/param.h) @@ -1419,22 +1573,6 @@ AC_CHECK_MEMBERS([struct timeval.tv_sec], , , #include <sys/time.h> #endif]) -dnl In case we aren't given a working stdint.h, we'll need to grow our own. -dnl Watch out. - -AC_CHECK_SIZEOF(int8_t) -AC_CHECK_SIZEOF(int16_t) -AC_CHECK_SIZEOF(int32_t) -AC_CHECK_SIZEOF(int64_t) -AC_CHECK_SIZEOF(uint8_t) -AC_CHECK_SIZEOF(uint16_t) -AC_CHECK_SIZEOF(uint32_t) -AC_CHECK_SIZEOF(uint64_t) -AC_CHECK_SIZEOF(intptr_t) -AC_CHECK_SIZEOF(uintptr_t) - -dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t]) - AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) @@ -1550,6 +1688,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( @@ -1679,43 +1837,79 @@ if test "$tor_cv_uint8_uchar" = "no"; then AC_MSG_ERROR([We assume that uint8_t is the same type as unsigned char, but your compiler disagrees.]) fi -# Whether we should use the dmalloc memory allocation debugging library. -AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library)) -AC_ARG_WITH(dmalloc, -AS_HELP_STRING(--with-dmalloc, [use debug memory allocation library]), -[if [[ "$withval" = "yes" ]]; then - dmalloc=1 - AC_MSG_RESULT(yes) -else - dmalloc=1 - AC_MSG_RESULT(no) -fi], [ dmalloc=0; AC_MSG_RESULT(no) ] -) - -if [[ $dmalloc -eq 1 ]]; then - AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?)) - AC_SEARCH_LIBS(dmalloc_malloc, [dmallocth dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.)) - AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library]) - AC_CHECK_FUNCS(dmalloc_strdup dmalloc_strndup) -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 -if test "$using_custom_malloc" = "no"; then - AC_CHECK_FUNCS(mallinfo) + +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" = "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() @@ -1728,14 +1922,6 @@ AC_CHECK_DECLS([mlockall], , , [ #include <sys/mman.h> #endif]) -# Some MinGW environments don't have getpagesize in unistd.h. We don't use -# AC_CHECK_FUNCS(getpagesize), because other environments rename getpagesize -# using macros -AC_CHECK_DECLS([getpagesize], , , [ -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif]) - # Allow user to specify an alternate syslog facility AC_ARG_WITH(syslog-facility, AS_HELP_STRING(--with-syslog-facility=LOG, [syslog facility to use (default=LOG_DAEMON)]), @@ -1873,6 +2059,12 @@ AC_SUBST(BUILDDIR) AH_TEMPLATE([BUILDDIR],[tor's build directory]) AC_DEFINE_UNQUOTED(BUILDDIR,"$BUILDDIR") +if test "x$SRCDIR" = "x"; then + SRCDIR=$(cd "$srcdir"; pwd) +fi +AH_TEMPLATE([SRCDIR],[tor's sourcedir directory]) +AC_DEFINE_UNQUOTED(SRCDIR,"$SRCDIR") + if test "x$CONFDIR" = "x"; then CONFDIR=`eval echo $sysconfdir/tor` fi @@ -2191,6 +2383,9 @@ dnl -Wthread-safety-precise if test "$tor_cv_cflags__Woverlength_strings" = "yes"; then AC_DEFINE([HAVE_CFLAG_WOVERLENGTH_STRINGS], 1, [True if we have -Woverlength-strings]) fi + if test "$tor_cv_cflags__warn_unused_const_variable_2" = "yes"; then + AC_DEFINE([HAVE_CFLAG_WUNUSED_CONST_VARIABLE], 1, [True if we have -Wunused-const-variable]) + fi if test "x$enable_fatal_warnings" = "xyes"; then # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the @@ -2210,18 +2405,19 @@ fi CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib" AC_CONFIG_FILES([ - Doxyfile - Makefile - contrib/dist/suse/tor.sh - contrib/operator-tools/tor.logrotate - contrib/dist/tor.sh - contrib/dist/torctl - contrib/dist/tor.service - src/config/torrc.sample - src/config/torrc.minimal - src/rust/.cargo/config - scripts/maint/checkOptionDocs.pl - scripts/maint/updateVersions.pl + Doxyfile + Makefile + config.rust + contrib/dist/suse/tor.sh + contrib/operator-tools/tor.logrotate + contrib/dist/tor.sh + contrib/dist/torctl + contrib/dist/tor.service + src/config/torrc.sample + src/config/torrc.minimal + src/rust/.cargo/config + scripts/maint/checkOptionDocs.pl + scripts/maint/updateVersions.pl ]) if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then |