Even though the c++ compiler is passed switches like "-fnoexceptions -fno-rtti -fno-threadsafe-statics", the copy of libstdc++ that gets linked by Teensyduino was still built with exceptions enabled and includes a bunch of cruft associated with handling them. Most of it is associated with the "__verbose_terminate_handler" function that tries to display "friendly" information when unhandled exceptions cause the program to terminate.
Here's an example of build output from a program that makes reasonable use of the C++ STL:
If I add this code to stub out __verbose_terminate_handler:
The size of the output binary shrinks to this:
By default nearly half of the program consists of exception handling rubbish that should never get used. Can we please either include the stub for this function in cores somewhere, or use a copy of libstdc++ that was built with --disable-libstdcxx-verbose.
Here's an example of build output from a program that makes reasonable use of the C++ STL:
Code:
Memory Usage on Teensy 4.1:
FLASH: code:106108, data:13256, headers:8632 free for files:7998468
RAM1: variables:18208, code:102564, padding:28508 free for local variables:375008
RAM2: variables:17728 free for malloc/new:506560
If I add this code to stub out __verbose_terminate_handler:
Code:
namespace __gnu_cxx
{
void __verbose_terminate_handler()
{
while (1) asm ("WFI");
}
}
Code:
Memory Usage on Teensy 4.1:
FLASH: code:58224, data:7112, headers:8388 free for files:8052740
RAM1: variables:12032, code:54680, padding:10856 free for local variables:446720
RAM2: variables:17728 free for malloc/new:506560
By default nearly half of the program consists of exception handling rubbish that should never get used. Can we please either include the stub for this function in cores somewhere, or use a copy of libstdc++ that was built with --disable-libstdcxx-verbose.