Re: ldionne
The contact surface discussed in the libc++ meeting was mostly focused on these sections:
Locale-free char/string functions (e.g. isdigit(x, _LIBCPP_GET_C_LOCALE)
)
Floating point conversion (to_chars/from_chars, strtof/strfromf)
Threading (pthreads, C11 threads)
Timezones
These are pieces that LLVM-libc and libc++ can share relatively easily, with some additional complexity around timezones. Having a C++ to C++ interface allows for a nicer interface, using things like optional
and stringref
instead of returning null or passing a pointer and length.
Where we place this code is still somewhat to be determined. I think eventually we will want a separate shared directory inside of llvm-project
, but to keep the proposal simple I have focused on code that exists in LLVM-libc and would be useful in libc++. For that code, placing it in libc/shared
should be fine, and that allows us to put off a major refactor of our libc/__support
directory.
For fallbacks in libc++, that’s ultimately up to you. I think that there are some places where you will still want to go through the public libc interface (e.g. math functions), but for places where we have a good internal API then we might not need a fallback.
Re: jyknight
My plan isn’t to replace the entire libc/libc++ contact surface with an internal API, this is more focused on places where libc and libc++ have a shared underlying goal (e.g. convert a string to a float) but incompatible interfaces (e.g. strtof vs from_chars). The decoupled nature of the C and C++ standards is exactly what causes this problem, and and my proposed solution is effectively coupling our libraries at a lower level so that it can be specialized for each public interface.
Re: mordante
Our compiler support is listed here: Compiler Support — The LLVM C Library
Currently we support Clang 11+ and GCC 12.2+, and I believe we use C++20, though I’m not entirely certain, and I’m not opposed to increasing the minimum required compiler/C++ version. We can discuss how to handle timezones, but I think having them as the first piece in a shared top level directory would work well. We would need it to be a build option to add it to our libc, at least at first, but requiring that for timezone support shouldn’t be a hard sell. Anyone who needs to touch timezones is advanced enough to flip some cmake switches.
As for sharing code without ODR violations, I think we’ll need to consider two cases:
- libc++ is being built on its own (and a different libc is used)
- LLVM-libc and libc++ are being built together
In case 1, we don’t need to worry about ODR at all. In case 2, the design I had been imagining would be to create a combined libc/libc++, though I think this is a good ways off. As a temporary measure, the LIBC_NAMESPACE
could be defined differently by LLVM-libc and libc++ to avoid ODR violations. Additionally the plan for the shared code is for it to be in a header-only library, so it should all be marked inline anyways.
Re: efriedma-quic
My plan for the start is to stick to a header only shared library included internally, so sharing the source code and building it twice. In the future I’d like to make a combined libc/libc++ library, but that’s not part of this proposal nor do I expect it to happen anytime soon.