__eh_frame missing when building with ESP-DIF (ESP32)

__eh_frame missing when building with ESP-DIF (ESP32)
Photo by Vishnu Mohanan / Unsplash

If you just enabled the CONFIG_ESP_SYSTEM_USE_EH_FRAME or CONFIG_CXX_EXCEPTIONS build options to allow for debugging / C++ exception handling, you might encounter an error during linking similar to "undefined reference to __eh_frame"

I didn't debug that much into it as there wasn't much information available online, digging in the source code of the ESP-DIF framework shows that it should automatically enable the EH_FRAME linking if one of these two flags is enabled.

esp-idf/components/esp_system/ld/ld.common at 5c51472e82a58098dda8d40a1c4f250c374fc900 · espressif/esp-idf
Espressif IoT Development Framework. Official development framework for Espressif SoCs. - espressif/esp-idf

Resolution

For some reason, it wasn't being done at link, probably a caching issue or whatever. Doesn't matter, in the end the fix was just to clean up the build folder and rebuild from scratch.

Now enjoy those C++ exception handling and riddle your codes with useless try/catch blocks.