r/cpp • u/13steinj • Sep 19 '24
CppCon C++ Exceptions for Smaller Firmware - Khalil Estell - CppCon 2024
https://www.youtube.com/watch?v=bY2FlayomlE
83
Upvotes
r/cpp • u/13steinj • Sep 19 '24
27
u/fwsGonzo IncludeOS, C++ bare metal Sep 20 '24 edited Sep 20 '24
The C++ exceptions story is history repeating itself that everyone is just repeating what they heard and what they learned. And it turned out to be complete bs. He didn't even need to change a single line in libunwind to make embedded binaries with exceptions smaller than without, for what are programs less than 64kb. Makes me wonder what else we are all wrong about.
One of my hobbies is emulation/interpreters, and I want to try to accelerate C++ exceptions in my RISC-V emulator by handling them entirely outside of the guest. In theory, it would make the guest programs smaller, and exception handling native performance. Wouldn't that be cool?
8
u/Tringi github.com/tringi Sep 20 '24
Damn, finally some proper talk. Hook me up and inject this type of research into my veins ...um, compiler.
6
u/ts826848 Sep 20 '24
At least based on the title/speaker looks like this might be similar to/the same as his ACCU talk ("C++ Exceptions Reduce Firmware Code Size")? Anyone know if the content is the same?
6
u/catcat202X Sep 20 '24
https://github.com/ApexAI/static_exception
This library has a really cool idea of re-implementing GCC's exceptions API with a memory pool, so you can have C++ exceptions work as normal but also easily do so with bounded memory constraints.
4
u/XeroKimo Exception Enthusiast Sep 21 '24
Amazing work and updates for thisΒ talk.
I really wish I had more real world practical experience because implementing my theories on structuring code bases around exceptions in my own code bases and having great success in it doesn't mean it'll apply everywhere as it really surprised me about what you said when exceptions suck because we don't know what throws and what kind of exception gets thrown, and I agree, that sucks, but at the same time, I kind of embrace it based on my current understanding of general error handling written here.
I am still experimenting on that different exception hierarchy from that previous post and learnt a few things so far in trying to implement it. Reminder it's this concept of
Exception<F, E, O>where I'm trying to make a wide hierarchy for various reasons2
u/Ok-Revenue-3059 Sep 21 '24
Great talk. Apologies if I missed it, but it would be useful to at least mention how it applies to using with FreeRTOS or similar. I did a quick search and it is apparently possible with some caveats.