summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac178
1 files changed, 110 insertions, 68 deletions
diff --git a/configure.ac b/configure.ac
index d658ef6e60..9bd8eb21bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,9 +143,11 @@ case "$host" in
esac
AC_ARG_ENABLE(gcc-warnings,
- AS_HELP_STRING(--enable-gcc-warnings, [enable verbose warnings]))
+ AS_HELP_STRING(--enable-gcc-warnings, [deprecated alias for enable-fatal-warnings]))
+AC_ARG_ENABLE(fatal-warnings,
+ AS_HELP_STRING(--enable-fatal-warnings, [tell the compiler to treat all warnings as errors.]))
AC_ARG_ENABLE(gcc-warnings-advisory,
- AS_HELP_STRING(--enable-gcc-warnings-advisory, [enable verbose warnings, excluding -Werror]))
+ AS_HELP_STRING(--disable-gcc-warnings-advisory, [disable the regular verbose warnings]))
dnl Others suggest '/gs /safeseh /nxcompat /dynamicbase' for non-gcc on Windows
AC_ARG_ENABLE(gcc-hardening,
@@ -432,6 +434,7 @@ AC_CHECK_FUNCS(
strtoull \
sysconf \
sysctl \
+ truncate \
uname \
usleep \
vasprintf \
@@ -815,6 +818,47 @@ fi
CFLAGS_BUGTRAP="$CFLAGS_FTRAPV $CFLAGS_ASAN $CFLAGS_UBSAN"
CFLAGS_CONSTTIME="$CFLAGS_FWRAPV"
+mulodi_fixes_ftrapv=no
+if test "$have_clang" = "yes"; then
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $CFLAGS_FTRAPV"
+ AC_MSG_CHECKING([whether clang -ftrapv can link a 64-bit int multiply])
+ AC_LINK_IFELSE([
+ AC_LANG_SOURCE([[
+ #include <stdint.h>
+ #include <stdlib.h>
+ int main(int argc, char **argv)
+ {
+ int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
+ * (int64_t)atoi(argv[3]);
+ return x == 9;
+ } ]])],
+ [ftrapv_can_link=yes; AC_MSG_RESULT([yes])],
+ [ftrapv_can_link=no; AC_MSG_RESULT([no])])
+ if test "$ftrapv_can_link" = "no"; then
+ AC_MSG_CHECKING([whether defining __mulodi4 fixes that])
+ AC_LINK_IFELSE([
+ AC_LANG_SOURCE([[
+ #include <stdint.h>
+ #include <stdlib.h>
+ int64_t __mulodi4(int64_t a, int64_t b, int *overflow) {
+ *overflow=0;
+ return a;
+ }
+ int main(int argc, char **argv)
+ {
+ int64_t x = ((int64_t)atoi(argv[1])) * (int64_t)atoi(argv[2])
+ * (int64_t)atoi(argv[3]);
+ return x == 9;
+ } ]])],
+ [mulodi_fixes_ftrapv=yes; AC_MSG_RESULT([yes])],
+ [mulodi_fixes_ftrapv=no; AC_MSG_RESULT([no])])
+ fi
+ CFLAGS="$saved_CFLAGS"
+fi
+
+AM_CONDITIONAL(ADD_MULODI4, test "$mulodi_fixes_ftrapv" = "yes")
+
dnl These cflags add bunches of branches, and we haven't been able to
dnl persuade ourselves that they're suitable for code that needs to be
dnl constant time.
@@ -865,6 +909,7 @@ dnl Check for libscrypt
if test "x$enable_libscrypt" != "xno"; then
AC_CHECK_HEADERS([libscrypt.h])
AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
+ AC_CHECK_FUNCS([libscrypt_scrypt])
fi
dnl ============================================================
@@ -974,64 +1019,57 @@ 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
- , , AC_MSG_WARN(Some headers were not found, compilation may fail. If compilation succeeds, please send your orconfig.h to the developers so we can fix this warning.))
-
-dnl These headers are not essential
-
-AC_CHECK_HEADERS(
- arpa/inet.h \
- crt_externs.h \
- execinfo.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 \
- sys/eventfd.h \
- sys/file.h \
- sys/ioctl.h \
- sys/limits.h \
- sys/mman.h \
- sys/param.h \
- sys/prctl.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([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 \
+ 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 \
+ sys/eventfd.h \
+ sys/file.h \
+ sys/ioctl.h \
+ sys/limits.h \
+ sys/mman.h \
+ sys/param.h \
+ sys/prctl.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)
@@ -1608,6 +1646,12 @@ else
enable_gcc_warnings_advisory=no
fi
+# Warnings implies advisory-warnings and -Werror.
+if test "$enable_gcc_warnings" = "yes"; then
+ enable_gcc_warnings_advisory=yes
+ enable_fatal_warnings=yes
+fi
+
# OS X Lion started deprecating the system openssl. Let's just disable
# all deprecation warnings on OS X. Also, to potentially make the binary
# a little smaller, let's enable dead_strip.
@@ -1620,8 +1664,7 @@ esac
# Add some more warnings which we use in development but not in the
# released versions. (Some relevant gcc versions can't handle these.)
-if test "x$enable_gcc_warnings" = "xyes" ||
- test "x$enable_gcc_warnings_advisory" = "xyes"; then
+if test "x$enable_gcc_warnings_advisory" != "xno"; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
#if !defined(__GNUC__) || (__GNUC__ < 4)
@@ -1643,7 +1686,6 @@ if test "x$enable_gcc_warnings" = "xyes" ||
#error
#endif])], have_gcc46=yes, have_gcc46=no)
-
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wshorten-64-to-32"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], have_shorten64_flag=yes,
@@ -1665,10 +1707,6 @@ if test "x$enable_gcc_warnings" = "xyes" ||
CFLAGS="$CFLAGS -Wwrite-strings -Wmissing-declarations -Wredundant-decls"
CFLAGS="$CFLAGS -Wnested-externs -Wbad-function-cast -Wswitch-enum"
- if test "x$enable_gcc_warnings" = "xyes"; then
- CFLAGS="$CFLAGS -Werror"
- fi
-
# Disabled, so we can use mallinfo(): -Waggregate-return
if test "x$have_gcc4" = "xyes"; then
@@ -1705,7 +1743,11 @@ if test "x$enable_gcc_warnings" = "xyes" ||
CFLAGS="$CFLAGS -Wshorten-64-to-32"
fi
-
+ if test "x$enable_fatal_warnings" = "xyes"; then
+ # I'd like to use TOR_CHECK_CFLAGS here, but I can't, since the
+ # default autoconf programs are full of errors.
+ CFLAGS="$CFLAGS -Werror"
+ fi
##This will break the world on some 64-bit architectures
# CFLAGS="$CFLAGS -Winline"