Lines Matching +full:libc +full:- +full:build

4 Full Host Build
16 In this document, we will present a recipe to build the full libc for the host.
17 When we say *build the libc for the host*, the goal is to build the libc for
18 the same system on which the libc is being built. First, we will explain how to
19 build for developing LLVM-libc, then we will explain how to build LLVM-libc as
22 Configure the build for development
26 Below is the list of commands for a simple recipe to build LLVM-libc for
27 development. In this we've set the Ninja generator, set the build type to
28 "Debug", and enabled the Scudo allocator. This build also enables generating the
32 if your build fails with an error saying the compiler can't find
35 ``gcc-multilib`` package creates this symlink, or you can do it manually with
37 ``sudo ln -s /usr/include/<HOST TRIPLE>/asm /usr/include/asm``
38 (your host triple will probably be similar to ``x86_64-linux-gnu``)
40 .. code-block:: sh
42 $> cd llvm-project # The llvm-project checkout
43 $> mkdir build
44 $> cd build
46 -G Ninja \
47 -DCMAKE_C_COMPILER=clang \
48 -DCMAKE_CXX_COMPILER=clang++ \
49 -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \
50 -DLLVM_LIBC_FULL_BUILD=ON \
51 -DCMAKE_BUILD_TYPE=Debug \
52 -DLLVM_LIBC_INCLUDE_SCUDO=ON \
53 -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
54 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
55 -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
56 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
57 -DLLVM_ENABLE_SPHINX=ON -DLIBC_INCLUDE_DOCS=ON \
58 -DLIBC_CMAKE_VERBOSE_LOGGING=ON
60 Build and test
63 After configuring the build with the above ``cmake`` command, one can build test
64 libc with the following command:
66 .. code-block:: sh
68 $> ninja libc libm check-libc
70 To build the docs run this command:
73 .. code-block:: sh
75 $> ninja docs-libc-html
79 .. code-block:: sh
81 $> ninja libc.test.src.<HEADER>.<FUNCTION>_test.__unit__
82 $> ninja libc.test.src.ctype.isalpha_test.__unit__ # EXAMPLE
84 Configure the complete toolchain build
88 of the ``--sysroot`` option here:
89 `<https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html>`_) which includes
90 not only the components of LLVM's libc, but also a full LLVM only toolchain
93 `compiler-rt <https://compiler-rt.llvm.org/>`_ runtime libraries. LLVM-libc is
95 a C++ standard library (like libc++). Hence, we do not include
96 `libc++ <https://libcxx.llvm.org/>`_ in the sysroot.
98 .. note:: When the libc is complete enough, we should be able to include
99 `libc++ <https://libcxx.llvm.org/>`_, libcxx-abi and libunwind in the
100 LLVM only toolchain and use them to build and link C++ applications.
102 Below is the cmake command for a bootstrapping build of LLVM. This will build
103 clang and lld with the current system's toolchain, then build compiler-rt and
104 LLVM-libc with that freshly built clang. This ensures that LLVM-libc can take
107 This build also uses Ninja as cmake's generator, and sets lld and compiler-rt as
108 the default for the fresh clang. Those settings are recommended, but the build
109 should still work without them. The compiler-rt options are required for
111 allocator for LLVM-libc.
114 if your build fails with an error saying the compiler can't find
117 ``gcc-multilib`` package creates this symlink, or you can do it manually with
119 ``sudo ln -s /usr/include/<TARGET TRIPLE>/asm /usr/include/asm``
121 .. code-block:: sh
123 $> cd llvm-project # The llvm-project checkout
124 $> mkdir build
125 $> cd build
128 -G Ninja \
129 -DLLVM_ENABLE_PROJECTS="clang;lld" \
130 -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \
131 -DCMAKE_BUILD_TYPE=Release \
132 -DCMAKE_C_COMPILER=clang \
133 -DCMAKE_CXX_COMPILER=clang++ \
134 -DLLVM_LIBC_FULL_BUILD=ON \
135 -DLLVM_LIBC_INCLUDE_SCUDO=ON \
136 -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
137 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
138 -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF \
139 -DCLANG_DEFAULT_LINKER=lld \
140 -DCLANG_DEFAULT_RTLIB=compiler-rt \
141 -DCMAKE_INSTALL_PREFIX=$SYSROOT
143 Build and install
150 just trying to develop libc, then just run ``ninja check-libc`` to build the
151 libc and run the tests. If you've already accidentally installed the headers,
154 After configuring the build with the above ``cmake`` command, one can build and
157 .. code-block:: sh
159 $> ninja install-clang install-builtins install-compiler-rt \
160 install-core-resource-headers install-libc install-lld
164 .. code-block:: sh
169 have specified with the CMake configure step above will contain a full LLVM-only
170 toolchain with which you can build practical/real-world C applications. See
171 `<https://github.com/llvm/llvm-project/tree/main/libc/examples>`_ for examples
177 If you are using the full libc on Linux, then you will also need to install
178 Linux headers in your sysroot. Let's build them from source.
180 .. code-block:: sh
182 $> git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git /tmp/linux
183 $> make LLVM=1 INSTALL_HDR_PATH=/path/to/sysroot -C /tmp/linux headers_install
185 The headers can be built to target non-host architectures by adding the
188 Using your newly built libc
191 You can now use your newly built libc nearly like you would use any compiler
194 .. code-block:: sh
196 $> /path/to/sysroot/bin/clang -static main.c
199 Because the libc does not yet support dynamic linking, the -static parameter
207 .. code-block:: C
209 // $ $SYSROOT/bin/clang example.c -static -ffixed-point --sysroot=$SYSROOT