Newlib v2.5.0 and LibC++ locale support

I am in the process of updating from using Newlib v2.2.0-20150423 for our common C library with LLVM to v2.5.0 and this is breaking LibC++. Both LibC++ v3.9 and what is currently at head are affected.

There are some general problems with Locales, and in particular the definition of the type ‘locale_t’ which is defined in Newlib’s ‘sys/_locale.h’ as:

typedef struct __locale_t *locale_t;

and in LibC++’s ‘support/xlocale/__nop_locale_mgmt.h’ as:

typedef void *locale_t;

But it is also running into another problem with ‘vasprintf’. In LibC++ this is referenced in ‘__bsd_locale_fallbacks.h’, but ‘vasprintf’ is not an ISO C function, and the newer version of Newlib has the declaration in ‘<stdio.h>’ guarded with ‘__GNU_VISIBLE’ to keep it out of the global namespace, thus:


int _EXFUN(asprintf, (char **__restrict, const char *__restrict, …)

_ATTRIBUTE ((format (printf, 2, 3))));

int _EXFUN(vasprintf, (char **, const char *, __VALIST)

_ATTRIBUTE ((format (printf, 2, 0))));


I don’t know which version of Newlib changed the declaration of ‘vasprintf’, but the current LibC++ does not seem to handle the change. Should I be building LibC++ with ‘__GNU_VISIBLE’ defined? Any recommendations for how I should resolve the multiple definition of ‘locale_t’?