Show if ASAN build in --show-config (#2650)
authorAndres Noetzli <andres.noetzli@gmail.com>
Thu, 18 Oct 2018 04:21:00 +0000 (21:21 -0700)
committerGitHub <noreply@github.com>
Thu, 18 Oct 2018 04:21:00 +0000 (21:21 -0700)
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
src/base/configuration.h
src/base/configuration_private.h
src/options/options_handler.cpp
test/unit/memory.h

index 32ab85f96515d7478bec8fbfd650cfac685ebed2..a00cee856c557eb09704ec59f558b004dba65f3d 100644 (file)
@@ -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;
 }
index a00a6c1d97c5480422931549653f57c68a244956..b6e2a19635e2a2515bca66321f2f19dd42bd135e 100644 (file)
@@ -63,6 +63,8 @@ public:
 
   static bool isProfilingBuild();
 
+  static bool isAsanBuild();
+
   static bool isCompetitionBuild();
 
   static std::string getPackageName();
index e2974260cbad05fcd1b0c4692f5df15274aea9bb..5164d46bcafd04b7fa64ddf1e6c6f4bddd145731 100644 (file)
@@ -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 */
index 9cf5180e83e607ef252127c108f17e32299474f4..be2d7883d9149f76fa26595c86856c2fdda33db0 100644 (file)
@@ -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;
index a4d650b3b610d76c519dab595443c076434e5ec0..8f4eca37195e929d420844601f2e86d2ffe8871d 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/resource.h>
 #include <sys/time.h>
 
+#include "base/configuration_private.h"
 #include "base/cvc4_assert.h"
 
 // Conditionally define CVC4_MEMORY_LIMITING_DISABLED.
 #  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 {