Use default thread sanitizer linkage (#899)
GCC and CLang *default* sanitizer linkage differs (static vs. dynamic). Prefer default behavior as alternate seen having issues. Default (GN)U linker fails with unresolved symbols linking Clang built binaries with sanitizer enabled. Force use LLVM linker lld for Clang builds. Sanitizer instrumentation and link flags should be retained for all binaries. Updating samples cmake configuration to keep those flags after unset logic at the ie_build_samples().
This commit is contained in:
@@ -27,8 +27,14 @@ endif()
|
||||
|
||||
if (ENABLE_THREAD_SANITIZER)
|
||||
set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=thread -fno-omit-frame-pointer")
|
||||
set(SANITIZER_LINKER_FLAGS "-fsanitize=thread -static-libsan")
|
||||
|
||||
set(SANITIZER_LINKER_FLAGS "-fsanitize=thread")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
|
||||
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld")
|
||||
else()
|
||||
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -static-libsan")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
|
||||
@@ -79,7 +79,7 @@ function(ie_build_samples)
|
||||
MINGW64 CMAKE_BUILD_TYPE CMAKE_MACOSX_RPATH)
|
||||
unset(${var})
|
||||
endforeach()
|
||||
|
||||
include(sanitizer)
|
||||
add_subdirectory(samples)
|
||||
endfunction()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user