| 1 |
From cbda7ce74d74539ce0baef4a36198081dfb0265c Mon Sep 17 00:00:00 2001 |
| 2 |
From: Marc Mutz <[email protected]> |
| 3 |
Date: Fri, 14 Mar 2025 18:29:20 +0100 |
| 4 |
Subject: [PATCH] ECMEnableSanitizers.cmake: fix GCC's "note: variable tracking |
| 5 |
size limit exceeded" when using asan |
| 6 |
MIME-Version: 1.0 |
| 7 |
Content-Type: text/plain; charset=UTF-8 |
| 8 |
Content-Transfer-Encoding: 8bit |
| 9 |
|
| 10 |
Set the max-vartrack-size parameter to 0 (= unlimited) to avoid GCC's |
| 11 |
"note: variable tracking size limit exceeded with |
| 12 |
-fvar-tracking-assignments, retrying without" message you get when you |
| 13 |
compile with asan sometimes. |
| 14 |
|
| 15 |
This is reported¹ to speed up compilation, not slow it down. |
| 16 |
|
| 17 |
¹ https://stackoverflow.com/a/75704837/134841 |
| 18 |
--- |
| 19 |
modules/ECMEnableSanitizers.cmake | 10 ++++++++++ |
| 20 |
1 file changed, 10 insertions(+) |
| 21 |
|
| 22 |
diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake |
| 23 |
index 07db1c80..45236e6d 100644 |
| 24 |
--- a/modules/ECMEnableSanitizers.cmake |
| 25 |
+++ b/modules/ECMEnableSanitizers.cmake |
| 26 |
@@ -117,6 +117,16 @@ macro (enable_sanitizer_flags sanitize_option) |
| 27 |
set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") |
| 28 |
set(XSAN_LINKER_FLAGS "asan") |
| 29 |
endif() |
| 30 |
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 31 |
+ # fixes "note: variable tracking size limit exceeded with |
| 32 |
+ # -fvar-tracking-assignments, retrying without" (which is |
| 33 |
+ # another way of saying "I'll go ahead and compile this |
| 34 |
+ # thing _twice_") by making it unlimited |
| 35 |
+ # Reference: |
| 36 |
+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html |
| 37 |
+ # -> max-vartrack-size |
| 38 |
+ string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0") |
| 39 |
+ endif () |
| 40 |
elseif (${sanitize_option} MATCHES "thread") |
| 41 |
check_compiler_version("4.8" "3.1" "99.99") |
| 42 |
set(XSAN_COMPILE_FLAGS "-fsanitize=thread") |
| 43 |
-- |
| 44 |
2.25.1 |
| 45 |
|