Enabling Exceptions in C++ Build #CPP #CPP_Exceptions
apion@...
I am trying to get my code to build with C++ exceptions enabled. Here are my configurations:
CONFIG_CPLUSPLUS=y CONFIG_NEWLIB_LIBC=y CONFIG_LIB_CPLUSPLUS=y CONFIG_MINIMAL_LIBC=n CONFIG_NEWLIB_LIBC_NANO=n CONFIG_EXCEPTIONS=y The build fails in the linker stage with an undefined reference to "_fini". Does anyone know why this is happening? (The code builds fine if I don't try to use exceptions) |
|
artur.lipowski@...
What SDK/toolchain and platform do you use?
BTW> Build with C++ exceptions is a part of Zephyr CI (1 test), so for many platforms (including mine) C++ exceptions work well. |
|
Dave Nadler
Are exceptions thread-safe under Zephyr
with newlib?
mbarret, what is the COMPLETE list of menuconfig options you used to enable C++, and which compiler are you using? Here's why I'm asking (specifically,
GCC toolchain)...
Not thread-safe: C++ Exception Processing Crashes in GNU Arm Embedded Toolchain Depending on how toolchain is built,
appropriate mutex support may not be included...
Interested to hear what Zephyr users
are doing here...
Hope that helps, Best Regards, Dave On 12/9/2021 8:32 AM,
mbarrett@... wrote:
We figured out the issue. There are some other config dependencies that I was unaware of but On 12/9/2021 2:48 AM, artur.lipowski
via lists.zephyrproject.org wrote:
What SDK/toolchain and platform do you use?
-- Dave Nadler, USA East Coast voice (978) 263-0097, drn@..., Skype Dave.Nadler1 |
|
Stephanos Ioannidis
Hi,
While the newlib itself is thread-safe, libgcc and libstdc++ (and therefore C++ exceptions) are not.
We currently build the GCC with --enable-threads=no (i.e. single thread model), so we are using the libgcc gthr-single.h with dummy lock implementations.
In the future, this issue will be addressed by providing Zephyr-specific gthread implementation in the libgcc (gthr-zephyr.h) and building GCC with --enable-threads=zephyr.
For more details, refer to the Zephyr SDK issue #350.
Regards,
Stephanos
|
|
Dave Nadler
Thanks Stephanos, it is great to hear
that C++ exception thread-safety in Zephyr will be fixed.
Do you have an expected date for this? Thanks again, Best Regards, Dave On 12/9/2021 7:57 PM, Stephanos
Ioannidis wrote:
-- Dave Nadler, USA East Coast voice (978) 263-0097, drn@..., Skype Dave.Nadler1 |
|