Lines Matching +full:runs +full:- +full:on
11 `CMake <http://www.cmake.org/>`_ is a cross-platform build-generator tool. CMake
22 Many of the build configurations mentioned on this documentation page can be
26 can be passed to CMake using the :code:`-C` flag as demonstrated in the examples
32 The Clang CMake build system supports bootstrap (aka multi-stage) builds. At a
33 high level a multi-stage build is a chain of builds that pass data from one
37 In a simple two-stage bootstrap build, we build clang using the system compiler,
38 then use that just-built clang to build clang again. In CMake this simplest form
42 .. code-block:: console
44 $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
45 -DCLANG_ENABLE_BOOTSTRAP=On \
46 -DLLVM_ENABLE_PROJECTS="clang" \
56 To force the passing of the variables between stages, use the -DCLANG_BOOTSTRAP_PASSTHROUGH
59 .. code-block:: console
61 $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
62 -DCLANG_ENABLE_BOOTSTRAP=On \
63 -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE" \
64 -DLLVM_ENABLE_PROJECTS="clang" \
70 For example, the following CMake call will enabled '-fno-addrsig' only during
73 .. code-block:: console
75 …$ cmake [..] -DBOOTSTRAP_CMAKE_CXX_FLAGS='-fno-addrsig' -DBOOTSTRAP_CMAKE_C_FLAGS='-fno-addrsig' …
78 build using the compiler installed on the host, and a stage2 build is built
80 general a stage*n* build is built using the output from stage*n-1*.
86 bootstrapping scenario. Apple Clang is built using a 2-stage build.
88 The stage1 compiler is a host-only compiler with some options set. The stage1
96 .. code-block:: console
98 $ cmake -G Ninja -C <path to source>/clang/cmake/caches/Apple-stage1.cmake <path to source>/llvm
99 $ ninja stage2-distribution
102 CLANG_BOOTSTRAP_CMAKE_ARGS to pass the Apple-stage2.cmake cache script to the
105 When you build the stage2-distribution target it builds the minimal stage1
107 based on the settings in Apple-stage2.cmake.
113 Multi-stage PGO
116 Profile-Guided Optimizations (PGO) is a really great way to optimize the code
117 clang generates. Our multi-stage PGO builds are a workflow for generating PGO
122 instrumented compiler runs it will output a bunch of files containing
124 you use llvm-profdata to merge the files into a single profdata file that you
130 .. code-block:: console
132 $ cmake -G Ninja -C <path to source>/clang/cmake/caches/PGO.cmake \
142 .. code-block:: console
144 $ cmake -G Ninja -C <path to source>/clang/cmake/caches/PGO.cmake \
145 -DPGO_INSTRUMENT_LTO=Thin \
156 `LLVM Test Suite <https://github.com/llvm/llvm-test-suite/>`_ to generate
159 .. code-block:: console
161 $ cmake -G Ninja -C <path to source>/clang/cmake/caches/PGO.cmake \
162 -DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=<path to llvm-test-suite> \
163 -DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes
165 The BOOTSTRAP\_ prefixes tells CMake to pass the variables on to the instrumented
168 LLVM Test Suite requires compiler-rt to build, so we need to add the
171 After configuration, building the stage2-instrumented-generate-profdata target
176 .. code-block:: console
178 $ ninja stage2-instrumented-generate-profdata
182 and you *must* have compiler-rt in your build tree.
184 This process uses any source files under the perf-training directory as training
185 data as long as the source files are marked up with LIT-style RUN lines.
187 After it finishes you can use :code:`find . -name clang.profdata` to find it, but it
190 .. code-block:: console
192 <build dir>/tools/clang/stage2-instrumented-bins/utils/perf-training/clang.profdata
201 .. code-block:: cmake
206 multi-stage builds. It generates three stages: stage1, stage2-instrumented, and
211 **stage2-instrumented**
212 Builds a stage1 compiler, runtime, and required tools (llvm-config,
213 llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.
215 **stage2-instrumented-generate-profdata**
216 Depends on stage2-instrumented and will use the instrumented compiler to
217 generate profdata based on the training files in clang/utils/perf-training
220 Depends on stage2-instrumented-generate-profdata and will use the stage1
221 compiler with the stage2 profdata to build a PGO-optimized compiler.
223 **stage2-check-llvm**
224 Depends on stage2 and runs check-llvm using the stage2 compiler.
226 **stage2-check-clang**
227 Depends on stage2 and runs check-clang using the stage2 compiler.
229 **stage2-check-all**
230 Depends on stage2 and runs check-all using the stage2 compiler.
232 **stage2-test-suite**
233 Depends on stage2 and runs the test-suite using the stage2 compiler (requires
234 in-tree test-suite).
239 `BOLT <https://github.com/llvm/llvm-project/blob/main/bolt/README.md>`_
241 post-link by profiling them at runtime and then using that information to
246 To configure a single-stage build that builds LLVM/Clang and then optimizes
249 .. code-block:: console
251 $ cmake <path to source>/llvm -C <path to source>/clang/cmake/caches/BOLT.cmake
253 Then, build the BOLT-optimized binary by running the following ninja command:
255 .. code-block:: console
257 $ ninja clang-bolt
263 It is also possible to use BOLT on top of PGO and (Thin)LTO for an even more
268 .. code-block:: console
270 $ cmake -G Ninja <path to source>/llvm \
271 -C <path to source>/clang/cmake/caches/BOLT-PGO.cmake \
272 -DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
273 -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
274 -DPGO_INSTRUMENT_LTO=Thin
276 Then, to build the final optimized binary, build the stage2-clang-bolt target:
278 .. code-block:: console
280 $ ninja stage2-clang-bolt
282 3-Stage Non-Determinism
285 In the ancient lore of compilers non-determinism is like the multi-headed hydra.
293 this, you have a stage2 and stage3 compiler that should be bit-for-bit
296 You can perform one of these 3-stage builds with LLVM and clang using the
299 .. code-block:: console
301 $ cmake -G Ninja -C <path to source>/clang/cmake/caches/3-stage.cmake <path to source>/llvm