Description
The nano variant of the libstdc++ library (libstdc++_nano.a
and libsupc++_nano.a
) is not built with the correct specs.
Comparing libstdc++ of Zephyr SDK and GNU Arm Embedded:
Toolchain | libstdc++.a | libstdc++_nano.a |
---|---|---|
Zephyr SDK | 5.4M | 5.3M |
GNU Arm Embedded | 5.5M | 3.5M |
Note that there is a significant size difference between the full and nano variants of libstdc++ for GNU Arm Embedded, whereas the size difference between these two for Zephyr SDK is minimal.
This difference is due to the fact that the libstdc++ for Zephyr SDK is currently built with only -Os
(optimise for space), whereas the libstdc++ for GNU Arm Embedded is built with -Os
and -fno-exceptions
(no C++ exception handling support).
The decision to disable C++ exception handling support for the nano variant of the libstdc++ library is a sensible one, noting that doing so greatly reduces the final binary size, which can be said to be the whole point of having a separate nano variant.
The following fix should be implemented:
- Add a crosstool-ng config/scheme that can be used to specfiy
-fno-exceptions
toCXXFLAGS_FOR_TARGET
. - Use the above to specify
-fno-exceptions
for the libstdc++ nano build.
For more information, refer to the issue zephyrproject-rtos/zephyr#35972.