From 2979e2cc48a73f010e0bfd292a646d0cd398998d Mon Sep 17 00:00:00 2001 From: Rokashevich Svetlana Date: Thu, 11 Sep 2025 21:42:41 +0800 Subject: [PATCH] Fix sanitiers build with ohos toolchain Signed-off-by: Rokashevich Svetlana Change-Id: I6b6224d2a676cc264d880607d91366b4d5be27aa --- static_core/cmake/Sanitizers.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static_core/cmake/Sanitizers.cmake b/static_core/cmake/Sanitizers.cmake index 1e0fa8c28b..5833bceeeb 100644 --- a/static_core/cmake/Sanitizers.cmake +++ b/static_core/cmake/Sanitizers.cmake @@ -78,17 +78,27 @@ function(panda_add_sanitizers) if(ARG_SANITIZERS) set(AVAILABLE_SANITIZERS "address" "undefined" "thread") + set(SANITIZERS_LINK_FLAGS) foreach(sanitizer ${ARG_SANITIZERS}) if(NOT ${sanitizer} IN_LIST AVAILABLE_SANITIZERS) message(FATAL_ERROR "Unknown sanitizer: ${sanitizer}") endif() + + if(${sanitizer} STREQUAL "address") + list(APPEND SANITIZERS_LINK_FLAGS "-lasan") + elseif(${sanitizer} STREQUAL "undefined") + list(APPEND SANITIZERS_LINK_FLAGS "-lubsan") + else() + list(APPEND SANITIZERS_LINK_FLAGS "-ltsan") + endif() endforeach() string(REPLACE ";" "," ARG_SANITIZERS "${ARG_SANITIZERS}") target_compile_options(${ARG_TARGET} PUBLIC "-fsanitize=${ARG_SANITIZERS}" -g) if (PANDA_ENABLE_SANITIZE_TRAP) target_compile_options(${ARG_TARGET} PUBLIC "-fsanitize-undefined-trap-on-error") endif() - set_target_properties(${ARG_TARGET} PROPERTIES LINK_FLAGS "-fsanitize=${ARG_SANITIZERS}") + string(REPLACE ";" " " SANITIZERS_LINK_FLAGS "${SANITIZERS_LINK_FLAGS}") + set_target_properties(${ARG_TARGET} PROPERTIES LINK_FLAGS ${SANITIZERS_LINK_FLAGS}) if (PANDA_TARGET_MOBILE) target_link_libraries(${ARG_TARGET} log) -- Gitee