Skia, RTTI, and C++ exceptions Jun 27, 2018

If you are going to use the static version of the Skia library in your program, and you use C++ exceptions as your error handling mechanism, you might have problem in your hands (mainly in your macOS port).

By default Skia is compiled without RTTI information (-fno-rtti flag), but Skia uses the STL anyway (std::vector, etc.), this might link a std::exception without RTTI. So code like this:

#include <cstdio>
#include <stdexcept>

int main() {
  try {
    throw std::runtime_error("testing...");
  catch (const std::exception& e) {

Will crash because the std::runtime_error doesn’t have the RTTI information necessary to match the std::exception. To fix this you have to compile Skia with an extra flag: extra_cflags_cc=["-frtti"].

This might be a Clang bug, I have reported it and reduce the issue to a minimal example.