| 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 |
|
| 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 |
| 32 |
set (DEFAULT_RUNTIMES "compiler-rt;libcxx") |
| 33 |
if (NOT WIN32) |
| 34 |
list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind") |
| 35 |
endif() |
| 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 |
| 41 |
# steps. |
| 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 "") |
| 44 |
|
| 45 |
# Stage 1 Options |
| 46 |
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") |
| 47 |
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") |
| 48 |
|
| 49 |
set(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. |
| 54 |
set(STAGE1_RUNTIMES "compiler-rt") |
| 55 |
|
| 56 |
if (LLVM_RELEASE_ENABLE_PGO) |
| 57 |
list(APPEND STAGE1_PROJECTS "lld") |
| 58 |
set(CLANG_BOOTSTRAP_TARGETS |
| 59 |
generate-profdata |
| 60 |
stage2-package |
| 61 |
stage2-clang |
| 62 |
stage2-install |
| 63 |
stage2-check-all |
| 64 |
stage2-check-llvm |
| 65 |
stage2-check-clang CACHE STRING "") |
| 66 |
|
| 67 |
# Configuration for stage2-instrumented |
| 68 |
set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") |
| 69 |
# This enables the build targets for the final stage which is called stage2. |
| 70 |
set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "") |
| 71 |
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "") |
| 72 |
set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "") |
| 73 |
set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "") |
| 74 |
|
| 75 |
else() |
| 76 |
if (LLVM_RELEASE_ENABLE_LTO) |
| 77 |
list(APPEND STAGE1_PROJECTS "lld") |
| 78 |
endif() |
| 79 |
# Any targets added here will be given the target name stage2-${target}, so |
| 80 |
# if you want to run them you can just use: |
| 81 |
# ninja -C $BUILDDIR stage2-${target} |
| 82 |
set(CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING "") |
| 83 |
endif() |
| 84 |
|
| 85 |
# Stage 1 Common Config |
| 86 |
set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "") |
| 87 |
set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "") |
| 88 |
|
| 89 |
# stage2-instrumented and Final Stage Config: |
| 90 |
# Options that need to be set in both the instrumented stage (if we are doing |
| 91 |
# a pgo build) and the final stage. |
| 92 |
set_instrument_and_final_stage_var(CMAKE_POSITION_INDEPENDENT_CODE "ON" STRING) |
| 93 |
set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}" STRING) |
| 94 |
if (LLVM_RELEASE_ENABLE_LTO) |
| 95 |
set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL) |
| 96 |
endif() |
| 97 |
|
| 98 |
# Final Stage Config (stage2) |
| 99 |
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING) |
| 100 |
set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" STRING) |
| 101 |
set_final_stage_var(CPACK_GENERATOR "TXZ" STRING) |
| 102 |
set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING) |
| 103 |
|
| 104 |
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") |
| 105 |
set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL) |
| 106 |
endif() |