Skip to content

test-release.sh: Add a CMake cache file for 3-stage release builds #75903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"

Expand Down
41 changes: 41 additions & 0 deletions clang/cmake/caches/Release.cmake
Original file line number Diff line number Diff line change
@@ -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 "")
67 changes: 60 additions & 7 deletions llvm/utils/release/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BuildDir="`pwd`"
ExtraConfigureFlags=""
ExportBranch=""
git_ref=""

do_cmake_cache="no"
do_bolt="no"
if [ "$System" = "Linux" ]; then
case $Machine in
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down