CMake: Fix UBSAN link error

This commit is contained in:
Gleb Mazovetskiy 2021-01-29 23:29:54 +00:00
parent 0fb42e07a6
commit 08dbec532a

View File

@ -283,6 +283,14 @@ if(NOT MSVC)
message("Undefined behaviour sanitizer enabled (DEBUG only)")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=undefined")
# UBSAN is a collection of sanitizers, including vtpr, which reqiuires RTTI.
# ext/glslang disables RTTI by default using the `ENABLE_RTTI` option.
# If RTTI is disabled, we must also disable the vtpr sanitizer.
if(NOT ENABLE_RTTI)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-sanitize=vptr")
endif()
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")