xref: /aosp_15_r20/external/clang/cmake/caches/README.txt (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin LiCMake Caches
2*67e74705SXin Li============
3*67e74705SXin Li
4*67e74705SXin LiThis directory contains CMake cache scripts that pre-populate the CMakeCache in
5*67e74705SXin Lia build directory with commonly used settings.
6*67e74705SXin Li
7*67e74705SXin LiYou can use the caches files with the following CMake invocation:
8*67e74705SXin Li
9*67e74705SXin Licmake -G <build system>
10*67e74705SXin Li  -C <path to cache file>
11*67e74705SXin Li  [additional CMake options (i.e. -DCMAKE_INSTALL_PREFIX=<install path>)]
12*67e74705SXin Li  <path to llvm>
13*67e74705SXin Li
14*67e74705SXin LiOptions specified on the command line will override options in the cache files.
15*67e74705SXin Li
16*67e74705SXin LiThe following cache files exist.
17*67e74705SXin Li
18*67e74705SXin LiApple-stage1
19*67e74705SXin Li------------
20*67e74705SXin Li
21*67e74705SXin LiThe Apple stage1 cache configures a two stage build similar to how Apple builds
22*67e74705SXin Lithe clang shipped with Xcode. The build files generated from this invocation has
23*67e74705SXin Lia target named "stage2" which performs an LTO build of clang.
24*67e74705SXin Li
25*67e74705SXin LiThe Apple-stage2 cache can be used directly to match the build settings Apple
26*67e74705SXin Liuses in shipping builds without doing a full bootstrap build.
27*67e74705SXin Li
28*67e74705SXin LiPGO
29*67e74705SXin Li---
30*67e74705SXin Li
31*67e74705SXin LiThe PGO CMake cache can be used to generate a multi-stage instrumented compiler.
32*67e74705SXin LiYou can configure your build directory with the following invocation of CMake:
33*67e74705SXin Li
34*67e74705SXin Licmake -G <generator> -C <path_to_clang>/cmake/caches/PGO.cmake <source dir>
35*67e74705SXin Li
36*67e74705SXin LiAfter configuration the following additional targets will be generated:
37*67e74705SXin Li
38*67e74705SXin Listage2-instrumented:
39*67e74705SXin LiBuilds a stage1 x86 compiler, runtime, and required tools (llvm-config,
40*67e74705SXin Lillvm-profdata) then uses that compiler to build an instrumented stage2 compiler.
41*67e74705SXin Li
42*67e74705SXin Listage2-instrumented-generate-profdata:
43*67e74705SXin LiDepends on "stage2-instrumented" and will use the instrumented compiler to
44*67e74705SXin Ligenerate profdata based on the training files in <clang>/utils/perf-training
45*67e74705SXin Li
46*67e74705SXin Listage2:
47*67e74705SXin LiDepends on "stage2-instrumented-generate-profdata" and will use the stage1
48*67e74705SXin Licompiler with the stage2 profdata to build a PGO-optimized compiler.
49*67e74705SXin Li
50*67e74705SXin Listage2-check-llvm:
51*67e74705SXin LiDepends on stage2 and runs check-llvm using the stage3 compiler.
52*67e74705SXin Li
53*67e74705SXin Listage2-check-clang:
54*67e74705SXin LiDepends on stage2 and runs check-clang using the stage3 compiler.
55*67e74705SXin Li
56*67e74705SXin Listage2-check-all:
57*67e74705SXin LiDepends on stage2 and runs check-all using the stage3 compiler.
58*67e74705SXin Li
59*67e74705SXin Listage2-test-suite:
60*67e74705SXin LiDepends on stage2 and runs the test-suite using the stage3 compiler (requires
61*67e74705SXin Liin-tree test-suite).
62*67e74705SXin Li
63*67e74705SXin Li3-stage
64*67e74705SXin Li-------
65*67e74705SXin Li
66*67e74705SXin LiThis cache file can be used to generate a 3-stage clang build. You can configure
67*67e74705SXin Liusing the following CMake command:
68*67e74705SXin Li
69*67e74705SXin Licmake -C <path to clang>/cmake/caches/3-stage.cmake -G Ninja <path to llvm>
70*67e74705SXin Li
71*67e74705SXin LiYou can then run "ninja stage3-clang" to build stage1, stage2 and stage3 clangs.
72*67e74705SXin Li
73*67e74705SXin LiThis is useful for finding non-determinism the compiler by verifying that stage2
74*67e74705SXin Liand stage3 are identical.
75