mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Add --with-sanitizers option to configure
This enables the use of different compiler sanitizers, coresponding to the -fsanitize option in GCC and Clang.
This commit is contained in:
28
configure.ac
28
configure.ac
@@ -219,6 +219,12 @@ AC_ARG_ENABLE([debug],
|
||||
[enable_debug=$enableval],
|
||||
[enable_debug=no])
|
||||
|
||||
# Enable different -fsanitize options
|
||||
AC_ARG_WITH([sanitizers],
|
||||
[AS_HELP_STRING([--with-sanitizers],
|
||||
[comma separated list of extra sanitizers to build with (default is none enabled)])],
|
||||
[use_sanitizers=$withval])
|
||||
|
||||
# Enable gprof profiling
|
||||
AC_ARG_ENABLE([gprof],
|
||||
[AS_HELP_STRING([--enable-gprof],
|
||||
@@ -247,6 +253,26 @@ if test "x$enable_debug" = xyes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$use_sanitizers != x; then
|
||||
# First check if the compiler accepts flags. If an incompatible pair like
|
||||
# -fsanitize=address,thread is used here, this check will fail. This will also
|
||||
# fail if a bad argument is passed, e.g. -fsanitize=undfeined
|
||||
AX_CHECK_COMPILE_FLAG(
|
||||
[[-fsanitize=$use_sanitizers]],
|
||||
[[SANITIZER_CXXFLAGS=-fsanitize=$use_sanitizers]],
|
||||
[AC_MSG_ERROR([compiler did not accept requested flags])])
|
||||
|
||||
# Some compilers (e.g. GCC) require additional libraries like libasan,
|
||||
# libtsan, libubsan, etc. Make sure linking still works with the sanitize
|
||||
# flag. This is a separate check so we can give a better error message when
|
||||
# the sanitize flags are supported by the compiler but the actual sanitizer
|
||||
# libs are missing.
|
||||
AX_CHECK_LINK_FLAG(
|
||||
[[-fsanitize=$use_sanitizers]],
|
||||
[[SANITIZER_LDFLAGS=-fsanitize=$use_sanitizers]],
|
||||
[AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])])
|
||||
fi
|
||||
|
||||
ERROR_CXXFLAGS=
|
||||
if test "x$enable_werror" = "xyes"; then
|
||||
if test "x$CXXFLAG_WERROR" = "x"; then
|
||||
@@ -1258,6 +1284,8 @@ AC_SUBST(HARDENED_CPPFLAGS)
|
||||
AC_SUBST(HARDENED_LDFLAGS)
|
||||
AC_SUBST(PIC_FLAGS)
|
||||
AC_SUBST(PIE_FLAGS)
|
||||
AC_SUBST(SANITIZER_CXXFLAGS)
|
||||
AC_SUBST(SANITIZER_LDFLAGS)
|
||||
AC_SUBST(SSE42_CXXFLAGS)
|
||||
AC_SUBST(LIBTOOL_APP_LDFLAGS)
|
||||
AC_SUBST(USE_UPNP)
|
||||
|
||||
Reference in New Issue
Block a user