Existing code in libc++ uses _NEWLIB_VERSION to check for the presence
of newlib. But this macro is only set when a library header has been
included before that brings in its definition. In some cases, this macro
can't be used as a library header has not been included before it use.
This patch adds a CMake variable and corresponding macro that is used
to check for the presence of newlib in the following 2 cases:
- The __config header is the generally the first header included. So
_NEWLIB_VERSION used in it will not be set. We check for
_LIBCPP_HAS_NEWLIB_LIBC and include newlib.h that will make sure that
_NEWLIB_VERSION is correctly defined.
- The nasty_macros.h also has similar issue so _NEWLIB_VERSION can't be
used in it. We check for _LIBCPP_HAS_NEWLIB_LIBC to stub out a
problematic macro for newlib.
The new variable for newlib is quite similar to existing variable for MUSL.