1 # Plain options configure the first build.
2 # BOOTSTRAP_* options configure the second build.
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)
8 function (set_final_stage_var name value type)
9 if (LLVM_RELEASE_ENABLE_PGO)
10 set(BOOTSTRAP_BOOTSTRAP_${name} ${value} CACHE ${type} "")
12 set(BOOTSTRAP_${name} ${value} CACHE ${type} "")
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} "")
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.
31 # cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake
32 set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
34 list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind")
36 set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
37 set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
38 set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
39 set(LLVM_RELEASE_ENABLE_PROJECTS "clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "")
40 # Note we don't need to add install here, since it is one of the pre-defined
42 set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
43 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
46 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
47 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
49 set(STAGE1_PROJECTS "clang")
51 # Building Flang on Windows requires compiler-rt, so we need to build it in
52 # stage1. compiler-rt is also required for building the Flang tests on
54 set(STAGE1_RUNTIMES "compiler-rt")
56 if (LLVM_RELEASE_ENABLE_PGO)
57 list(APPEND STAGE1_PROJECTS "lld")
68 foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS)
69 list(APPEND tmp_targets "stage2-${X}")
71 list(REMOVE_DUPLICATES tmp_targets)
73 set(CLANG_BOOTSTRAP_TARGETS "${tmp_targets}" CACHE STRING "")
75 # Configuration for stage2-instrumented
76 set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "")
77 # This enables the build targets for the final stage which is called stage2.
78 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "")
79 set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "")
80 set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "")
81 set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
84 if (LLVM_RELEASE_ENABLE_LTO)
85 list(APPEND STAGE1_PROJECTS "lld")
87 # Any targets added here will be given the target name stage2-${target}, so
88 # if you want to run them you can just use:
89 # ninja -C $BUILDDIR stage2-${target}
90 set(CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "")
93 # Stage 1 Common Config
94 set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
95 set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
97 # stage2-instrumented and Final Stage Config:
98 # Options that need to be set in both the instrumented stage (if we are doing
99 # a pgo build) and the final stage.
100 set_instrument_and_final_stage_var(CMAKE_POSITION_INDEPENDENT_CODE "ON" STRING)
101 set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}" STRING)
102 if (LLVM_RELEASE_ENABLE_LTO)
103 set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
106 # Final Stage Config (stage2)
107 set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)
108 set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING)
109 set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
110 set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
112 if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
113 set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)