Add configure flags for enabling ASan/UBSan and TSan
Co-authored-by: Robert Seacord <rcseacord@gmail.com>
This commit is contained in:
parent
326fc65e66
commit
c4379e3a22
39
configure.ac
39
configure.ac
|
@ -113,6 +113,18 @@ AC_ARG_ENABLE(tests,
|
||||||
[use_tests=$enableval],
|
[use_tests=$enableval],
|
||||||
[use_tests=yes])
|
[use_tests=yes])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([asan],
|
||||||
|
[AS_HELP_STRING([--enable-asan],
|
||||||
|
[instrument the executables with asan (default is no)])],
|
||||||
|
[use_asan=$enableval],
|
||||||
|
[use_asan=no])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([tsan],
|
||||||
|
[AS_HELP_STRING([--enable-tsan],
|
||||||
|
[instrument the executables with tsan (default is no)])],
|
||||||
|
[use_tsan=$enableval],
|
||||||
|
[use_tsan=no])
|
||||||
|
|
||||||
AC_ARG_ENABLE([hardening],
|
AC_ARG_ENABLE([hardening],
|
||||||
[AS_HELP_STRING([--enable-hardening],
|
[AS_HELP_STRING([--enable-hardening],
|
||||||
[attempt to harden the resulting executables (default is yes)])],
|
[attempt to harden the resulting executables (default is yes)])],
|
||||||
|
@ -441,6 +453,29 @@ if test x$TARGET_OS != xwindows; then
|
||||||
AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
|
AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#asan and tsan cannot be used together
|
||||||
|
if test x$use_asan$use_tsan == xyesyes; then
|
||||||
|
AC_MSG_ERROR(asan and tsan cannot be simultaneously enabled)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# using asan flag to enable address sanitizer and undefined behavior sanitizer
|
||||||
|
if test x$use_asan == xyes; then
|
||||||
|
AX_CHECK_LINK_FLAG([-static-libstdc++],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libstdc++"],[AC_MSG_ERROR(Cannot statically link -static-libstdc++)])
|
||||||
|
AX_CHECK_LINK_FLAG([-static-libasan],[SAN_LDFLAGS="$SAN_LDFLAGS -static-libasan"],[AC_MSG_ERROR(Cannot statically link -static-libasan)])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-fsanitize=address],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=address"],[AC_MSG_ERROR(Cannot enable -fsanitize=address)])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=undefined"],[AC_MSG_ERROR(Cannot enable -fsanitize=undefined)])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# using tsan flag to enable address thread sanitizer
|
||||||
|
# TSAN is supported on Linux x84_64 and tested on Ubuntu 12.04
|
||||||
|
# Non-position-independent executables are not supported. Use with -fPIE and -pie flags
|
||||||
|
# libc/libstdc++ static linking is not supported
|
||||||
|
if test x$use_tsan == xyes; then
|
||||||
|
AX_CHECK_COMPILE_FLAG([-fsanitize=thread],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fsanitize=thread"],[AC_MSG_ERROR(Cannot enable -fsanitize=thread)])
|
||||||
|
AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],[SAN_CXXFLAGS="$SAN_CXXFLAGS -fno-omit-frame-pointer"],[AC_MSG_ERROR(Cannot enable -fno-omit-frame-pointer)])
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$use_hardening != xno; then
|
if test x$use_hardening != xno; then
|
||||||
AX_CHECK_COMPILE_FLAG([-Wformat],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat"],[AC_MSG_ERROR(Cannot enable -Wformat)])
|
AX_CHECK_COMPILE_FLAG([-Wformat],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat"],[AC_MSG_ERROR(Cannot enable -Wformat)])
|
||||||
AX_CHECK_COMPILE_FLAG([-Wformat-security],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat-security"],[AC_MSG_ERROR(Cannot enable -Wformat-security)],[-Wformat])
|
AX_CHECK_COMPILE_FLAG([-Wformat-security],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wformat-security"],[AC_MSG_ERROR(Cannot enable -Wformat-security)],[-Wformat])
|
||||||
|
@ -824,6 +859,8 @@ AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
|
||||||
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
|
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
|
||||||
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
|
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
|
||||||
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
|
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
|
||||||
|
AM_CONDITIONAL([ASAN],[test x$use_asan = xyes])
|
||||||
|
AM_CONDITIONAL([TSAN],[test x$use_tsan = xyes])
|
||||||
|
|
||||||
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
|
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
|
||||||
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
|
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
|
||||||
|
@ -843,6 +880,8 @@ AC_SUBST(BITCOIN_TX_NAME)
|
||||||
|
|
||||||
AC_SUBST(RELDFLAGS)
|
AC_SUBST(RELDFLAGS)
|
||||||
AC_SUBST(ERROR_CXXFLAGS)
|
AC_SUBST(ERROR_CXXFLAGS)
|
||||||
|
AC_SUBST(SAN_CXXFLAGS)
|
||||||
|
AC_SUBST(SAN_LDFLAGS)
|
||||||
AC_SUBST(HARDENED_CXXFLAGS)
|
AC_SUBST(HARDENED_CXXFLAGS)
|
||||||
AC_SUBST(HARDENED_CPPFLAGS)
|
AC_SUBST(HARDENED_CPPFLAGS)
|
||||||
AC_SUBST(HARDENED_LDFLAGS)
|
AC_SUBST(HARDENED_LDFLAGS)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DIST_SUBDIRS = secp256k1 univalue
|
DIST_SUBDIRS = secp256k1 univalue
|
||||||
|
|
||||||
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
|
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(SAN_LDFLAGS) $(HARDENED_LDFLAGS)
|
||||||
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
|
AM_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
|
||||||
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
|
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
|
||||||
|
|
||||||
if EMBEDDED_LEVELDB
|
if EMBEDDED_LEVELDB
|
||||||
|
@ -525,11 +525,11 @@ libzcash_a_SOURCES = \
|
||||||
zcash/circuit/prfs.tcc \
|
zcash/circuit/prfs.tcc \
|
||||||
zcash/circuit/utils.tcc
|
zcash/circuit/utils.tcc
|
||||||
|
|
||||||
libzcash_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES)
|
libzcash_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) $(HARDENED_CXXFLAGS) $(HARDENED_LDFLAGS) -pipe $(SAN_LDFLAGS) -O1 -g -Wstack-protector $(SAN_CXXFLAGS) -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES)
|
||||||
|
|
||||||
libzcash_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing
|
libzcash_a_CXXFLAGS = $(SAN_CXXFLAGS) $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing
|
||||||
|
|
||||||
libzcash_a_LDFLAGS = $(HARDENED_LDFLAGS)
|
libzcash_a_LDFLAGS = $(SAN_LDFLAGS) $(HARDENED_LDFLAGS)
|
||||||
|
|
||||||
libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT
|
libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue