brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 9d846e6 Raw
59 lines · plain
1Getting Started2===============3 4Let's fetch the llvm-libc sources and build them.5 6Install dependencies first:7 8.. code-block:: sh9 10  $ sudo apt update11  $ sudo apt install git cmake ninja-build clang gcc-multilib12 13.. code-block:: sh14 15  $ git clone --depth=1 git@github.com:llvm/llvm-project.git /tmp/llvm-project16  $ mkdir /tmp/llvm-project/build17  $ cd /tmp/llvm-project/build18  $ 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=OFF28  $ ninja libc libm29 30This will produce the following artifacts:31 32.. code-block::33 34  llvm-project/build/libc/lib/libc.a35  llvm-project/build/libc/lib/libm.a36  llvm-project/build/libc/startup/linux/crt1.o37  llvm-project/build/libc/include/**.h38 39We can then compile and run hello world via:40 41.. code-block:: c++42 43  // hello.c44  #include <stdio.h>45  int main () { puts("hello world"); }46 47.. code-block:: sh48 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.a52   $ ./a.out53   hello world54 55This was what we call a "full build" of llvm-libc. From here, you can visit56:ref:`full_host_build` for more info, :ref:`full_cross_build` for cross57compiling, :ref:`overlay_mode` for mixing llvm-libc with another libc,58:ref:`libc_gpu` for targeting GPUs, or :ref:`libc_uefi` for targeting UEFI.59