Lines Matching +full:ninja +full:- +full:build

14 This document will present recipes to build the LLVM C library targeting a GPU
15 architecture. The GPU build uses the same :ref:`cross build<full_cross_build>`
17 it *must* be built with an up-to-date ``clang`` compiler. This is because the
21 ``nvptx64-nvidia-cuda`` for NVIDIA GPUs or ``amdgcn-amd-amdhsa`` for AMD GPUs.
22 Targeting these architectures is done through ``clang``'s cross-compiling
23 support using the ``--target=<triple>`` flag. The following sections will
24 describe how to build the GPU support specifically.
29 Standard runtimes build
30 -----------------------
32 The simplest way to build the GPU libc is to use the existing LLVM runtimes
33 support. This will automatically handle bootstrapping an up-to-date ``clang``
34 compiler and using it to build the C library. The following CMake invocation
35 will instruct it to build the ``libc`` runtime targeting both AMD and NVIDIA
39 .. code-block:: sh
41 $> cd llvm-project # The llvm-project checkout
42 $> mkdir build
43 $> cd build
44 $> cmake ../llvm -G Ninja \
45 -DLLVM_ENABLE_PROJECTS="clang;lld" \
46 -DLLVM_ENABLE_RUNTIMES="openmp" \
47 -DCMAKE_BUILD_TYPE=<Debug|Release> \ # Select build type
48 -DCMAKE_INSTALL_PREFIX=<PATH> \ # Where the libraries will live
49 -DRUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES=libc \
50 -DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=libc \
51 -DLLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda"
52 $> ninja install
54 We need ``clang`` to build the GPU C library and ``lld`` to link AMDGPU
59 targets to build, in this case we want the default target and the GPU targets.
60 Note that if ``libc`` were included in ``LLVM_ENABLE_RUNTIMES`` it would build
62 your build towards the ``libc/cmake/caches/gpu.cmake`` cache file with ``-C``.
64 Runtimes cross build
65 --------------------
67 For users wanting more direct control over the build process, the build steps
68 can be done manually instead. This build closely follows the instructions in the
70 build. We follow the same steps to first build the libc tools and a suitable
71 compiler. These tools must all be up-to-date with the libc source.
73 .. code-block:: sh
75 $> cd llvm-project # The llvm-project checkout
76 $> mkdir build-libc-tools # A different build directory for the build tools
77 $> cd build-libc-tools
81 -G Ninja \
82 -DLLVM_ENABLE_PROJECTS="clang" \
83 -DCMAKE_C_COMPILER=$HOST_C_COMPILER \
84 -DCMAKE_CXX_COMPILER=$HOST_CXX_COMPILER \
85 -DLLVM_LIBC_FULL_BUILD=ON \
86 -DCMAKE_BUILD_TYPE=Release # Release suggested to make "clang" fast
87 $> ninja # Build the 'clang' compiler
89 Once this has finished the build directory should contain the ``clang``
90 compiler executable. We will use the ``clang`` compiler to build the GPU code.
91 We use these tools to bootstrap the build out of the runtimes directory
94 .. code-block:: sh
96 $> cd llvm-project # The llvm-project checkout
97 $> mkdir build # A different build directory for the build tools
98 $> cd build
99 $> TARGET_TRIPLE=<amdgcn-amd-amdhsa or nvptx64-nvidia-cuda>
102 $> cmake ../runtimes \ # Point to the runtimes build
103 -G Ninja \
104 -DLLVM_ENABLE_RUNTIMES=libc \
105 -DCMAKE_C_COMPILER=$TARGET_C_COMPILER \
106 -DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \
107 -DLLVM_LIBC_FULL_BUILD=ON \
108 -DLLVM_RUNTIMES_TARGET=$TARGET_TRIPLE \
109 -DCMAKE_BUILD_TYPE=Release
110 $> ninja install
112 The above steps will result in a build targeting one of the supported GPU
116 Standalone cross build
117 ----------------------
119 The GPU build can also be targeted directly as long as the compiler used is a
123 .. code-block:: sh
125 $> cd llvm-project # The llvm-project checkout
126 $> mkdir build # A different build directory for the build tools
127 $> cd build
128 $> CLANG_C_COMPILER=</path/to/clang> # Must be a trunk build
129 $> CLANG_CXX_COMPILER=</path/to/clang++> # Must be a trunk build
130 $> TARGET_TRIPLE=<amdgcn-amd-amdhsa or nvptx64-nvidia-cuda>
132 -G Ninja \
133 -DLLVM_ENABLE_PROJECTS=libc \
134 -DCMAKE_C_COMPILER=$CLANG_C_COMPILER \
135 -DCMAKE_CXX_COMPILER=$CLANG_CXX_COMPILER \
136 -DLLVM_LIBC_FULL_BUILD=ON \
137 -DLIBC_TARGET_TRIPLE=$TARGET_TRIPLE \
138 -DCMAKE_BUILD_TYPE=Release
139 $> ninja install
141 This will build and install the GPU C library along with all the other LLVM
144 Build overview
147 Once installed, the GPU build will create several files used for different
150 **include/<target-triple>**
154 **lib/clang/<llvm-major-version>/include/llvm-libc-wrappers/llvm-libc-decls**
160 **lib/<target-triple>/libc.a**
161 The main C library static archive containing LLVM-IR targeting the given GPU.
164 **lib/<target-triple>/libm.a**
168 **lib/<target-triple>/libc.bc**
169 An alternate form of the library provided as a single LLVM-IR bitcode blob.
172 **lib/<target-triple>/libm.bc**
173 An alternate form of the library provided as a single LLVM-IR bitcode blob
176 **lib/<target-triple>/crt1.o**
177 An LLVM-IR file containing startup code to call the ``main`` function on the
180 **bin/amdhsa-loader**
182 This will be included if the build system found the ``hsa-runtime64`` library
184 required to build the GPU tests .See the :ref:`libc GPU usage<libc_gpu_usage>`
187 **bin/nvptx-loader**
189 This will be included if the build system found the CUDA driver API. This is
192 **include/llvm-libc-rpc-server.h**
207 control the GPU build of the C library. These options can be passed individually
208 to each target using ``-DRUNTIMES_<target>_<variable>=<value>`` when using a
209 standard runtime build.
212 This flag controls whether or not the libc build will generate its own
220 Sets the architecture used to build the GPU tests for, such as ``gfx90a`` or