|
1 | 1 | # Plain options configure the first build.
|
2 | 2 | # BOOTSTRAP_* options configure the second build.
|
3 | 3 | # BOOTSTRAP_BOOTSTRAP_* options configure the third build.
|
| 4 | +# PGO Builds have 3 stages (stage1, stage2-instrumented, stage2) |
| 5 | +# non-PGO Builds have 2 stages (stage1, stage2) |
4 | 6 |
|
5 |
| -# General Options |
| 7 | + |
| 8 | +function (set_final_stage_var name value type) |
| 9 | + if (LLVM_RELEASE_ENABLE_PGO) |
| 10 | + set(BOOTSTRAP_BOOTSTRAP_${name} ${value} CACHE ${type} "") |
| 11 | + else() |
| 12 | + set(BOOTSTRAP_${name} ${value} CACHE ${type} "") |
| 13 | + endif() |
| 14 | +endfunction() |
| 15 | + |
| 16 | +function (set_instrument_and_final_stage_var name value type) |
| 17 | + # This sets the varaible for the final stage in non-PGO builds and in |
| 18 | + # the stage2-instrumented stage for PGO builds. |
| 19 | + set(BOOTSTRAP_${name} ${value} CACHE ${type} "") |
| 20 | + if (LLVM_RELEASE_ENABLE_PGO) |
| 21 | + # Set the variable in the final stage for PGO builds. |
| 22 | + set(BOOTSTRAP_BOOTSTRAP_${name} ${value} CACHE ${type} "") |
| 23 | + endif() |
| 24 | +endfunction() |
| 25 | + |
| 26 | +# General Options: |
| 27 | +# If you want to override any of the LLVM_RELEASE_* variables you can set them |
| 28 | +# on the command line via -D, but you need to do this before you pass this |
| 29 | +# cache file to CMake via -C. e.g. |
| 30 | +# |
| 31 | +# cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake |
6 | 32 | set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
|
7 | 33 | set(LLVM_RELEASE_ENABLE_PGO OFF CACHE BOOL "")
|
8 |
| - |
| 34 | +set(LLVM_RELEASE_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") |
| 35 | +set(LLVM_RELEASE_ENABLE_PROJECTS "clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "") |
| 36 | +# Note we don't need to add install here, since it is one of the pre-defined |
| 37 | +# steps. |
| 38 | +set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "") |
9 | 39 | set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
|
10 | 40 |
|
11 |
| -# Stage 1 Bootstrap Setup |
| 41 | +# Stage 1 Options |
| 42 | +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") |
12 | 43 | set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
|
| 44 | + |
| 45 | +set(STAGE1_PROJECTS "clang") |
| 46 | +set(STAGE1_RUNTIMES "") |
| 47 | + |
13 | 48 | if (LLVM_RELEASE_ENABLE_PGO)
|
| 49 | + list(APPEND STAGE1_PROJECTS "lld") |
| 50 | + list(APPEND STAGE1_RUNTIMES "compiler-rt") |
14 | 51 | set(CLANG_BOOTSTRAP_TARGETS
|
15 | 52 | generate-profdata
|
16 |
| - stage2 |
17 | 53 | stage2-package
|
18 | 54 | stage2-clang
|
19 |
| - stage2-distribution |
20 | 55 | stage2-install
|
21 |
| - stage2-install-distribution |
22 |
| - stage2-install-distribution-toolchain |
23 | 56 | stage2-check-all
|
24 | 57 | stage2-check-llvm
|
25 |
| - stage2-check-clang |
26 |
| - stage2-test-suite CACHE STRING "") |
27 |
| -else() |
28 |
| - set(CLANG_BOOTSTRAP_TARGETS |
29 |
| - clang |
30 |
| - check-all |
31 |
| - check-llvm |
32 |
| - check-clang |
33 |
| - test-suite |
34 |
| - stage3 |
35 |
| - stage3-clang |
36 |
| - stage3-check-all |
37 |
| - stage3-check-llvm |
38 |
| - stage3-check-clang |
39 |
| - stage3-install |
40 |
| - stage3-test-suite CACHE STRING "") |
41 |
| -endif() |
| 58 | + stage2-check-clang CACHE STRING "") |
42 | 59 |
|
43 |
| -# Stage 1 Options |
44 |
| -set(STAGE1_PROJECTS "clang") |
45 |
| -set(STAGE1_RUNTIMES "") |
| 60 | + # Configuration for stage2-instrumented |
| 61 | + set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") |
| 62 | + # This enables the build targets for the final stage which is called stage2. |
| 63 | + set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "") |
| 64 | + set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "") |
| 65 | + set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "") |
| 66 | + set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "") |
46 | 67 |
|
47 |
| -if (LLVM_RELEASE_ENABLE_PGO) |
48 |
| - list(APPEND STAGE1_PROJECTS "lld") |
49 |
| - list(APPEND STAGE1_RUNTIMES "compiler-rt") |
| 68 | +else() |
| 69 | + if (LLVM_RELEASE_ENABLE_LTO) |
| 70 | + list(APPEND STAGE1_PROJECTS "lld") |
| 71 | + endif() |
| 72 | + # Any targets added here will be given the target name stage2-${target}, so |
| 73 | + # if you want to run them you can just use: |
| 74 | + # ninja -C $BUILDDIR stage2-${target} |
| 75 | + set(CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "") |
50 | 76 | endif()
|
51 | 77 |
|
| 78 | +# Stage 1 Common Config |
52 | 79 | set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
|
53 | 80 | set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
|
54 | 81 |
|
55 |
| -set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") |
56 |
| - |
57 |
| -# Stage 2 Bootstrap Setup |
58 |
| -set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") |
59 |
| -set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS |
60 |
| - clang |
61 |
| - package |
62 |
| - check-all |
63 |
| - check-llvm |
64 |
| - check-clang CACHE STRING "") |
65 |
| - |
66 |
| -# Stage 2 Options |
67 |
| -set(STAGE2_PROJECTS "clang") |
68 |
| -set(STAGE2_RUNTIMES "") |
69 |
| - |
70 |
| -if (LLVM_RELEASE_ENABLE_LTO OR LLVM_RELEASE_ENABLE_PGO) |
71 |
| - list(APPEND STAGE2_PROJECTS "lld") |
72 |
| -endif() |
73 |
| - |
74 |
| -if (LLVM_RELEASE_ENABLE_PGO) |
75 |
| - set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "") |
76 |
| - list(APPEND STAGE2_RUNTIMES "compiler-rt") |
77 |
| - set(BOOTSTRAP_LLVM_ENABLE_LTO ${LLVM_RELEASE_ENABLE_LTO}) |
78 |
| - if (LLVM_RELEASE_ENABLE_LTO) |
79 |
| - set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") |
80 |
| - endif() |
| 82 | +# stage2-instrumented and Final Stage Config: |
| 83 | +# Options that need to be set in both the instrumented stage (if we are doing |
| 84 | +# a pgo build) and the final stage. |
| 85 | +set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}" STRING) |
| 86 | +if (LLVM_RELEASE_ENABLE_LTO) |
| 87 | + set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL) |
81 | 88 | endif()
|
82 | 89 |
|
83 |
| -set(BOOTSTRAP_LLVM_ENABLE_PROJECTS ${STAGE2_PROJECTS} CACHE STRING "") |
84 |
| -set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES ${STAGE2_RUNTIMES} CACHE STRING "") |
85 |
| -if (NOT LLVM_RELEASE_ENABLE_PGO) |
86 |
| - set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "") |
87 |
| -endif() |
| 90 | +# Final Stage Config (stage2) |
| 91 | +set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING) |
| 92 | +set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING) |
88 | 93 |
|
89 |
| -# Stage 3 Options |
90 |
| -set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") |
91 |
| -set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "") |
92 |
| -set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LTO ${LLVM_RELEASE_ENABLE_LTO} CACHE STRING "") |
93 |
| -if (LLVM_RELEASE_ENABLE_LTO) |
94 |
| - set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") |
95 |
| -endif() |
0 commit comments