[cfe-dev] [libc++] Porting libc++ to embedded targets/compilers

David Chisnall via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 13 09:10:52 PDT 2017


On 13 Sep 2017, at 17:01, Jonathan Roelofs <jonathan at codesourcery.com> wrote:
> 
> On 9/13/17 2:12 AM, David Chisnall via cfe-dev wrote:
>> The C++11 locale support is designed to be a thin wrapper around POSIX2008 locales.  These are pretty heavy and likely not to be useful in an embedded target, where you’d only want to support the C locale (std::locale::classic).  In this case, all of these would be compiled away.  I don’t think we have such a fallback implementation, but a trivial one should be easy to write.
> 
> Assuming we're talking about the same thing, there's one in: `include/support/xlocale/__posix_l_fallback.h`. That's included, for example, by: `include/support/newlib/xlocale.h`

That provides implementations that ignore the std::locale, which is half of what you want.  The other half is to provide a std::locale implementation where all of the method bodies are almost empty and where `locale(const char*)` and `locale(const string&)` always throw, so that the compiler can optimise away any uses of `std::locale` entirely (you don’t want to be carrying around a big structure that’s never used on an embedded target).

David




More information about the cfe-dev mailing list