From 3488f97ed86ca339d02a681b3bc57c03e9772696 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 6 Oct 2022 21:08:46 +0200 Subject: [PATCH] Add sanitizer options. Fix mac default folders locations like rings and belr grammars. --- CMakeLists.txt | 2 ++ linphone-app/CMakeLists.txt | 29 ++++++++----------- .../linphone_package/CMakeLists.txt | 12 +++++--- linphone-sdk | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2b5a45a1..c5c698053 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ option(ENABLE_BUILD_EXAMPLES "Enable the build of examples" NO) option(ENABLE_BUILD_VERBOSE "Enable the build generation to be more verbose" NO) option(ENABLE_DAEMON "Enable the linphone daemon interface." NO) option(ENABLE_FFMPEG "Build mediastreamer2 with ffmpeg video support." ON) +option(ENABLE_SANITIZER "Enable sanitizer." NO) option(ENABLE_STRICT "Build with strict compilator flags e.g. -Wall -Werror" NO) option(ENABLE_TESTS "Build with testing binaries of SDK" NO ) option(ENABLE_TESTS_COMPONENTS "Build libbctoolbox-tester" NO ) @@ -131,6 +132,7 @@ list(APPEND APP_OPTIONS "-DENABLE_UNIT_TESTS=${ENABLE_UNIT_TESTS}") list(APPEND APP_OPTIONS "-DENABLE_TESTS=${ENABLE_TESTS}") list(APPEND APP_OPTIONS "-DENABLE_TESTS_COMPONENTS=${ENABLE_TESTS_COMPONENTS}") list(APPEND APP_OPTIONS "-DENABLE_TOOLS=${ENABLE_TOOLS}") +list(APPEND APP_OPTIONS "-DENABLE_SANITIZER=${ENABLE_SANITIZER}") list(APPEND APP_OPTIONS "-DENABLE_STRICT=${ENABLE_STRICT}") list(APPEND APP_OPTIONS "-DENABLE_FFMPEG=${ENABLE_FFMPEG}") list(APPEND APP_OPTIONS "-DENABLE_BUILD_VERBOSE=${ENABLE_BUILD_VERBOSE}") diff --git a/linphone-app/CMakeLists.txt b/linphone-app/CMakeLists.txt index 0493b0661..656baf131 100644 --- a/linphone-app/CMakeLists.txt +++ b/linphone-app/CMakeLists.txt @@ -89,18 +89,6 @@ if(ENABLE_BUILD_VERBOSE) endif() # Build configuration -############################# -#Sanitizer -if(ENABLE_SANITIZER) - set(sanitize_flags "-fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls") - set(sanitize_linker_flags "-fsanitize=address,undefined") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${sanitize_flags}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${sanitize_flags}") - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize_linker_flags}") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${sanitize_linker_flags}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${sanitize_linker_flags}") -endif() ############################# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DQT_NO_DEBUG") @@ -110,14 +98,21 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DQT_QML_DEBUG -DQT_ ############################# #Sanitizer if(ENABLE_SANITIZER) - set(sanitize_flags "-fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls") - set(sanitize_linker_flags "-fsanitize=address,undefined") + if(MSVC) + set(sanitize_flags "/fsanitize=address /Oy-") + else() + set(sanitize_flags "-fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls") + endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${sanitize_flags}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${sanitize_flags}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize_linker_flags}") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${sanitize_linker_flags}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${sanitize_linker_flags}") + if(NOT MSVC) + set(sanitize_linker_flags "-fsanitize=address,undefined") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitize_linker_flags}") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${sanitize_linker_flags}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${sanitize_linker_flags}") + endif() endif() ############################# diff --git a/linphone-app/cmake_builder/linphone_package/CMakeLists.txt b/linphone-app/cmake_builder/linphone_package/CMakeLists.txt index e45186092..f0e2e85c0 100644 --- a/linphone-app/cmake_builder/linphone_package/CMakeLists.txt +++ b/linphone-app/cmake_builder/linphone_package/CMakeLists.txt @@ -149,7 +149,14 @@ if (WIN32) LIBRARY DESTINATION "${LIBDIR}" RUNTIME DESTINATION "${LIBDIR}" ) - + if(ENABLE_SANITIZER AND MSVC) + if( CMAKE_SIZEOF_VOID_P EQUAL 8) + find_file(SANITIZER_LIB clang_rt.asan_dynamic-x86_64.dll) + else() + find_file(SANITIZER_LIB clang_rt.asan_dynamic-i386.dll) + endif() + install(FILES "${SANITIZER_LIB}" DESTINATION "${CMAKE_INSTALL_BINDIR}/") + endif() ############################## set(BIN_ARCH "win32") @@ -193,10 +200,7 @@ elseif (APPLE) endforeach(item) endif() install(FILES ${SHARED_LIBRARIES} DESTINATION "${APPLICATION_NAME}.app/Contents/Frameworks") - file(GLOB GRAMMAR_FILES "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/Belr/grammars/*") - install(FILES ${GRAMMAR_FILES} DESTINATION "${APPLICATION_NAME}.app/Contents/Resources/${CMAKE_INSTALL_DATAROOTDIR}/belr/grammars/") install(DIRECTORY "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/images" DESTINATION "${APPLICATION_NAME}.app/Contents/Resources/${CMAKE_INSTALL_DATAROOTDIR}" USE_SOURCE_PERMISSIONS OPTIONAL) - install(DIRECTORY "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/sounds/linphone/" DESTINATION "${APPLICATION_NAME}.app/Contents/Resources/${CMAKE_INSTALL_DATAROOTDIR}/sounds/${EXECUTABLE_NAME}" USE_SOURCE_PERMISSIONS) install(FILES "${LINPHONE_OUTPUT_DIR}/${CMAKE_INSTALL_DATAROOTDIR}/Linphone/rootca.pem" DESTINATION "${APPLICATION_NAME}.app/Contents/Resources/${CMAKE_INSTALL_DATAROOTDIR}/${EXECUTABLE_NAME}") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../assets/linphonerc-factory" DESTINATION "${APPLICATION_NAME}.app/Contents/Resources/${CMAKE_INSTALL_DATAROOTDIR}/${EXECUTABLE_NAME}") diff --git a/linphone-sdk b/linphone-sdk index ba15d5d18..b9e9ed678 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit ba15d5d1862543b073d878c77b5c91babfe6abf4 +Subproject commit b9e9ed67872864dfcb802825a04678fea3f316a1