project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.45k stars 1.99k forks source link

Figure out what parts of libstdc++ we are pulling in and why #2757

Open bzbarsky-apple opened 4 years ago

bzbarsky-apple commented 4 years ago

Problem

Our esp32 "wifi-echo" example app has 114KB of flash used by code that comes from libstdc++. I looked a bit at the specific functions we're pulling in and I see things like:

void std::__facet_shims::__numpunct_fill_cache<wchar_t>(std::integral_constant<bool, true>, std::locale::facet const*, std::__numpunct_cache<wchar_t>*)
std::collate<wchar_t>::do_compare(wchar_t const*, wchar_t const*, wchar_t const*, wchar_t const*) const
std::locale::_Impl::_Impl(unsigned int)

etc, etc. So for some reason we're pulling in a bunch of locale stuff, and I strongly suspect this is not in fact desired. Just that locale::_Impl constructor is 1.5KB of codesize!

Proposed Solution

Figure out which parts of this we actually need and why and make the rest go away. This might need to end up as multiple issues as we go....

issue-label-bot[bot] commented 4 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

bzbarsky-apple commented 4 years ago

Oh, and we also need to check whether this is happening on other platforms too. But I just looked at out/debug/nrf5_lighting_app//chip-nrf52840-lighting-example.map and it seems to have the locale bits too....

mspang commented 4 years ago

https://github.com/project-chip/connectedhomeip/pull/2759

bzbarsky-apple commented 4 years ago

2759

That helps a lot! With that change, the libstdc++ bits are down to more like 15KB.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 2 years ago

This stale issue has been automatically closed. Thank you for your contributions.

bzbarsky-apple commented 2 years ago

Still need to get to this.

tcarmelveilleux commented 2 years ago

This impacts Flash and RAM size on all embedded platforms

kpschoedel commented 2 years ago

The ALLOW list in #14704 is a partial answer.

kpschoedel commented 2 years ago

src/app/app-platform/ContentApp.h: list, string src/app/clusters/application-basic-server/application-basic-delegate.h: list src/app/clusters/application-basic-server/application-basic-server.cpp: list src/app/clusters/application-launcher-server/application-launcher-delegate.h: list src/app/clusters/audio-output-server/audio-output-delegate.h: list src/app/clusters/channel-server/channel-delegate.h: list src/app/clusters/content-launch-server/content-launch-delegate.h: list src/app/clusters/content-launch-server/content-launch-server.cpp: list src/app/clusters/media-input-server/media-input-delegate.h: list src/app/clusters/media-playback-server/media-playback-delegate.h: list src/app/clusters/target-navigator-server/target-navigator-delegate.h: list

src/setup_payload/AdditionalDataPayload.h: string src/setup_payload/AdditionalDataPayloadParser.cpp: vector src/setup_payload/Base38Decode.h: string, vector src/setup_payload/ManualSetupPayloadGenerator.h: string src/setup_payload/ManualSetupPayloadParser.cpp: string, vector src/setup_payload/ManualSetupPayloadParser.h: string src/setup_payload/QRCodeSetupPayloadParser.cpp: vector src/setup_payload/QRCodeSetupPayloadParser.h: string src/setup_payload/SetupPayloadHelper.cpp: fstream src/setup_payload/SetupPayloadHelper.h: string src/setup_payload/SetupPayload.h: map, string, vector

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.