[clang] [llvm] [CMake][Release] Add option for enabling PGO to release cache file. (PR #78823)
Tom Stellard via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 19 17:01:36 PST 2024
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/78823
The option is LLVM_RELEASE_ENABLE_PGO and it's turned on by default.
>From b23e23f862bec32e42fa7aa96da1fe0c4ed38a54 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 6 Jan 2024 06:44:32 +0000
Subject: [PATCH] [CMake][Release] Add option for enabling PGO to release cache
file.
The option is LLVM_RELEASE_ENABLE_PGO and it's turned on by default.
---
clang/cmake/caches/Release.cmake | 73 +++++++++++++++++++++++-------
llvm/utils/release/test-release.sh | 4 +-
2 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index a7b9a8d0e29f88f..0d114c3734a82d3 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -4,27 +4,53 @@
# General Options
set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
+set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
# Stage 1 Bootstrap Setup
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(CLANG_BOOTSTRAP_TARGETS
- clang
- check-all
- check-llvm
- check-clang
- test-suite
- stage3
- stage3-clang
- stage3-check-all
- stage3-check-llvm
- stage3-check-clang
- stage3-install
- stage3-test-suite CACHE STRING "")
+if (LLVM_RELEASE_ENABLE_PGO)
+ set(CLANG_BOOTSTRAP_TARGETS
+ generate-profdata
+ stage2
+ stage2-clang
+ stage2-distribution
+ stage2-install
+ stage2-install-distribution
+ stage2-install-distribution-toolchain
+ stage2-check-all
+ stage2-check-llvm
+ stage2-check-clang
+ stage2-test-suite CACHE STRING "")
+else()
+ set(CLANG_BOOTSTRAP_TARGETS
+ clang
+ check-all
+ check-llvm
+ check-clang
+ test-suite
+ stage3
+ stage3-clang
+ stage3-check-all
+ stage3-check-llvm
+ stage3-check-clang
+ stage3-install
+ stage3-test-suite CACHE STRING "")
+endif()
# Stage 1 Options
-set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+set(STAGE1_PROJECTS "clang")
+set(STAGE1_RUNTIMES "")
+
+if (LLVM_RELEASE_ENABLE_PGO)
+ list(APPEND STAGE1_PROJECTS "lld")
+ list(APPEND STAGE1_RUNTIMES "compiler-rt")
+endif()
+
+set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
+set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
+
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
# Stage 2 Bootstrap Setup
@@ -37,11 +63,26 @@ set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
# Stage 2 Options
set(STAGE2_PROJECTS "clang")
-if (LLVM_RELEASE_ENABLE_LTO)
+set(STAGE2_RUNTIMES "")
+
+if (LLVM_RELEASE_ENABLE_LTO OR LLVM_RELEASE_ENABLE_PGO)
list(APPEND STAGE2_PROJECTS "lld")
endif()
+
+if (LLVM_RELEASE_ENABLE_PGO)
+ set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
+ list(APPEND STAGE2_RUNTIMES "compiler-rt")
+ set(BOOTSTRAP_LLVM_ENABLE_LTO ${LLVM_RELEASE_ENABLE_LTO})
+ if (LLVM_RELEASE_ENABLE_LTO)
+ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+ endif()
+endif()
+
set(BOOTSTRAP_LLVM_ENABLE_PROJECTS ${STAGE2_PROJECTS} CACHE STRING "")
-set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES ${STAGE2_RUNTIMES} CACHE STRING "")
+if (NOT LLVM_RELEASE_ENABLE_PGO)
+ set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+endif()
# Stage 3 Options
set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
diff --git a/llvm/utils/release/test-release.sh b/llvm/utils/release/test-release.sh
index 544d4bfdd799ce8..5b1945df47d24a7 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -359,11 +359,11 @@ function build_with_cmake_cache() {
$ExtraConfigureFlags
2>&1 | tee $LogDir/llvm.configure-$Flavor.log
- ${MAKE} $J_ARG $Verbose -C $CMakeBuildDir stage3-check-all \
+ ${MAKE} $J_ARG $Verbose -C $CMakeBuildDir stage2-check-all \
2>&1 | tee $LogDir/llvm.make-$Flavor.log > $redir
DESTDIR="${InstallDir}" \
- ${MAKE} -C $CMakeBuildDir stage3-install \
+ ${MAKE} -C $CMakeBuildDir stage2-install \
2>&1 | tee $LogDir/llvm.install-$Flavor.log > $redir
mkdir -p $BuildDir/Release
More information about the cfe-commits
mailing list