diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index f09b2d3913..a5f5cb842a 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -523,12 +523,20 @@ void start_cpu1_default(void) } #endif //!CONFIG_FREERTOS_UNICORE -#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS +/** + * This function overwrites a the same function of libsupc++ (part of libstdc++). + * Consequently, libsupc++ will then follow our configured exception emergency pool size. + * + * It will be called even with -fno-exception for user code since the stdlib still uses exceptions. + */ size_t __cxx_eh_arena_size_get(void) { +#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS return CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE; -} +#else + return 0; #endif +} static void do_global_ctors(void) { diff --git a/components/esp32s2beta/cpu_start.c b/components/esp32s2beta/cpu_start.c index eccf621aa3..9270ac5ae9 100644 --- a/components/esp32s2beta/cpu_start.c +++ b/components/esp32s2beta/cpu_start.c @@ -363,12 +363,20 @@ void start_cpu0_default(void) abort(); /* Only get to here if not enough free heap to start scheduler */ } -#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS +/** + * This function overwrites a the same function of libsupc++ (part of libstdc++). + * Consequently, libsupc++ will then follow our configured exception emergency pool size. + * + * It will be called even with -fno-exception for user code since the stdlib still uses exceptions. + */ size_t __cxx_eh_arena_size_get(void) { +#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS return CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE; -} +#else + return 0; #endif +} static void do_global_ctors(void) {