RTTI linking issue, Hydra Cycles render delegate development

Hello,

I’m beginning development of a Hydra Cycles render delegate (i.e. from USD library… I’m with Tangent Animation). I want to link libusd_m.lib with bf_intern_cycles library but the following …/intern/cycles/CMakeLists.txt presents an issue when linking the libraries:

if(WITH_CYCLES_OSL)
  # LLVM and OSL need to build without RTTI
  if(WIN32 AND MSVC)
    set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
  elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
    set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
  endif()
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
endif()

I’m compiling and linking with Visual Studio on a Windows 10 box:

cmd.exe /C "cd . && C:\Users\philip.luk\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\193.5233.144\bin\cmake\win\bin\cmake.exe -E vs_link_exe --intdir=source\creator\CMakeFiles\blender.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x86\mt.exe --manifests blender.exe.manifest -- C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x64\link.exe /nologo @CMakeFiles\blender.rsp  /out:bin\blender.exe /implib:bin\blender.lib /pdb:bin\blender.pdb /version:0.0  /machine:x64 /SAFESEH:NO /MACHINE:X64  /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO  /ignore:4049 /ignore:4217 /ignore:4221 /debug /INCREMENTAL  /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib /subsystem:console  /DELAYLOAD:vcomp140d.dll delayimp.lib  && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x64\link.exe /nologo @CMakeFiles\blender.rsp /out:bin\blender.exe /implib:bin\blender.lib /pdb:bin\blender.pdb /version:0.0 /machine:x64 /SAFESEH:NO /MACHINE:X64 /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /ignore:4049 /ignore:4217 /ignore:4221 /debug /INCREMENTAL /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib /subsystem:console /DELAYLOAD:vcomp140d.dll delayimp.lib /MANIFEST /MANIFESTFILE:source\creator\CMakeFiles\blender.dir/intermediate.manifest source\creator\CMakeFiles\blender.dir/manifest.res" failed (exit code 1319) with the following output:
bf_intern_cycles.lib(blender_session.cpp.obj) : error LNK2038: mismatch detected for 'boost__type_index__abi': value 'RTTI is off - typeid() is used only for templates' doesn't match value 'RTTI is used' in bf_usd.lib(usd_capi.cc.obj)
   Creating library bin\blender.lib and object bin\blender.exp

Since USD is compiled with RTTI and uses dynamic_cast, typeid, this appears to be an issue with conflicting enabled/disabled RTTI settings. Does anyone have an opinion about how to deal with it?

I’m attempting to enable the following flags when building LLVM and OSL to solve the issue:
LLVM: LLVM_REQUIRES_RTTI =ON
OSL: ENABLERTTI=ON

… but is there a good reason not to do this?

Thanks,
Philip Luk

1 Like

Building LLVM and OSL with RTTI enabled is probably fine. They just build without RTTI by default, so we followed that. I couldn’t find information about it why exactly this is done.

Maybe disabling RTTI helps reducing executable size or memory usage? I’ve never tried to check that.

Thanks for the feedback. I’ll post to this thread if I discover any performance or related issues from the build.