Stripped-down libstdc++-psram-workaround.a
Posted: Sat Nov 25, 2017 11:40 pm
Holy hell! I used C++ std::*stream in my app and all of a sudden my libstdc++ usage ballooned from ~7k to ~200k.
Merely instantiating a std::stringstream does this, and investigation of the map file reveals that a lot of that is related to pulling in locale and formatting symbols which I will never use, but which are being loaded anyway.
So, my reasoning is that I should produce a new libstdc++, patching the stream classes to not use locale at all, and then to link this instead of the toolchain provided libstdc++. (I am very open to other suggestions to avoid this approach -- I did investigate uSTL but found the implementation too simplistic, and needed the full std:: streams/rdbuf interface.)
However, let's say that I need to reproduce the libstdc++-psram-workaround.a binary that is contained in esp-idf... how would I do that? A total guess is to copy the upstream gcc/libstdc++-v3/**/*.cc files into a new component in my app, with the following flags in component.mk:
Is that all that is necessary? Any other suggestions, or if other people have run into this situation before? I suppose I could avoid the STL, but I'm not aware of a good replacement for std::*streams. Thanks for your advice!
Merely instantiating a std::stringstream does this, and investigation of the map file reveals that a lot of that is related to pulling in locale and formatting symbols which I will never use, but which are being loaded anyway.
So, my reasoning is that I should produce a new libstdc++, patching the stream classes to not use locale at all, and then to link this instead of the toolchain provided libstdc++. (I am very open to other suggestions to avoid this approach -- I did investigate uSTL but found the implementation too simplistic, and needed the full std:: streams/rdbuf interface.)
However, let's say that I need to reproduce the libstdc++-psram-workaround.a binary that is contained in esp-idf... how would I do that? A total guess is to copy the upstream gcc/libstdc++-v3/**/*.cc files into a new component in my app, with the following flags in component.mk:
Code: Select all
CFLAGS+=-mfix-esp32-psram-cache-issue
CXXFLAGS+=-mfix-esp32-psram-cache-issue
LDFLAGS:=$(filter-out -lstdc++,$(LDFLAGS))