[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
Wed Mar 26 14:17:04 PDT 2025
domin144 wrote:
This looks good except for `__linux__`. Picolibc is mainly for bare metal, so the `__linux__` define will not be there. Removing `__linux__` should get the tests passing.
Currently the tests do have explicit `-include <picolibc.h>` in their commandline, but they link against the prebuilt specializations (`libcxx/src/ios.instantiations.cpp`), which have been compiled in the library build step (not test build step) and at that step the flag was not added. (At least this is how I *think* it works).
> Plus, as I said earlier, I don't think that patch is really the right thing to do.
It's hard for me to judge. I think it's better than relying on users for including `picolibc.h` (or some C header) before including libcxx.
Alternatively, one of below could be done:
- detect picolibc during cmake configure step and record this in `__config_site`
- when compiling libc++ against picolibc add some option to the cmake commadline (like `-D LIBCXX_EXTRA_SITE_DEFINES=_LIBCPP_INCLUDE_PICOLIBC_H` or `-D LIBCXX_EXTRA_SITE_DEFINES=_LIBCPP_STREAMOFF_IS_DOUBLE`)
after that one of these can be done:
- include `picolibc.h` (e.g. in `platform.h` as you did) only if `__config_site` has the define added above,
- don't include `picolibc.h` at all and use the config from `__config_site` directly instead of `_NEWLIB_VERSION`
These are poorly informed ideas - I am new to the libc++ configuration.
https://github.com/llvm/llvm-project/pull/131921
More information about the libcxx-commits
mailing list