Testing: Add --enable-asan configure option to compile with AddressSanitizer (#6404)

This commit is contained in:
Geza Lore
2025-09-09 08:55:49 +01:00
committed by GitHub
parent c6ffd22c45
commit 056c3ee331
9 changed files with 79 additions and 5 deletions
+15
View File
@@ -29,6 +29,21 @@
VL_DEFINE_DEBUG_FUNCTIONS;
//######################################################################
// AddressSanitizer default options
#ifdef VL_ASAN
extern "C" const char* __asan_default_options() {
// See https://github.com/google/sanitizers/wiki/SanitizerCommonFlags
// or 'env ASAN_OPTIONS=help=1 ./verilator_bin'
return ""
#ifndef VL_LEAK_CHECKS
":detect_leaks=0"
#endif
;
}
#endif
//######################################################################
// V3Global
+10
View File
@@ -817,6 +817,8 @@ string V3Options::getSupported(const string& var) {
// cppcheck-suppress knownConditionTrueFalse
} else if (var == "SYSTEMC" && systemCFound()) {
return "1";
} else if (var == "ASAN" && builtWithAsan()) {
return "1";
} else {
return "";
}
@@ -843,6 +845,14 @@ bool V3Options::coroutineSupport() {
#endif
}
bool V3Options::builtWithAsan() {
#ifdef HAVE_ASAN
return true;
#else
return false;
#endif
}
//######################################################################
// V3 Options notification methods
+1
View File
@@ -821,6 +821,7 @@ public:
static bool systemCSystemWide();
static bool systemCFound(); // SystemC installed, or environment points to it
static bool coroutineSupport(); // Compiler supports coroutines
static bool builtWithAsan(); // Compiler built with AddressSanitizer
// METHODS (file utilities using these options)
string fileExists(const string& filename);
+3
View File
@@ -44,6 +44,9 @@ PACKAGE_VERSION_STRING_CHAR
// Define if compiled with tcmalloc
#undef HAVE_TCMALLOC
// Define if compiled with AddressSanitizer
#undef HAVE_ASAN
//**********************************************************************
//**** This file sometimes gets truncated, so check in consumers
#define HAVE_CONFIG_PACKAGE