From 0f084321f265235e898b63224ff33c1e341974b8 Mon Sep 17 00:00:00 2001 From: Maksim Kutakov Date: Thu, 18 Apr 2024 11:36:24 +0200 Subject: [PATCH] Fix sanitizer cmake config for GNU compiler --- cmake/developer_package/compile_flags/sanitizer.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/developer_package/compile_flags/sanitizer.cmake b/cmake/developer_package/compile_flags/sanitizer.cmake index 5927aec9cc2d5b..02c62640207c43 100644 --- a/cmake/developer_package/compile_flags/sanitizer.cmake +++ b/cmake/developer_package/compile_flags/sanitizer.cmake @@ -16,7 +16,7 @@ if (ENABLE_SANITIZER) "Please, check requirements:\n" "https://github.com/openvinotoolkit/openvino/wiki/AddressSanitizer-and-LeakSanitizer") endif() - elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) + elseif(OV_COMPILER_IS_CLANG) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/asan/ignore.txt") if(BUILD_SHARED_LIBS) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -shared-libasan") @@ -31,6 +31,14 @@ if (ENABLE_SANITIZER) if(BUILD_SHARED_LIBS) set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -shared-libasan") endif() + elseif(CMAKE_COMPILER_IS_GNUCXX) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address") + + check_cxx_compiler_flag("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED) + if (SANITIZE_RECOVER_ADDRESS_SUPPORTED) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address") + endif() + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address") else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif()