cpp_client_telemetry icon indicating copy to clipboard operation
cpp_client_telemetry copied to clipboard

No exceptions build

Open maxgolov opened this issue 5 years ago • 5 comments

In a few interesting environments:

  • Android
  • cross-library ABI calls where libraries are built with different compilers

It'd make sense to totally avoid using exceptions. For that reason the SDK is providing MATSDK_THROW macro, that allows to either crash (std::terminate) the app, or transform the failure into some sort of error code.

I believe a few recent changes might have introduced exceptions, such as throwing without using MATSDK_THROW macro. That results in having to build with exceptions. We do want to maintain ability to build without exceptions, so these recent changes must be carefully reviewed.

maxgolov avatar Jun 24 '20 07:06 maxgolov

@larvacea - I can try to validate this with Gnu C++ and Clang on Mac, i.e. how it all works if we try the no-exceptions build.

Would you be able to check if some of the existing Android layer code can use a macro instead of try / catch / throw? (as a lower priority item). Historically I remember that some apps, like Skype, provided an option of building without exceptions, with throw being a function call instead of the actual standard library exception flow.

maxgolov avatar Jun 24 '20 16:06 maxgolov

The existing Android layer code does not need to throw C++ exceptions, so that's the simple, painless approach. The STL will likely throw exceptions. If you feel it would be helpful, I can annotate methods as noexcept to make STL exceptions turn into terminate().

larvacea avatar Jun 24 '20 18:06 larvacea

Let's see if react would work as-is in static build with matching runtime ( #471 ), then solving no-except would probably be of lower priority. I'd like to enable as many teams as possible :) React seems like an interesting / useful scenario to enable.

maxgolov avatar Jun 24 '20 18:06 maxgolov

I'm removing BUG label from it - since we generally have the SDK working fine in most environments. No-exceptions may require a bit of a buildflag / build infra changes, and although seems like easy on surface - this may have implications, like we most likely NOT gonna be adding no exceptions into CI loop. I'll try to spend a few hours on cleaning this up, testing on Mac and/or Linux Desktop.

maxgolov avatar Jun 24 '20 20:06 maxgolov

Martin's fix in #475 cleans-up the Android side. I'd like to see if we can specify a new build option at build.sh script level to force the no-except for POSIX-alike systems. On Windows we're usually (and normally) fine to live with exceptions in place.

maxgolov avatar Jun 25 '20 03:06 maxgolov