From 51cf964e95e20926dcff3f1a79b8bb66992b5e62 Mon Sep 17 00:00:00 2001 From: msclock Date: Tue, 2 Apr 2024 11:12:52 +0800 Subject: [PATCH] fix: resolve the conflics between ub minimal runtime and asan (#79) Signed-off-by: msclock --- cmake/build/Hardening.cmake | 11 +++++++++++ cmake/{test => build}/Sanitizer.cmake | 0 2 files changed, 11 insertions(+) rename cmake/{test => build}/Sanitizer.cmake (100%) diff --git a/cmake/build/Hardening.cmake b/cmake/build/Hardening.cmake index a538739..74600a9 100644 --- a/cmake/build/Hardening.cmake +++ b/cmake/build/Hardening.cmake @@ -16,6 +16,7 @@ Example: include_guard(GLOBAL) include(${CMAKE_CURRENT_LIST_DIR}/../Common.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/Sanitizer.cmake) set(USE_HARDENING ON @@ -123,6 +124,16 @@ endif() flags_to_list(hardening_links "${hardening_links}") +# Handle the conflics between hardening ubsan and asan +if(san_available_flags MATCHES "-fsanitize=address") + message( + WARNING "Try to disable usan minimal runtime due to conflict with asan") + list(REMOVE_ITEM hardening_flags "-fsanitize=undefined" + "-fsanitize-minimal-runtime" "-fno-sanitize-recover=undefined") + list(REMOVE_ITEM hardening_links "-fsanitize=undefined" + "-fsanitize-minimal-runtime" "-fno-sanitize-recover=undefined") +endif() + message(STATUS "Final Hardening flags: ${hardening_flags}") message(STATUS "Final Hardening links: ${hardening_links}") diff --git a/cmake/test/Sanitizer.cmake b/cmake/build/Sanitizer.cmake similarity index 100% rename from cmake/test/Sanitizer.cmake rename to cmake/build/Sanitizer.cmake