[llvm-dev] A libc in LLVM
Siva Chandra via llvm-dev
llvm-dev at lists.llvm.org
Fri Jul 12 08:15:40 PDT 2019
On Fri, Jun 28, 2019 at 9:29 AM JF Bastien <jfbastien at apple.com> wrote:
> I think I now understand some of the disconnect you and I are having, and I think some of the pushback you’re getting from the community is the same. You’re talking about where you want to start with an LLVM libc. Many in the community (myself included) want to understand where we’ll get with this libc. At steady-state, what does it do? To a certain degree I don’t care about how you get to the steady state: sure the implementation approach is important, and which contributor cares about what parts is important in shaping that evolution, but at the end of the day what matters is where you get.
> So here’s what’s missing: there’s no goal. Right now, your proposal is “let’s do an LLVM libc, starting with what I care about, who’s interested?”
> That’s an OK place to start! You illustrated your needs, others chimed in with theirs, and now you know there’s some interest. However, you should take time now to come up with a plan. What’s this libc actually going to be? I ask a bunch of questions below that I think you need to answer as a next step. Others asked more questions which I didn’t echo, but which you should answer as well. What does this libc aspire to become?
I apologize for the delay. I will try to address the above questions
in this email. I will shortly follow up with answers to other
Below is a write up which I think would qualify as the "charter" for
the new libc. It is also answering questions like, "where we’ll get
with this libc?", "what's this libc actually going to be?" and similar
ones. I have used libcxx.llvm.org landing page as a template to write
"llvm-libc" C Standard Library
llvm-libc is an implementation of the C standard library targeting C11
and above. It also provides platform specific extensions as relevant.
For example, on Linux it also provides pthreads, librt and other POSIX
The llvm-libc project is still in the planning phase. Stay tuned for
Features and Goals
* C11 and upwards conformant.
* A modular libc with individual pieces implemented in the "as a
library" philosophy of the LLVM project.
* Ability to layer this libc over the system libc.
* Provide C symbols as specified by the standards, but take advantage
and use C++ language facilities for the core implementation.
* Provides POSIX extensions on POSIX compliant platforms.
* Provides system-specific extensions as appropriate. For example,
provides the Linux API on Linux.
* Vendor extensions if and only if necessary.
* Designed and developed from the start to work with LLVM tooling and
testing like fuzz testing and sanitizer-supported testing.
* ABI independent implementation as far as possible.
* Use source based implementations as far possible rather than
assembly. Will try to “fix” the compiler rather than use assembly
Why a new C Standard Library?
Implementing a libc is no small task and is not be taken lightly. A
natural question to ask is, "why a new implementation of the C
standard library?" There is no single answer to this question, but
some of the major reasons are as follows:
* Most libc implementations are monolithic. It is a non-trivial
porting task to pick and choose only the pieces relevant to one's
platform. The new libc will be developed with sufficient modularity to
make picking and choosing a straightforward task.
* Most libc implementations break when built with sanitizer specific
compiler options. The new libc will be developed from the start to
work with those specialized compiler options.
* The new libc will be developed to support and employ fuzz testing
from the start.
* Most libc implementations use a good amount of assembly language,
and assume specific ABIs (may be platform dependent). With the new
libc implementation, we want to use normal source code as much as
possible so that compiler-based changes to the ABI are easy. Moreover,
as part of the LLVM project, we want to use this opportunity to fix
performance related compiler bugs rather than using assembly
* A large hole in the llvm toolchain will be plugged with this new
libc. With the broad platform expertise in the LLVM community, and the
strong license and project structure, we think that the new libc will
be more tunable and robust, without sacrificing the simplicity and
accessibility typical of the LLVM project.
llvm-libc development is still in the planning phase. However, we
envision that it will support a variety of platforms in the coming
years. Interested parties are encouraged to participate in the design
and implementation, and add support for their favorite platforms.
llvm-libc development is still in the planning phase.
First please review our Developer's Policy. Stay tuned for llvm-libc
More information about the llvm-dev