From 5045d299a6a73219d0e70abb74d6a17186a4db0f Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 8 Feb 2021 20:50:00 +0300 Subject: [PATCH] enable AddressSanitizer only for GCC 5 onwards (bug #5533) --- CMakeLists.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5757388c4..cb65bdc04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2350,20 +2350,21 @@ macro(asan_check_add_debug_flag2 ASAN_FLAG) endmacro() # enable AddressSanitizer if supported -check_add_debug_flag("-shared-libasan" "shared_libasan") -asan_check_add_debug_flag2("address") -asan_check_add_debug_flag("bool") -asan_check_add_debug_flag("bounds") -asan_check_add_debug_flag("enum") -asan_check_add_debug_flag("float-cast-overflow") -asan_check_add_debug_flag("float-divide-by-zero") -asan_check_add_debug_flag("nonnull-attribute") -asan_check_add_debug_flag("returns-nonnull-attribute") -asan_check_add_debug_flag("signed-integer-overflow") -asan_check_add_debug_flag("undefined") -asan_check_add_debug_flag("vla-bound") -asan_check_add_debug_flag("leak") -asan_check_add_debug_flag("object-size") +if ( (CMAKE_C_COMPILER_ID STREQUAL "GNU") AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4) + asan_check_add_debug_flag2("address") + asan_check_add_debug_flag("bool") + asan_check_add_debug_flag("bounds") + asan_check_add_debug_flag("enum") + asan_check_add_debug_flag("float-cast-overflow") + asan_check_add_debug_flag("float-divide-by-zero") + asan_check_add_debug_flag("nonnull-attribute") + asan_check_add_debug_flag("returns-nonnull-attribute") + asan_check_add_debug_flag("signed-integer-overflow") + asan_check_add_debug_flag("undefined") + asan_check_add_debug_flag("vla-bound") + asan_check_add_debug_flag("leak") + asan_check_add_debug_flag("object-size") +endif() ##### Tests #####