1Getting Started 2=============== 3 4Let's fetch the llvm-libc sources and build them. 5 6Install dependencies first: 7 8.. code-block:: sh 9 10 $ sudo apt update 11 $ sudo apt install git cmake ninja-build clang gcc-multilib 12 13.. code-block:: sh 14 15 $ git clone --depth=1 git@github.com:llvm/llvm-project.git /tmp/llvm-project 16 $ mkdir /tmp/llvm-project/build 17 $ cd /tmp/llvm-project/build 18 $ cmake ../runtimes -GNinja \ 19 -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" \ 20 -DCMAKE_BUILD_TYPE=Debug \ 21 -DCMAKE_CXX_COMPILER=clang++ \ 22 -DCMAKE_C_COMPILER=clang \ 23 -DLLVM_LIBC_FULL_BUILD=ON \ 24 -DLLVM_LIBC_INCLUDE_SCUDO=ON \ 25 -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \ 26 -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \ 27 -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF 28 $ ninja libc libm 29 30This will produce the following artifacts: 31 32.. code-block:: 33 34 llvm-project/build/libc/lib/libc.a 35 llvm-project/build/libc/lib/libm.a 36 llvm-project/build/libc/startup/linux/crt1.o 37 llvm-project/build/libc/include/**.h 38 39We can then compile and run hello world via: 40 41.. code-block:: c++ 42 43 // hello.c 44 #include <stdio.h> 45 int main () { puts("hello world"); } 46 47.. code-block:: sh 48 49 $ clang -nostdinc -nostdlib hello.c -I libc/include \ 50 -I $(clang -print-resource-dir)/include libc/startup/linux/crt1.o \ 51 libc/lib/libc.a 52 $ ./a.out 53 hello world 54 55This was what we call a "full build" of llvm-libc. From here, you can visit 56:ref:`full_host_build` for more info, :ref:`full_cross_build` for cross 57compiling, :ref:`overlay_mode` for mixing llvm-libc with another libc, or 58:ref:`libc_gpu` for targeting GPUs. 59