[libcxx-commits] [libcxx] [libc++] Guard additional headers with _LIBCPP_HAS_LOCALIZATION (PR #131921)

Dominik Wójt via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 25 14:50:17 PDT 2025


dominik-wojt-2311446 wrote:

I confirmed the hypothesis, by adding `#include <limits.h>` to `ios.h` before `_NEWLIB_VERSION` macro is checked. With this extra include the tests pass.

Other tests used to have the same problem and a workaround was introduced in _test_ config `armv7m-picolibc-libc++.cfg.in`:
```
config.substitutions.append(('%{compile_flags}',
   (...)
    # Various libc++ headers check for the definition of _NEWLIB_VERSION
    # which for picolibc is defined in picolibc.h.
    ' -include picolibc.h'
))
```

Now, as some specializations are compiled during build step a proper solution for build time (not just for test) is needed.
There is an option to extend flags in `run-buildbot`, but this would be another workaroud: we would be sure, that the flag is properly recognized during build and test, but user could still include the libc++ headers and miss the flag. 
```
function test-armv7m-picolibc() {
   (...)
    flags="--sysroot=${INSTALL_DIR} -include picolibc.h"
```

Adding `#include <limits.h>` (or some other c header, which includes `picolibc.h`) to `ios.h` and all other headers checking for `_NEWLIB_VERSION` would be a robust solution. We would need to accept, that all other targets are also affected though.

https://github.com/llvm/llvm-project/pull/131921


More information about the libcxx-commits mailing list