[F] Fixed ubsan build with clang

This commit is contained in:
seleznevae 2019-01-13 11:22:51 +03:00
parent f9db2c8402
commit 6ae5cb0107

View File

@ -183,12 +183,17 @@ if("${FORT_COMPILER}" STREQUAL "GNU" OR "${FORT_COMPILER}" STREQUAL "Clang")
#ubsan case #ubsan case
if(FORT_BUILD_TYPE STREQUAL "ubsan") if(FORT_BUILD_TYPE STREQUAL "ubsan")
# -fno-sanitize-recover option is used to force faild # -fno-sanitize-recover option is used to force faild
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
if("${FORT_COMPILER}" STREQUAL "GNU") if("${FORT_COMPILER}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover")
target_link_libraries(${PROJECT_NAME}_example ubsan) target_link_libraries(${PROJECT_NAME}_example ubsan)
target_link_libraries(${PROJECT_NAME}_example_cpp ubsan) target_link_libraries(${PROJECT_NAME}_example_cpp ubsan)
target_link_libraries(${PROJECT_NAME}_test ubsan) target_link_libraries(${PROJECT_NAME}_test ubsan)
elseif("${FORT_COMPILER}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover=all")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all")
endif("${FORT_COMPILER}" STREQUAL "GNU") endif("${FORT_COMPILER}" STREQUAL "GNU")
endif(FORT_BUILD_TYPE STREQUAL "ubsan") endif(FORT_BUILD_TYPE STREQUAL "ubsan")