From 4ab0690428ea03953b54edbe93d2eb8088b2c953 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Wed, 17 Sep 2025 01:18:58 +0200 Subject: [PATCH] CI: Add -DVL_LEAK_CHECKS in asan builds (#6444) --- ci/ci-script.bash | 1 + include/verilatedos.h | 5 +++++ src/V3Broken.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/ci-script.bash b/ci/ci-script.bash index 2aed4ee9c..b78d82e8b 100755 --- a/ci/ci-script.bash +++ b/ci/ci-script.bash @@ -44,6 +44,7 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then CONFIGURE_ARGS="--enable-longtests --enable-ccwarn" if [ "$CI_ASAN" = 1 ]; then CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-asan" + CXX="$CXX -DVL_LEAK_CHECKS" fi ./configure $CONFIGURE_ARGS --prefix="$INSTALL_DIR" ccache -z diff --git a/include/verilatedos.h b/include/verilatedos.h index a4c03c46d..0a1df2035 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -120,6 +120,11 @@ // Allowed on: function, method. (-fthread-safety) #define VL_ASSERT_CAPABILITY(x) \ VL_CLANG_ATTR(assert_capability(x)) +// Disable thread safety analysis for the annotted function +// Use this only when absolutely sure code is correct, but too +// complicated for the compiler to prove. +#define VL_NO_THREAD_SAFETY_ANALYSIS \ + VL_CLANG_ATTR(no_thread_safety_analysis) // Require mutex locks only in code units which work with enabled multi-threading. #if !defined(VL_MT_DISABLED_CODE_UNIT) diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 329dcce5e..8df3598e4 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -353,7 +353,7 @@ void V3Broken::brokenAll(AstNetlist* nodep) { // Mark every node in the tree const uint8_t brokenCntCurrent = s_brokenCntGlobal.get(); - nodep->foreach([brokenCntCurrent](AstNode* nodep) { + nodep->foreach([brokenCntCurrent](AstNode* nodep) VL_NO_THREAD_SAFETY_ANALYSIS { #ifdef VL_LEAK_CHECKS UASSERT_OBJ(s_allocTable.isAllocated(nodep), nodep, "AstNode is in tree, but not allocated");