From 62ed33cb855dc2c86d1fe4342b5cc6217e03910f Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Wed, 17 Oct 2018 21:21:00 -0700 Subject: [PATCH] Show if ASAN build in --show-config (#2650) This commit extends `--show-config` to show whether the current build is an ASAN build or not. This is done by moving a detection that was previously done for the unit tests into base/configuration_private.h. In addition to being convenient, this allows us to easily exclude regression tests from ASAN builds. --- src/base/configuration.cpp | 2 ++ src/base/configuration.h | 2 ++ src/base/configuration_private.h | 16 ++++++++++++++++ src/options/options_handler.cpp | 1 + test/unit/memory.h | 19 +++---------------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/base/configuration.cpp b/src/base/configuration.cpp index 32ab85f96..a00cee856 100644 --- a/src/base/configuration.cpp +++ b/src/base/configuration.cpp @@ -82,6 +82,8 @@ bool Configuration::isProfilingBuild() { return IS_PROFILING_BUILD; } +bool Configuration::isAsanBuild() { return IS_ASAN_BUILD; } + bool Configuration::isCompetitionBuild() { return IS_COMPETITION_BUILD; } diff --git a/src/base/configuration.h b/src/base/configuration.h index a00a6c1d9..b6e2a1963 100644 --- a/src/base/configuration.h +++ b/src/base/configuration.h @@ -63,6 +63,8 @@ public: static bool isProfilingBuild(); + static bool isAsanBuild(); + static bool isCompetitionBuild(); static std::string getPackageName(); diff --git a/src/base/configuration_private.h b/src/base/configuration_private.h index e2974260c..5164d46bc 100644 --- a/src/base/configuration_private.h +++ b/src/base/configuration_private.h @@ -150,6 +150,22 @@ namespace CVC4 { # define IS_GPL_BUILD false #endif /* CVC4_GPL_DEPS */ +#define IS_ASAN_BUILD false + +// GCC test +#if defined(__SANITIZE_ADDRESS__) +# undef IS_ASAN_BUILD +# define IS_ASAN_BUILD true +#endif /* defined(__SANITIZE_ADDRESS__) */ + +// Clang test +#if defined(__has_feature) +# if __has_feature(address_sanitizer) +# undef IS_ASAN_BUILD +# define IS_ASAN_BUILD true +# endif /* __has_feature(address_sanitizer) */ +#endif /* defined(__has_feature) */ + }/* CVC4 namespace */ #endif /* __CVC4__CONFIGURATION_PRIVATE_H */ diff --git a/src/options/options_handler.cpp b/src/options/options_handler.cpp index 9cf5180e8..be2d7883d 100644 --- a/src/options/options_handler.cpp +++ b/src/options/options_handler.cpp @@ -1685,6 +1685,7 @@ void OptionsHandler::showConfiguration(std::string option) { print_config_cond("proof", Configuration::isProofBuild()); print_config_cond("coverage", Configuration::isCoverageBuild()); print_config_cond("profiling", Configuration::isProfilingBuild()); + print_config_cond("asan", Configuration::isAsanBuild()); print_config_cond("competition", Configuration::isCompetitionBuild()); std::cout << std::endl; diff --git a/test/unit/memory.h b/test/unit/memory.h index a4d650b3b..8f4eca371 100644 --- a/test/unit/memory.h +++ b/test/unit/memory.h @@ -36,6 +36,7 @@ #include #include +#include "base/configuration_private.h" #include "base/cvc4_assert.h" // Conditionally define CVC4_MEMORY_LIMITING_DISABLED. @@ -43,29 +44,15 @@ # define CVC4_MEMORY_LIMITING_DISABLED 1 # define CVC4_MEMORY_LIMITING_DISABLED_REASON "setrlimit() is broken on Mac." #else /* __APPLE__ */ -// Clang test -# if defined(__has_feature) -# if __has_feature(address_sanitizer) -# define _IS_ASAN_BUILD -# endif /* __has_feature(address_sanitizer) */ -# endif /* defined(__has_feature) */ - -// GCC test -# if defined(__SANITIZE_ADDRESS__) -# define _IS_ASAN_BUILD -# endif /* defined(__SANITIZE_ADDRESS__) */ // Tests cannot expect bad_alloc to be thrown due to limit memory using // setrlimit when ASAN is enable. ASAN instead aborts on mmap failures. -# if defined(_IS_ASAN_BUILD) +# if IS_ASAN_BUILD # define CVC4_MEMORY_LIMITING_DISABLED 1 # define CVC4_MEMORY_LIMITING_DISABLED_REASON "ASAN's mmap failures abort." -# undef _IS_ASAN_BUILD -# endif /* defined(_IS_ASAN_BUILD) */ +# endif #endif - - namespace CVC4 { namespace test { -- 2.30.2