Commit 48c8a180 by Ben Clayton

CMakeLists: Pass sanitizer flags to the linker too.

We were only passing them to the compiler. These should go to the linker as well. Bug: b/133127573 Change-Id: Ifc02a2c17a164f30c80311fd17d2a6311e3d5cba Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31817Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent b03ce831
...@@ -224,6 +224,14 @@ macro(set_cpp_flag FLAG) ...@@ -224,6 +224,14 @@ macro(set_cpp_flag FLAG)
endif() endif()
endmacro() endmacro()
macro(set_linker_flag FLAG)
if(${ARGC} GREATER 1)
set(CMAKE_EXE_LINKER_FLAGS ${ARGV1} "${CMAKE_EXE_LINKER_FLAGS ${ARGV1}} ${FLAG}")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
endif()
endmacro()
if(MSVC) if(MSVC)
set_cpp_flag("/MP") set_cpp_flag("/MP")
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
...@@ -371,12 +379,16 @@ else() ...@@ -371,12 +379,16 @@ else()
if(MSAN) if(MSAN)
set_cpp_flag("-fsanitize=memory") set_cpp_flag("-fsanitize=memory")
set_linker_flag("-fsanitize=memory")
elseif(ASAN) elseif(ASAN)
set_cpp_flag("-fsanitize=address") set_cpp_flag("-fsanitize=address")
set_linker_flag("-fsanitize=address")
elseif(TSAN) elseif(TSAN)
set_cpp_flag("-fsanitize=thread") set_cpp_flag("-fsanitize=thread")
set_linker_flag("-fsanitize=thread")
elseif(UBSAN) elseif(UBSAN)
set_cpp_flag("-fsanitize=undefined") set_cpp_flag("-fsanitize=undefined")
set_linker_flag("-fsanitize=undefined")
endif() endif()
endif() endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment