Fix building with asan option and OSL.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 23 Apr 2019 18:59:10 +0000 (20:59 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 23 Apr 2019 19:00:40 +0000 (21:00 +0200)
When OSL is enabled, Cycles disables RTTI in some of its modules, which
then breaks vptr sanitizer (part of the 'undefined' sanitizer).

thanks to @brecht for helping tracking down the issue.

CMakeLists.txt

index 052222b..1cb2014 100644 (file)
@@ -811,6 +811,12 @@ if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
 
     set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
     set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
+    if(WITH_CYCLES_OSL)
+      # With OSL, Cycles disables rtti in some modules, wich then breaks at linking
+      # when trying to use vptr sanitizer (included into 'undefined' general option).
+      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
+      set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr")
+    endif()
     if(MSVC)
       set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
     endif()