efriedma added a comment.

In D144889#4156120 <https://reviews.llvm.org/D144889#4156120>, @bcraig wrote:

> A freestanding implementation doesn't necessarily mean that everything is 
> header-only.  It's fine to require linking against a (freestanding) C runtime 
> library.  All header-only is fine too though, if you want to make that work.
>
> Architecturally, I don't feel it is required that Clang be the location of 
> all the freestanding headers for C.  I think that's fine for the C library in 
> the final toolchain to own those headers.  I'm not super familiar with what 
> interface contracts you have between the clang-provided C headers and the 
> C-library provided C headers though.

In practice, there are basically three ways people can use clang:

1. A normal operating system target with a "hosted" libc.
2. A baremetal target with an "embedded" libc; basically a stripped down libc 
which only includes stuff that doesn't require an operating system.  What 
exactly this includes varies; may include some form of "malloc", some "POSIX" 
APIs, semihosting, etc.
3. A baremetal target with no libc, using custom implementations for 
everything.  This is what we conventionally referred to as "freestanding", and 
what -ffreestanding implements.  The user provides memcpy/memmove/memset, and 
uses the compiler-provided "builtins" lib if neceessary, but nothing we would 
traditionally call "libc".

We could just refuse to provide any APIs outside of our conventional notion of 
"freestanding", I guess, and say users that want a C23 freestanding environment 
need to find their own mini-libc. Or just provide the header, and say users are 
responsible for providing implementations, like they currently are for memcpy 
etc.  That doesn't really align with what the committee was hoping for, 
though...

Maybe eventually we can come up with some way to use implementations provided 
by LLVM libc, but I'm not sure what exactly that looks like.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144889/new/

https://reviews.llvm.org/D144889

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to