From c6495e75fc6114314512427bce5e202c1ad648c6 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 29 Mar 2016 20:13:23 +0200 Subject: ECMEnableSanitizers: avoid linking runtime for Clang Clang automatically adds its runtime library (librt) when given the -fsanitize options. Do not force the GCC runtime libraries (asan, tsan, lsan), this results in "Your application is linked against incompatible ASan runtimes." errors when using the library in an executable built using Clang. Acked by Mathieu Tarral REVIEW: 127513 --- modules/ECMEnableSanitizers.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index e64599b6..aa7092df 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -139,7 +139,9 @@ foreach ( CUR_SANITIZER ${ECM_ENABLE_SANITIZERS} ) # check option and enable appropriate flags enable_sanitizer_flags ( ${CUR_SANITIZER} ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XSAN_COMPILE_FLAGS}" ) - link_libraries(${XSAN_LINKER_FLAGS}) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + link_libraries(${XSAN_LINKER_FLAGS}) + endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") -- cgit v1.2.1