7 .. contents:: Table of Contents
11 In this document, we will present a recipe to cross build a full libc. When we
12 say *cross build* a full libc, we mean that we will build the libc for a target
13 system which is not the same as the system on which the libc is being built.
14 For example, you could be building for a bare metal aarch64 *target* on a Linux
17 Configure the full cross build of the libc
18 ==========================================
20 Below is a simple recipe to configure the libc for a cross build.
24 $> cd llvm-project # The llvm-project checkout
28 -G Ninja \ # Generator
29 -DLLVM_ENABLE_PROJECTS=libc \ # Enable the libc project
30 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
31 -DLLVM_LIBC_FULL_BUILD=ON \ # We are building the full libc
32 -DLIBC_TARGET_TRIPLE=<Your target triple>
34 We will go over the special options passed to the ``cmake`` command above.
36 * **Enabled Projects** - Since we want to build the libc project, we list
37 ``libc`` as the enabled project.
38 * **The full build option** - Since we want to build the full libc, we pass
39 ``-DLLVM_LIBC_FULL_BUILD=ON``.
40 * **The target triple** - This is the target triple of the target for which
41 we are building the libc. For example, for a Linux 32-bit Arm target,
42 one can specify it as ``arm-linux-eabi``.
47 After configuring the build with the above ``cmake`` command, one can build the
48 the libc for the target with the following command:
54 The above ``ninja`` command will build the ``libc.a`` static archive for the
55 target specified with ``-DLIBC_TARGET_TRIPLE`` to the ``cmake`` command.
57 Building for bare metal
58 =======================
60 To build for bare metal, all one has to do is to specify the
61 `system <https://clang.llvm.org/docs/CrossCompilation.html#target-triple>`_
62 component of the target triple as ``none``. For example, to build for a
63 32-bit arm target on bare metal, one can use a target triple like