From 08dbec532afc49fa6e306f9d944592c566658dce Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Fri, 29 Jan 2021 23:29:54 +0000 Subject: [PATCH] CMake: Fix UBSAN link error --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6be322ddb..f71e066314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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")