|
| 1 | +Building libc using the runtimes build setup |
| 2 | +============================================ |
| 3 | + |
| 4 | +The runtimes build of the LLVM toolchain first builds clang and then builds the |
| 5 | +various runtimes (like ``libc++`` and ``compiler-rt``) and LLVM binutils (like |
| 6 | +``llvm-objcopy`` and ``llvm-readelf``) using the freshly built clang. One can |
| 7 | +build libc also as in the same manner. As of this writing, only the ABI agnostic |
| 8 | +parts of the libc are included when built in that manner. This allows interested |
| 9 | +users to continue using their system libc's headers while linking to LLVM libc's |
| 10 | +implementations when they are available. To build libc using the runtimes build |
| 11 | +setup, one needs to include the ``libc`` project in the list of the enabled |
| 12 | +runtimes when configuring the build: |
| 13 | + |
| 14 | +.. code-block:: shell |
| 15 | +
|
| 16 | + $> cmake ../llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang" \ |
| 17 | + -DLLVM_ENABLE_RUNTIMES=libc |
| 18 | +
|
| 19 | +Note that Ninja is used as the generator in the above CMake command. Hence, to |
| 20 | +actually build the libc, one has to build the Ninja target named ``llvmlibc``: |
| 21 | + |
| 22 | +.. code-block:: shell |
| 23 | +
|
| 24 | + $> ninja llvmlibc |
| 25 | +
|
| 26 | +If a different generator is used, then the build command should be suitably |
| 27 | +adapted to build the target ``llvmlibc``. Building that target will produce a |
| 28 | +static archive which includes all ABI agnostic functions available in LLVM libc. |
| 29 | + |
| 30 | +Future direction |
| 31 | +---------------- |
| 32 | + |
| 33 | +We plan to enhance the runtimes build of LLVM libc to include ABI sensitive |
| 34 | +parts and to also generate the public headers. Likewise, we would like to |
| 35 | +provide an option to build other runtimes like ``libc++`` and ``compiler-rt`` |
| 36 | +against LLVM libc. |
0 commit comments