[clang] [llvm] test-release.sh: Add a CMake cache file for 3-stage release builds (PR #75903)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 00:05:15 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-github-workflow
Author: Tom Stellard (tstellar)
<details>
<summary>Changes</summary>
You can now pass the -use-cmake-cache option to test-release.sh and it will use a predefined cache file for building the release. This will make it easier to reproduce the builds and add other enhancements like PGO or bolt optimizations.
---
Full diff: https://github.com/llvm/llvm-project/pull/75903.diff
3 Files Affected:
- (modified) .github/workflows/release-binaries.yml (+3-2)
- (added) clang/cmake/caches/Release.cmake (+41)
- (modified) llvm/utils/release/test-release.sh (+60-7)
``````````diff
diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml
index 4e3eaff97a8783..4a4ba9dcc5ca34 100644
--- a/.github/workflows/release-binaries.yml
+++ b/.github/workflows/release-binaries.yml
@@ -93,8 +93,8 @@ jobs:
- name: Build Clang
run: |
- cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_ENABLE_ASSERTIONS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLLVM_ENABLE_PROJECTS=clang -S llvm -B build
- ninja -v -C build
+ cmake -G Ninja -C clang/cmake/caches/Release.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_POSITION_INDEPENDENT_CODE=ON -S llvm -B build
+ ninja -v -C build clang
build-binaries:
@@ -152,6 +152,7 @@ jobs:
-triple ${{ matrix.target.triple }} \
-use-ninja \
-no-checkout \
+ -use-cmake-cache \
-no-test-suite \
-configure-flags "-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
new file mode 100644
index 00000000000000..42c88655c58cee
--- /dev/null
+++ b/clang/cmake/caches/Release.cmake
@@ -0,0 +1,41 @@
+# Plain options configure the first build.
+# BOOTSTRAP_* options configure the second build.
+# BOOTSTRAP_BOOTSTRAP_* options configure the third build.
+
+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 "")
+
+# Stage 1 Options
+set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+# Stage 2 Bootstrap Setup
+set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP=ON CACHE STRING "")
+set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
+ clang
+ check-all
+ check-llvm
+ check-clang CACHE STRING "")
+
+# Stage 2 Options
+set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+# Stage 3 Options
+set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
+set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "")
diff --git a/llvm/utils/release/test-release.sh b/llvm/utils/release/test-release.sh
index f38134e3d22d8f..544d4bfdd799ce 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -46,7 +46,7 @@ BuildDir="`pwd`"
ExtraConfigureFlags=""
ExportBranch=""
git_ref=""
-
+do_cmake_cache="no"
do_bolt="no"
if [ "$System" = "Linux" ]; then
case $Machine in
@@ -87,6 +87,7 @@ function usage() {
echo " -no-mlir Disable check-out & build MLIR"
echo " -no-flang Disable check-out & build Flang"
echo " -silent-log Don't output build logs to stdout"
+ echo " -use-cmake-cache Build using a CMake cache file"
}
while [ $# -gt 0 ]; do
@@ -200,6 +201,9 @@ while [ $# -gt 0 ]; do
-silent-log )
do_silent_log="yes"
;;
+ -use-cmake-cache | --use-cmake-cache )
+ do_cmake_cache="yes"
+ ;;
-help | --help | -h | --h | -\? )
usage
exit 0
@@ -328,6 +332,55 @@ Package=$Package-$Triple
# Errors to be highlighted at the end are written to this file.
echo -n > $LogDir/deferred_errors.log
+redir="/dev/stdout"
+if [ $do_silent_log == "yes" ]; then
+ echo "# Silencing build logs because of -silent-log flag..."
+ redir="/dev/null"
+fi
+
+
+function build_with_cmake_cache() {
+(
+ CMakeBuildDir=$BuildDir/build
+ SrcDir=$BuildDir/llvm-project/
+ InstallDir=$BuildDir/install
+
+ rm -rf $CMakeBuildDir
+
+ # FIXME: Would be nice if the commands were echoed to the log file too.
+ set -x
+
+ env CC="$c_compiler" CXX="$cxx_compiler" \
+ cmake -G "$generator" -B $CMakeBuildDir -S $SrcDir/llvm \
+ -C $SrcDir/clang/cmake/caches/Release.cmake \
+ -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_POSITION_INDEPENDENT_CODE;LLVM_LIT_ARGS" \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+ -DLLVM_LIT_ARGS="-j $NumJobs $LitVerbose" \
+ $ExtraConfigureFlags
+ 2>&1 | tee $LogDir/llvm.configure-$Flavor.log
+
+ ${MAKE} $J_ARG $Verbose -C $CMakeBuildDir stage3-check-all \
+ 2>&1 | tee $LogDir/llvm.make-$Flavor.log > $redir
+
+ DESTDIR="${InstallDir}" \
+ ${MAKE} -C $CMakeBuildDir stage3-install \
+ 2>&1 | tee $LogDir/llvm.install-$Flavor.log > $redir
+
+ mkdir -p $BuildDir/Release
+ pushd $BuildDir/Release
+ mv $InstallDir/usr/local $Package
+ if [ "$use_gzip" = "yes" ]; then
+ tar cf - $Package | gzip -9c > $BuildDir/$Package.tar.gz
+ else
+ tar cf - $Package | xz -9ce -T $NumJobs > $BuildDir/$Package.tar.xz
+ fi
+ mv $Package $InstallDir/usr/local
+ popd
+) 2>&1 | tee $LogDir/testing.$Release-$RC.log
+
+ exit 0
+}
+
function deferred_error() {
Phase="$1"
Flavor="$2"
@@ -485,12 +538,6 @@ function build_llvmCore() {
fi
fi
- redir="/dev/stdout"
- if [ $do_silent_log == "yes" ]; then
- echo "# Silencing build logs because of -silent-log flag..."
- redir="/dev/null"
- fi
-
cd $ObjDir
echo "# Compiling llvm $Release-$RC $Flavor"
echo "# ${MAKE} $J_ARG $Verbose"
@@ -600,7 +647,13 @@ if [ $do_test_suite = "yes" ]; then
mkdir -p $TestSuiteBuildDir
fi
+if [ "$do_cmake_cache" = "yes" ]; then
+ build_with_cmake_cache
+ exit 0
+fi
+
(
+
Flavors="Release"
if [ "$do_debug" = "yes" ]; then
Flavors="Debug $Flavors"
``````````
</details>
https://github.com/llvm/llvm-project/pull/75903
More information about the llvm-commits
mailing list