[libc-dev] API generation

David Chisnall via libc-dev libc-dev at lists.llvm.org
Wed Nov 20 02:38:53 PST 2019

On 19/11/2019 21:49, Siva Chandra via libc-dev wrote:
> 2. For developers putting together a libc for their platform: Instead
> of adding inclusion and exclusion macros to header files, they merely
> write a config for their platform, like the "config/linux/api.td" file
> in the above patch.

I want to highlight this point.  Most libc implementations are quite 
closely tied to a particular platform.  Those that are less OS-specific 
(glibc and musl come to mind) ship with a lot of their own scaffolding 
and are difficult to subset.

LLVM as a whole aims to provide a kit of parts for assembling a 
toolchain.  Clang is expected to work with different C++ standard 
library implementations, libc++ is expected to work with different C and 
C++ runtime libraries and different C standard implementations.  The 
philosophy behind the LLVM libc is similar: some people will use a 
fairly stock configuration, just as some people use clang + libc++ + 
libc++abi + compiler-rt, others will want to use just a subset.

Embedded platforms, minimal-TCB environments and sandboxed environments 
all want to be able to ship the smallest subset of libc that enables 
their specific workload.  This will rarely be the same small subset.

We need to be able to both carefully layer the internal implementation 
to avoid cross-dependencies (try compiling libc++ without iostream to 
see how difficult this is if you try to add it later) and define subsets 
of the public ABI.  The goal for the header generation is to automate 
the second part and help with tooling for checking the first.


More information about the libc-dev mailing list