xref: /llvm-project/clang/cmake/caches/Release.cmake (revision 748f5404ccdf28d4beef37efdaeba7a1701ab425)
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)
6
7
8function (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()
14endfunction()
15
16function (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()
24endfunction()
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
32set (DEFAULT_RUNTIMES "compiler-rt;libcxx")
33if (NOT WIN32)
34  list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind")
35endif()
36set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
37set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
38set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
39set(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
41# steps.
42set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
43set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
44
45# Stage 1 Options
46set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
47set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
48
49set(STAGE1_PROJECTS "clang")
50
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
53# macOS.
54set(STAGE1_RUNTIMES "compiler-rt")
55
56if (LLVM_RELEASE_ENABLE_PGO)
57  list(APPEND STAGE1_PROJECTS "lld")
58  set(tmp_targets
59    generate-profdata
60    stage2-package
61    stage2-clang
62    stage2
63    stage2-install
64    stage2-check-all
65    stage2-check-llvm
66    stage2-check-clang)
67
68  foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS)
69    list(APPEND tmp_targets "stage2-${X}")
70  endforeach()
71  list(REMOVE_DUPLICATES tmp_targets)
72
73  set(CLANG_BOOTSTRAP_TARGETS "${tmp_targets}" CACHE STRING "")
74
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 "")
82
83else()
84  if (LLVM_RELEASE_ENABLE_LTO)
85    list(APPEND STAGE1_PROJECTS "lld")
86  endif()
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 "")
91endif()
92
93# Stage 1 Common Config
94set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
95set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
96
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.
100set_instrument_and_final_stage_var(CMAKE_POSITION_INDEPENDENT_CODE "ON" STRING)
101set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}" STRING)
102if (LLVM_RELEASE_ENABLE_LTO)
103  set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
104endif()
105
106# Final Stage Config (stage2)
107set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)
108set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING)
109set_final_stage_var(CPACK_GENERATOR "TXZ" STRING)
110set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING)
111
112if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
113  set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL)
114endif()
115